]> git.buserror.net Git - polintos/scott/priv.git/blob - kernel/include/arch-x86/current.h
Initial struct marshalling.
[polintos/scott/priv.git] / kernel / include / arch-x86 / current.h
1 // This file should only be included by include/kern/thread.h.
2
3 #ifndef _ARCH_CURRENT_H
4 #define _ARCH_CURRENT_H
5
6 namespace Arch {
7         static inline Threads::Thread *get_current_thread() __attribute__((const));
8         
9         static inline Threads::Thread *get_current_thread()
10         {
11                 u32 ret;
12         
13                 asm("movl %%esp, %0;"
14                     "andl $~0xfff, %0" :
15                     "=r" (ret));
16                     
17                 ret += ArchThread::size - Threads::thread_size;
18
19                 return reinterpret_cast<Threads::Thread *>(ret);
20         }
21 }
22
23 #endif