Unleashed v1.4
[unleashed.git] / usr / src / uts / intel / asm / cpuvar.h
blob8a2039db8188d24a07a36abcfff4c67580d7957e
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _ASM_CPUVAR_H
28 #define _ASM_CPUVAR_H
30 #include <sys/ccompile.h>
31 #include <sys/types.h>
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
38 struct cpu;
40 extern __GNU_INLINE struct cpu *
41 curcpup(void)
43 struct cpu *__value;
45 #if defined(__amd64)
46 __asm__ __volatile__(
47 "movq %%gs:0x10,%0" /* CPU_SELF */
48 : "=r" (__value));
49 #elif defined(__i386)
50 __asm__ __volatile__(
51 "movl %%gs:0xc,%0" /* CPU_SELF */
52 : "=r" (__value));
53 #else
54 #error "port me"
55 #endif
56 return (__value);
60 #ifdef __cplusplus
62 #endif
64 #endif /* _ASM_CPUVAR_H */