]> git.buserror.net Git - polintos/scott/priv.git/blob - kernel/include/arch-x64/current.h
Initial checkin from Perforce.
[polintos/scott/priv.git] / kernel / include / arch-x64 / 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                 u64 ret;
12         
13                 asm("movq %%rsp, %0;"
14                     "andq $~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