Home | History | Annotate | Line # | Download | only in rumpkern
rump_curlwp___thread.h revision 1.2.10.2
      1  1.2.10.2  tls /*	$NetBSD: rump_curlwp___thread.h,v 1.2.10.2 2014/08/20 00:04:41 tls Exp $	*/
      2  1.2.10.2  tls 
      3  1.2.10.2  tls /*-
      4  1.2.10.2  tls  * Copyright (c) 2014 Antti Kantee.  All Rights Reserved.
      5  1.2.10.2  tls  *
      6  1.2.10.2  tls  * Redistribution and use in source and binary forms, with or without
      7  1.2.10.2  tls  * modification, are permitted provided that the following conditions
      8  1.2.10.2  tls  * are met:
      9  1.2.10.2  tls  * 1. Redistributions of source code must retain the above copyright
     10  1.2.10.2  tls  *    notice, this list of conditions and the following disclaimer.
     11  1.2.10.2  tls  * 2. Redistributions in binary form must reproduce the above copyright
     12  1.2.10.2  tls  *    notice, this list of conditions and the following disclaimer in the
     13  1.2.10.2  tls  *    documentation and/or other materials provided with the distribution.
     14  1.2.10.2  tls  *
     15  1.2.10.2  tls  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
     16  1.2.10.2  tls  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     17  1.2.10.2  tls  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     18  1.2.10.2  tls  * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     19  1.2.10.2  tls  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     20  1.2.10.2  tls  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     21  1.2.10.2  tls  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     22  1.2.10.2  tls  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     23  1.2.10.2  tls  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     24  1.2.10.2  tls  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     25  1.2.10.2  tls  * SUCH DAMAGE.
     26  1.2.10.2  tls  */
     27  1.2.10.2  tls 
     28  1.2.10.2  tls extern __thread struct lwp *curlwp_storage;
     29  1.2.10.2  tls #ifdef RUMP__CURLWP_PRIVATE
     30  1.2.10.2  tls #include <rump/rumpuser.h>
     31  1.2.10.2  tls 
     32  1.2.10.2  tls __thread struct lwp *curlwp_storage;
     33  1.2.10.2  tls static void
     34  1.2.10.2  tls lwproc_curlwpop(enum rumplwpop op, struct lwp *l)
     35  1.2.10.2  tls {
     36  1.2.10.2  tls 
     37  1.2.10.2  tls 	switch (op) {
     38  1.2.10.2  tls 	case RUMPUSER_LWP_CREATE:
     39  1.2.10.2  tls 	case RUMPUSER_LWP_DESTROY:
     40  1.2.10.2  tls 		break;
     41  1.2.10.2  tls 	case RUMPUSER_LWP_SET:
     42  1.2.10.2  tls 		KASSERT(curlwp_storage == NULL);
     43  1.2.10.2  tls 		curlwp_storage = l;
     44  1.2.10.2  tls 		break;
     45  1.2.10.2  tls 	case RUMPUSER_LWP_CLEAR:
     46  1.2.10.2  tls 		KASSERT(curlwp_storage == l);
     47  1.2.10.2  tls 		curlwp_storage = NULL;
     48  1.2.10.2  tls 		break;
     49  1.2.10.2  tls 	}
     50  1.2.10.2  tls 	/*
     51  1.2.10.2  tls 	 * Need to keep hypercall layer in sync, since it can use curlwp
     52  1.2.10.2  tls 	 * for things like mutexes.  Should be fixed/adjusted somehow.
     53  1.2.10.2  tls 	 */
     54  1.2.10.2  tls 	rumpuser_curlwpop(op, l);
     55  1.2.10.2  tls }
     56  1.2.10.2  tls #endif
     57  1.2.10.2  tls 
     58  1.2.10.2  tls static inline struct lwp * __attribute__((const))
     59  1.2.10.2  tls rump_curlwp_fast(void)
     60  1.2.10.2  tls {
     61  1.2.10.2  tls 
     62  1.2.10.2  tls 	return curlwp_storage;
     63  1.2.10.2  tls }
     64