/* * Copyright (c) 2003,2004 The DragonFly Project. All rights reserved. * * This code is derived from software contributed to The DragonFly Project * by Matthew Dillon * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * 3. Neither the name of The DragonFly Project nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific, prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * Machine independant code should not directly include this file. * * $DragonFly: src/sys/i386/include/Attic/thread.h,v 1.7 2004/07/16 05:48:46 dillon Exp $ */ #ifndef _MACHINE_THREAD_H_ #define _MACHINE_THREAD_H_ union savefpu; struct md_thread { unsigned int mtd_cpl; union savefpu *mtd_savefpu; }; #ifdef _KERNEL #define td_cpl td_mach.mtd_cpl #define td_savefpu td_mach.mtd_savefpu /* * mycpu() retrieves the base of the current cpu's globaldata structure. * Note that it is *NOT* volatile, meaning that the value may be cached by * GCC. We have to force a dummy memory reference so gcc does not cache * the gd pointer across a procedure call (which might block and cause us * to wakeup on a different cpu). * * Also note that in TurtleBSD a thread can be preempted, but it cannot * move to another cpu preemptively so the 'gd' pointer is good until you * block. */ struct globaldata; extern int __mycpu__dummy; static __inline struct globaldata * _get_mycpu(void) { struct globaldata *gd; __asm ("movl %%fs:globaldata,%0" : "=r" (gd) : "m"(__mycpu__dummy)); return(gd); } #define mycpu _get_mycpu() /* * note: curthread is never NULL, but curproc can be. Also note that * in Turtle, the current pcb is stored in the thread structure. */ #define curthread mycpu->gd_curthread #define curproc curthread->td_proc #endif /* _KERNEL */ #endif /* !_MACHINE_THREAD_H_ */