/* OK, macros are fun and everything, but this is crazy.. */ /* This is the expanded part of kern/kern_kthread.c */ void kproc_start(udata) const void *udata; { const struct kproc_desc *kp = udata; int error; error = kthread_create((void (*) (void *))kp->func, 0, kp->global_procpp, 0, "%s", kp->arg0); if (error) panic("kproc_start: %s: error %d", kp->arg0, error); } /* ****************************************************************** */ /* ****************************************************************** */ /* ****************************************************************** */ #if 0 int kthread_create(void (*func)(void *), void *arg, struct proc **newpp, int flags, const char *fmt, ...) { int error; va_list ap; struct proc *p2; if (!proc0.p_stats /* || proc0.p_stats->p_start.tv_sec == 0 */) panic("kthread_create called too soon"); error = fork1(thread0, RFMEM | RFFDG | RFPROC | RFSTOPPED | flags, &p2); if (error) return error; /* save a global descriptor, if desired */ if (newpp != NULL) *newpp = p2; /* this is a non-swapped system process */ PROC_LOCK(p2); p2->p_flag |= P_SYSTEM | P_KTHREAD; p2->p_procsig->ps_flag |= PS_NOCLDWAIT; _PHOLD(p2); PROC_UNLOCK(p2); /* set up arg0 for 'ps', et al */ va_start(ap, fmt); vsnprintf(p2->p_comm, sizeof(p2->p_comm), fmt, ap); va_end(ap); /* call the processes' main()... */ cpu_set_fork_handler(&p2->p_thread, func, arg); /* XXXKSE */ /* Delay putting it on the run queue until now. */ mtx_lock_spin(&sched_lock); p2->p_sflag |= PS_INMEM; if (!(flags & RFSTOPPED)) { p2->p_stat = SRUN; setrunqueue(&p2->p_thread); /* XXXKSE */ } mtx_unlock_spin(&sched_lock); return 0; } #endif int kthread_create(void (*func) (void *), void *arg, struct proc ** newpp, int flags, const char *fmt,...) { int error; va_list ap; struct proc *p2; if (!proc0.p_stats) panic("kthread_create called too soon"); error = fork1(thread0, (1 << 5) | (1 << 2) | (1 << 4) | (1 << 17) | flags, &p2); if (error) return error; if (newpp != 0) *newpp = p2; do { do { if (!atomic_cmpset_ptr(&(((((&(p2)->p_mtx)))))->mtx_lock, (void *)0x00000004, ((({ __typeof(((struct globaldata *) 0)->gd_curthread) __result; if (sizeof(__result) == 1) { u_char __b; __asm volatile ("movb %%fs:%1,%0":"=r" (__b):"m"(*(u_char *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __b; } else if (sizeof(__result) == 2) { u_short __w; __asm volatile ("movw %%fs:%1,%0":"=r" (__w):"m"(*(u_short *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __w; } else if (sizeof(__result) == 4) { u_int __i; __asm volatile ("movl %%fs:%1,%0":"=r" (__i):"m"(*(u_int *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __i; } else { __result = *({ __typeof(((struct globaldata *) 0)->gd_curthread) * __p; __asm volatile ("movl %%fs:%1,%0; addl %2,%0":"=r" (__p):"m"(*(struct globaldata *) (((size_t) (&((struct globaldata *) 0)->gd_prvspace)))), "i"(((size_t) (&((struct globaldata *) 0)->gd_curthread)))); __p; }); } __result; }))))) _mtx_lock_sleep(((((&(p2)->p_mtx)))), (((0))), ((0)), ((0))); } while (0); do { if ((((((0))) & 0x00000002) == 0 && (((&(((&(p2)->p_mtx)))->mtx_object))->lo_flags & 0x00040000) == 0)); } while (0); } while (0); p2->p_flag |= 0x00200 | 0x00004; p2->p_procsig->ps_flag |= 0x0001; do { if ((p2)->p_lock++ == 0) faultin((p2)); } while (0); do { do { if (((((((0)))) & 0x00000002) == 0 && (((&(((&(p2)->p_mtx)))->mtx_object))->lo_flags & 0x00040000) == 0)); } while (0); do { if (!atomic_cmpset_ptr(&(((((&(p2)->p_mtx)))))->mtx_lock, ((({ __typeof(((struct globaldata *) 0)->gd_curthread) __result; if (sizeof(__result) == 1) { u_char __b; __asm volatile ("movb %%fs:%1,%0":"=r" (__b):"m"(*(u_char *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __b; } else if (sizeof(__result) == 2) { u_short __w; __asm volatile ("movw %%fs:%1,%0":"=r" (__w):"m"(*(u_short *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __w; } else if (sizeof(__result) == 4) { u_int __i; __asm volatile ("movl %%fs:%1,%0":"=r" (__i):"m"(*(u_int *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __i; } else { __result = *({ __typeof(((struct globaldata *) 0)->gd_curthread) * __p; __asm volatile ("movl %%fs:%1,%0; addl %2,%0":"=r" (__p):"m"(*(struct globaldata *) (((size_t) (&((struct globaldata *) 0)->gd_prvspace)))), "i"(((size_t) (&((struct globaldata *) 0)->gd_curthread)))); __p; }); } __result; }))), (void *)0x00000004)) _mtx_unlock_sleep(((((&(p2)->p_mtx)))), (((0))), ((0)), ((0))); } while (0); } while (0); ((ap) = (va_list) __builtin_next_arg(fmt)); vsnprintf(p2->p_comm, sizeof(p2->p_comm), fmt, ap); ; cpu_set_fork_handler(&p2->p_thread, func, arg); do { do { critical_t _mtx_crit; _mtx_crit = critical_enter(); if (!atomic_cmpset_ptr(&(((((&sched_lock)))))->mtx_lock, (void *)0x00000004, ((({ __typeof(((struct globaldata *) 0)->gd_curthread) __result; if (sizeof(__result) == 1) { u_char __b; __asm volatile ("movb %%fs:%1,%0":"=r" (__b):"m"(*(u_char *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __b; } else if (sizeof(__result) == 2) { u_short __w; __asm volatile ("movw %%fs:%1,%0":"=r" (__w):"m"(*(u_short *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __w; } else if (sizeof(__result) == 4) { u_int __i; __asm volatile ("movl %%fs:%1,%0":"=r" (__i):"m"(*(u_int *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __i; } else { __result = *({ __typeof(((struct globaldata *) 0)->gd_curthread) * __p; __asm volatile ("movl %%fs:%1,%0; addl %2,%0":"=r" (__p):"m"(*(struct globaldata *) (((size_t) (&((struct globaldata *) 0)->gd_prvspace)))), "i"(((size_t) (&((struct globaldata *) 0)->gd_curthread)))); __p; }); } __result; }))))) { if (((((&sched_lock))))->mtx_lock == (uintptr_t) (({ __typeof(((struct globaldata *) 0)->gd_curthread) __result; if (sizeof(__result) == 1) { u_char __b; __asm volatile ("movb %%fs:%1,%0":"=r" (__b):"m"(*(u_char *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __b; } else if (sizeof(__result) == 2) { u_short __w; __asm volatile ("movw %%fs:%1,%0":"=r" (__w):"m"(*(u_short *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __w; } else if (sizeof(__result) == 4) { u_int __i; __asm volatile ("movl %%fs:%1,%0":"=r" (__i):"m"(*(u_int *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __i; } else { __result = *({ __typeof(((struct globaldata *) 0)->gd_curthread) * __p; __asm volatile ("movl %%fs:%1,%0; addl %2,%0":"=r" (__p):"m"(*(struct globaldata *) (((size_t) (&((struct globaldata *) 0)->gd_prvspace)))), "i"(((size_t) (&((struct globaldata *) 0)->gd_curthread)))); __p; }); } __result; }))) ((((&sched_lock))))->mtx_recurse++; else _mtx_lock_spin(((((&sched_lock)))), (((0))), _mtx_crit, ((0)), ((0))); } else ((((&sched_lock))))->mtx_savecrit = _mtx_crit; } while (0); do { if ((((((0))) & 0x00000002) == 0 && (((&(((&sched_lock)))->mtx_object))->lo_flags & 0x00040000) == 0)); } while (0); } while (0); p2->p_sflag |= 0x00001; if (!(flags & (1 << 17))) { p2->p_stat = 2; setrunqueue(&p2->p_thread); } do { do { if (((((((0)))) & 0x00000002) == 0 && (((&(((&sched_lock)))->mtx_object))->lo_flags & 0x00040000) == 0)); } while (0); do { critical_t _mtx_crit = ((((&sched_lock))))->mtx_savecrit; if (((((((&sched_lock)))))->mtx_recurse != 0)) ((((&sched_lock))))->mtx_recurse--; else { atomic_store_rel_ptr(&(((((&sched_lock)))))->mtx_lock, (void *)0x00000004); critical_exit(_mtx_crit); } } while (0); } while (0); return 0; } /* ****************************************************************** */ /* ****************************************************************** */ /* ****************************************************************** */ #if 0 void kthread_exit(int ecode) { sx_xlock(&proctree_lock); PROC_LOCK(curproc); proc_reparent(curproc, initproc); PROC_UNLOCK(curproc); sx_xunlock(&proctree_lock); exit1(curthread, W_EXITCODE(ecode, 0)); } #endif void kthread_exit(int ecode) { _sx_xlock((&proctree_lock), 0, 0); do { do { if (!atomic_cmpset_ptr(&(((((&((({ __typeof(((struct globaldata *) 0)->gd_curthread) __result; if (sizeof(__result) == 1) { u_char __b; __asm volatile ("movb %%fs:%1,%0":"=r" (__b):"m"(*(u_char *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __b; } else if (sizeof(__result) == 2) { u_short __w; __asm volatile ("movw %%fs:%1,%0":"=r" (__w):"m"(*(u_short *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __w; } else if (sizeof(__result) == 4) { u_int __i; __asm volatile ("movl %%fs:%1,%0":"=r" (__i):"m"(*(u_int *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __i; } else { __result = *({ __typeof(((struct globaldata *) 0)->gd_curthread) * __p; __asm volatile ("movl %%fs:%1,%0; addl %2,%0":"=r" (__p):"m"(*(struct globaldata *) (((size_t) (&((struct globaldata *) 0)->gd_prvspace)))), "i"(((size_t) (&((struct globaldata *) 0)->gd_curthread)))); __p; }); } __result; })->td_proc))->p_mtx)))))->mtx_lock, (void *)0x00000004, ((({ __typeof(((struct globaldata *) 0)->gd_curthread) __result; if (sizeof(__result) == 1) { u_char __b; __asm volatile ("movb %%fs:%1,%0":"=r" (__b):"m"(*(u_char *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __b; } else if (sizeof(__result) == 2) { u_short __w; __asm volatile ("movw %%fs:%1,%0":"=r" (__w):"m"(*(u_short *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __w; } else if (sizeof(__result) == 4) { u_int __i; __asm volatile ("movl %%fs:%1,%0":"=r" (__i):"m"(*(u_int *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __i; } else { __result = *({ __typeof(((struct globaldata *) 0)->gd_curthread) * __p; __asm volatile ("movl %%fs:%1,%0; addl %2,%0":"=r" (__p):"m"(*(struct globaldata *) (((size_t) (&((struct globaldata *) 0)->gd_prvspace)))), "i"(((size_t) (&((struct globaldata *) 0)->gd_curthread)))); __p; }); } __result; }))))) _mtx_lock_sleep(((((&((({ __typeof(((struct globaldata *) 0)->gd_curthread) __result; if (sizeof(__result) == 1) { u_char __b; __asm volatile ("movb %%fs:%1,%0":"=r" (__b):"m"(*(u_char *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __b; } else if (sizeof(__result) == 2) { u_short __w; __asm volatile ("movw %%fs:%1,%0":"=r" (__w):"m"(*(u_short *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __w; } else if (sizeof(__result) == 4) { u_int __i; __asm volatile ("movl %%fs:%1,%0":"=r" (__i):"m"(*(u_int *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __i; } else { __result = *({ __typeof(((struct globaldata *) 0)->gd_curthread) * __p; __asm volatile ("movl %%fs:%1,%0; addl %2,%0":"=r" (__p):"m"(*(struct globaldata *) (((size_t) (&((struct globaldata *) 0)->gd_prvspace)))), "i"(((size_t) (&((struct globaldata *) 0)->gd_curthread)))); __p; }); } __result; })->td_proc))->p_mtx)))), (((0))), ((0)), ((0))); } while (0); do { if ((((((0))) & 0x00000002) == 0 && (((&(((&((({ __typeof(((struct globaldata *) 0)->gd_curthread) __result; if (sizeof(__result) == 1) { u_char __b; __asm volatile ("movb %%fs:%1,%0":"=r" (__b):"m"(*(u_char *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __b; } else if (sizeof(__result) == 2) { u_short __w; __asm volatile ("movw %%fs:%1,%0":"=r" (__w):"m"(*(u_short *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __w; } else if (sizeof(__result) == 4) { u_int __i; __asm volatile ("movl %%fs:%1,%0":"=r" (__i):"m"(*(u_int *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __i; } else { __result = *({ __typeof(((struct globaldata *) 0)->gd_curthread) * __p; __asm volatile ("movl %%fs:%1,%0; addl %2,%0":"=r" (__p):"m"(*(struct globaldata *) (((size_t) (&((struct globaldata *) 0)->gd_prvspace)))), "i"(((size_t) (&((struct globaldata *) 0)->gd_curthread)))); __p; }); } __result; })->td_proc))->p_mtx)))->mtx_object))->lo_flags & 0x00040000) == 0)); } while (0); } while (0); proc_reparent((({ __typeof(((struct globaldata *) 0)->gd_curthread) __result; if (sizeof(__result) == 1) { u_char __b; __asm volatile ("movb %%fs:%1,%0":"=r" (__b):"m"(*(u_char *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __b; } else if (sizeof(__result) == 2) { u_short __w; __asm volatile ("movw %%fs:%1,%0":"=r" (__w):"m"(*(u_short *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __w; } else if (sizeof(__result) == 4) { u_int __i; __asm volatile ("movl %%fs:%1,%0":"=r" (__i):"m"(*(u_int *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __i; } else { __result = *({ __typeof(((struct globaldata *) 0)->gd_curthread) * __p; __asm volatile ("movl %%fs:%1,%0; addl %2,%0":"=r" (__p):"m"(*(struct globaldata *) (((size_t) (&((struct globaldata *) 0)->gd_prvspace)))), "i"(((size_t) (&((struct globaldata *) 0)->gd_curthread)))); __p; }); } __result; })->td_proc), initproc); do { do { if (((((((0)))) & 0x00000002) == 0 && (((&(((&((({ __typeof(((struct globaldata *) 0)->gd_curthread) __result; if (sizeof(__result) == 1) { u_char __b; __asm volatile ("movb %%fs:%1,%0":"=r" (__b):"m"(*(u_char *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __b; } else if (sizeof(__result) == 2) { u_short __w; __asm volatile ("movw %%fs:%1,%0":"=r" (__w):"m"(*(u_short *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __w; } else if (sizeof(__result) == 4) { u_int __i; __asm volatile ("movl %%fs:%1,%0":"=r" (__i):"m"(*(u_int *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __i; } else { __result = *({ __typeof(((struct globaldata *) 0)->gd_curthread) * __p; __asm volatile ("movl %%fs:%1,%0; addl %2,%0":"=r" (__p):"m"(*(struct globaldata *) (((size_t) (&((struct globaldata *) 0)->gd_prvspace)))), "i"(((size_t) (&((struct globaldata *) 0)->gd_curthread)))); __p; }); } __result; })->td_proc))->p_mtx)))->mtx_object))->lo_flags & 0x00040000) == 0)); } while (0); do { if (!atomic_cmpset_ptr(&(((((&((({ __typeof(((struct globaldata *) 0)->gd_curthread) __result; if (sizeof(__result) == 1) { u_char __b; __asm volatile ("movb %%fs:%1,%0":"=r" (__b):"m"(*(u_char *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __b; } else if (sizeof(__result) == 2) { u_short __w; __asm volatile ("movw %%fs:%1,%0":"=r" (__w):"m"(*(u_short *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __w; } else if (sizeof(__result) == 4) { u_int __i; __asm volatile ("movl %%fs:%1,%0":"=r" (__i):"m"(*(u_int *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __i; } else { __result = *({ __typeof(((struct globaldata *) 0)->gd_curthread) * __p; __asm volatile ("movl %%fs:%1,%0; addl %2,%0":"=r" (__p):"m"(*(struct globaldata *) (((size_t) (&((struct globaldata *) 0)->gd_prvspace)))), "i"(((size_t) (&((struct globaldata *) 0)->gd_curthread)))); __p; }); } __result; })->td_proc))->p_mtx)))))->mtx_lock, ((({ __typeof(((struct globaldata *) 0)->gd_curthread) __result; if (sizeof(__result) == 1) { u_char __b; __asm volatile ("movb %%fs:%1,%0":"=r" (__b):"m"(*(u_char *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __b; } else if (sizeof(__result) == 2) { u_short __w; __asm volatile ("movw %%fs:%1,%0":"=r" (__w):"m"(*(u_short *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __w; } else if (sizeof(__result) == 4) { u_int __i; __asm volatile ("movl %%fs:%1,%0":"=r" (__i):"m"(*(u_int *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __i; } else { __result = *({ __typeof(((struct globaldata *) 0)->gd_curthread) * __p; __asm volatile ("movl %%fs:%1,%0; addl %2,%0":"=r" (__p):"m"(*(struct globaldata *) (((size_t) (&((struct globaldata *) 0)->gd_prvspace)))), "i"(((size_t) (&((struct globaldata *) 0)->gd_curthread)))); __p; }); } __result; }))), (void *)0x00000004)) _mtx_unlock_sleep(((((&((({ __typeof(((struct globaldata *) 0)->gd_curthread) __result; if (sizeof(__result) == 1) { u_char __b; __asm volatile ("movb %%fs:%1,%0":"=r" (__b):"m"(*(u_char *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __b; } else if (sizeof(__result) == 2) { u_short __w; __asm volatile ("movw %%fs:%1,%0":"=r" (__w):"m"(*(u_short *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __w; } else if (sizeof(__result) == 4) { u_int __i; __asm volatile ("movl %%fs:%1,%0":"=r" (__i):"m"(*(u_int *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __i; } else { __result = *({ __typeof(((struct globaldata *) 0)->gd_curthread) * __p; __asm volatile ("movl %%fs:%1,%0; addl %2,%0":"=r" (__p):"m"(*(struct globaldata *) (((size_t) (&((struct globaldata *) 0)->gd_prvspace)))), "i"(((size_t) (&((struct globaldata *) 0)->gd_curthread)))); __p; }); } __result; })->td_proc))->p_mtx)))), (((0))), ((0)), ((0))); } while (0); } while (0); _sx_xunlock((&proctree_lock), 0, 0); exit1(({ __typeof(((struct globaldata *) 0)->gd_curthread) __result; if (sizeof(__result) == 1) { u_char __b; __asm volatile ("movb %%fs:%1,%0":"=r" (__b):"m"(*(u_char *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __b; } else if (sizeof(__result) == 2) { u_short __w; __asm volatile ("movw %%fs:%1,%0":"=r" (__w):"m"(*(u_short *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __w; } else if (sizeof(__result) == 4) { u_int __i; __asm volatile ("movl %%fs:%1,%0":"=r" (__i):"m"(*(u_int *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __i; } else { __result = *({ __typeof(((struct globaldata *) 0)->gd_curthread) * __p; __asm volatile ("movl %%fs:%1,%0; addl %2,%0":"=r" (__p):"m"(*(struct globaldata *) (((size_t) (&((struct globaldata *) 0)->gd_prvspace)))), "i"(((size_t) (&((struct globaldata *) 0)->gd_curthread)))); __p; }); } __result; }), ((ecode) << 8 | (0))); } /* ****************************************************************** */ /* ****************************************************************** */ /* ****************************************************************** */ #if 0 int kthread_suspend(struct proc *p, int timo) { PROC_LOCK(p); if ((p->p_flag & P_KTHREAD) == 0) { PROC_UNLOCK(p); return (EINVAL); } SIGADDSET(p->p_siglist, SIGSTOP); return msleep(&p->p_siglist, &p->p_mtx, PPAUSE | PDROP, "suspkt", timo); } #endif int kthread_suspend(struct proc * p, int timo) { do { do { if (!atomic_cmpset_ptr(&(((((&(p)->p_mtx)))))->mtx_lock, (void *)0x00000004, ((({ __typeof(((struct globaldata *) 0)->gd_curthread) __result; if (sizeof(__result) == 1) { u_char __b; __asm volatile ("movb %%fs:%1,%0":"=r" (__b):"m"(*(u_char *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __b; } else if (sizeof(__result) == 2) { u_short __w; __asm volatile ("movw %%fs:%1,%0":"=r" (__w):"m"(*(u_short *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __w; } else if (sizeof(__result) == 4) { u_int __i; __asm volatile ("movl %%fs:%1,%0":"=r" (__i):"m"(*(u_int *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __i; } else { __result = *({ __typeof(((struct globaldata *) 0)->gd_curthread) * __p; __asm volatile ("movl %%fs:%1,%0; addl %2,%0":"=r" (__p):"m"(*(struct globaldata *) (((size_t) (&((struct globaldata *) 0)->gd_prvspace)))), "i"(((size_t) (&((struct globaldata *) 0)->gd_curthread)))); __p; }); } __result; }))))) _mtx_lock_sleep(((((&(p)->p_mtx)))), (((0))), ((0)), ((0))); } while (0); do { if ((((((0))) & 0x00000002) == 0 && (((&(((&(p)->p_mtx)))->mtx_object))->lo_flags & 0x00040000) == 0)); } while (0); } while (0); if ((p->p_flag & 0x00004) == 0) { do { do { if (((((((0)))) & 0x00000002) == 0 && (((&(((&(p)->p_mtx)))->mtx_object))->lo_flags & 0x00040000) == 0)); } while (0); do { if (!atomic_cmpset_ptr(&(((((&(p)->p_mtx)))))->mtx_lock, ((({ __typeof(((struct globaldata *) 0)->gd_curthread) __result; if (sizeof(__result) == 1) { u_char __b; __asm volatile ("movb %%fs:%1,%0":"=r" (__b):"m"(*(u_char *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __b; } else if (sizeof(__result) == 2) { u_short __w; __asm volatile ("movw %%fs:%1,%0":"=r" (__w):"m"(*(u_short *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __w; } else if (sizeof(__result) == 4) { u_int __i; __asm volatile ("movl %%fs:%1,%0":"=r" (__i):"m"(*(u_int *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __i; } else { __result = *({ __typeof(((struct globaldata *) 0)->gd_curthread) * __p; __asm volatile ("movl %%fs:%1,%0; addl %2,%0":"=r" (__p):"m"(*(struct globaldata *) (((size_t) (&((struct globaldata *) 0)->gd_prvspace)))), "i"(((size_t) (&((struct globaldata *) 0)->gd_curthread)))); __p; }); } __result; }))), (void *)0x00000004)) _mtx_unlock_sleep(((((&(p)->p_mtx)))), (((0))), ((0)), ((0))); } while (0); } while (0); return (22); } (p->p_siglist).__bits[(((17) - 1) >> 5)] |= (1 << (((17) - 1) & 31)); return msleep(&p->p_siglist, &p->p_mtx, ((64) + 40) | 0x200, "suspkt", timo); } /* ****************************************************************** */ /* ****************************************************************** */ /* ****************************************************************** */ #if 0 int kthread_resume(struct proc *p) { PROC_LOCK(p); if ((p->p_flag & P_KTHREAD) == 0) { PROC_UNLOCK(p); return (EINVAL); } SIGDELSET(p->p_siglist, SIGSTOP); PROC_UNLOCK(p); wakeup(&p->p_siglist); return (0); } #endif int kthread_resume(struct proc * p) { do { do { if (!atomic_cmpset_ptr(&(((((&(p)->p_mtx)))))->mtx_lock, (void *)0x00000004, ((({ __typeof(((struct globaldata *) 0)->gd_curthread) __result; if (sizeof(__result) == 1) { u_char __b; __asm volatile ("movb %%fs:%1,%0":"=r" (__b):"m"(*(u_char *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __b; } else if (sizeof(__result) == 2) { u_short __w; __asm volatile ("movw %%fs:%1,%0":"=r" (__w):"m"(*(u_short *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __w; } else if (sizeof(__result) == 4) { u_int __i; __asm volatile ("movl %%fs:%1,%0":"=r" (__i):"m"(*(u_int *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __i; } else { __result = *({ __typeof(((struct globaldata *) 0)->gd_curthread) * __p; __asm volatile ("movl %%fs:%1,%0; addl %2,%0":"=r" (__p):"m"(*(struct globaldata *) (((size_t) (&((struct globaldata *) 0)->gd_prvspace)))), "i"(((size_t) (&((struct globaldata *) 0)->gd_curthread)))); __p; }); } __result; }))))) _mtx_lock_sleep(((((&(p)->p_mtx)))), (((0))), ((0)), ((0))); } while (0); do { if ((((((0))) & 0x00000002) == 0 && (((&(((&(p)->p_mtx)))->mtx_object))->lo_flags & 0x00040000) == 0)); } while (0); } while (0); if ((p->p_flag & 0x00004) == 0) { do { do { if (((((((0)))) & 0x00000002) == 0 && (((&(((&(p)->p_mtx)))->mtx_object))->lo_flags & 0x00040000) == 0)); } while (0); do { if (!atomic_cmpset_ptr(&(((((&(p)->p_mtx)))))->mtx_lock, ((({ __typeof(((struct globaldata *) 0)->gd_curthread) __result; if (sizeof(__result) == 1) { u_char __b; __asm volatile ("movb %%fs:%1,%0":"=r" (__b):"m"(*(u_char *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __b; } else if (sizeof(__result) == 2) { u_short __w; __asm volatile ("movw %%fs:%1,%0":"=r" (__w):"m"(*(u_short *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __w; } else if (sizeof(__result) == 4) { u_int __i; __asm volatile ("movl %%fs:%1,%0":"=r" (__i):"m"(*(u_int *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __i; } else { __result = *({ __typeof(((struct globaldata *) 0)->gd_curthread) * __p; __asm volatile ("movl %%fs:%1,%0; addl %2,%0":"=r" (__p):"m"(*(struct globaldata *) (((size_t) (&((struct globaldata *) 0)->gd_prvspace)))), "i"(((size_t) (&((struct globaldata *) 0)->gd_curthread)))); __p; }); } __result; }))), (void *)0x00000004)) _mtx_unlock_sleep(((((&(p)->p_mtx)))), (((0))), ((0)), ((0))); } while (0); } while (0); return (22); } (p->p_siglist).__bits[(((17) - 1) >> 5)] &= ~(1 << (((17) - 1) & 31)); do { do { if (((((((0)))) & 0x00000002) == 0 && (((&(((&(p)->p_mtx)))->mtx_object))->lo_flags & 0x00040000) == 0)); } while (0); do { if (!atomic_cmpset_ptr(&(((((&(p)->p_mtx)))))->mtx_lock, ((({ __typeof(((struct globaldata *) 0)->gd_curthread) __result; if (sizeof(__result) == 1) { u_char __b; __asm volatile ("movb %%fs:%1,%0":"=r" (__b):"m"(*(u_char *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __b; } else if (sizeof(__result) == 2) { u_short __w; __asm volatile ("movw %%fs:%1,%0":"=r" (__w):"m"(*(u_short *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __w; } else if (sizeof(__result) == 4) { u_int __i; __asm volatile ("movl %%fs:%1,%0":"=r" (__i):"m"(*(u_int *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __i; } else { __result = *({ __typeof(((struct globaldata *) 0)->gd_curthread) * __p; __asm volatile ("movl %%fs:%1,%0; addl %2,%0":"=r" (__p):"m"(*(struct globaldata *) (((size_t) (&((struct globaldata *) 0)->gd_prvspace)))), "i"(((size_t) (&((struct globaldata *) 0)->gd_curthread)))); __p; }); } __result; }))), (void *)0x00000004)) _mtx_unlock_sleep(((((&(p)->p_mtx)))), (((0))), ((0)), ((0))); } while (0); } while (0); wakeup(&p->p_siglist); return (0); } /* ****************************************************************** */ /* ****************************************************************** */ /* ****************************************************************** */ #if 0 void kthread_suspend_check(struct proc *p) { PROC_LOCK(p); while (SIGISMEMBER(p->p_siglist, SIGSTOP)) { wakeup(&p->p_siglist); msleep(&p->p_siglist, &p->p_mtx, PPAUSE, "ktsusp", 0); } PROC_UNLOCK(p); } #endif void kthread_suspend_check(struct proc * p) { do { do { if (!atomic_cmpset_ptr(&(((((&(p)->p_mtx)))))->mtx_lock, (void *)0x00000004, ((({ __typeof(((struct globaldata *) 0)->gd_curthread) __result; if (sizeof(__result) == 1) { u_char __b; __asm volatile ("movb %%fs:%1,%0":"=r" (__b):"m"(*(u_char *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __b; } else if (sizeof(__result) == 2) { u_short __w; __asm volatile ("movw %%fs:%1,%0":"=r" (__w):"m"(*(u_short *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __w; } else if (sizeof(__result) == 4) { u_int __i; __asm volatile ("movl %%fs:%1,%0":"=r" (__i):"m"(*(u_int *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __i; } else { __result = *({ __typeof(((struct globaldata *) 0)->gd_curthread) * __p; __asm volatile ("movl %%fs:%1,%0; addl %2,%0":"=r" (__p):"m"(*(struct globaldata *) (((size_t) (&((struct globaldata *) 0)->gd_prvspace)))), "i"(((size_t) (&((struct globaldata *) 0)->gd_curthread)))); __p; }); } __result; }))))) _mtx_lock_sleep(((((&(p)->p_mtx)))), (((0))), ((0)), ((0))); } while (0); do { if ((((((0))) & 0x00000002) == 0 && (((&(((&(p)->p_mtx)))->mtx_object))->lo_flags & 0x00040000) == 0)); } while (0); } while (0); while (((p->p_siglist).__bits[(((17) - 1) >> 5)] & (1 << (((17) - 1) & 31)))) { wakeup(&p->p_siglist); msleep(&p->p_siglist, &p->p_mtx, ((64) + 40), "ktsusp", 0); } do { do { if (((((((0)))) & 0x00000002) == 0 && (((&(((&(p)->p_mtx)))->mtx_object))->lo_flags & 0x00040000) == 0)); } while (0); do { if (!atomic_cmpset_ptr(&(((((&(p)->p_mtx)))))->mtx_lock, ((({ __typeof(((struct globaldata *) 0)->gd_curthread) __result; if (sizeof(__result) == 1) { u_char __b; __asm volatile ("movb %%fs:%1,%0":"=r" (__b):"m"(*(u_char *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __b; } else if (sizeof(__result) == 2) { u_short __w; __asm volatile ("movw %%fs:%1,%0":"=r" (__w):"m"(*(u_short *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __w; } else if (sizeof(__result) == 4) { u_int __i; __asm volatile ("movl %%fs:%1,%0":"=r" (__i):"m"(*(u_int *) (((size_t) (&((struct globaldata *) 0)->gd_curthread))))); __result = *(__typeof(((struct globaldata *) 0)->gd_curthread) *) & __i; } else { __result = *({ __typeof(((struct globaldata *) 0)->gd_curthread) * __p; __asm volatile ("movl %%fs:%1,%0; addl %2,%0":"=r" (__p):"m"(*(struct globaldata *) (((size_t) (&((struct globaldata *) 0)->gd_prvspace)))), "i"(((size_t) (&((struct globaldata *) 0)->gd_curthread)))); __p; }); } __result; }))), (void *)0x00000004)) _mtx_unlock_sleep(((((&(p)->p_mtx)))), (((0))), ((0)), ((0))); } while (0); } while (0); } /* ****************************************************************** */ /* ****************************************************************** */ /* ****************************************************************** */