5 #include "mem_layout.h"
7 #include "per_cpu_data.h"
17 extern Space *sigma0_task;
18 extern Task *boot_task;
19 extern Mem_space *sigma0_space;
20 extern Per_cpu<Timeout *> timeslice_timeout;
22 extern unsigned boot_stack;
24 /* the check macro is like assert(), but it evaluates its argument
25 even if NDEBUG is defined */
28 # define check(expression) ((void)(expression))
31 # define check(expression) assert(expression)
33 # define check(expression) \
34 ((void)((expression) ? 0 : \
35 (panic(__FILE__":%u: failed check `"#expression"'", \
41 // nil_thread and kernel_thread might have different values on a SMP system
42 extern Thread *nil_thread;
43 static Thread *&kernel_thread = nil_thread;
46 class Global_context_data
49 virtual ~Global_context_data() {}
56 //---------------------------------------------------------------------------
59 EXTENSION class Global_context_data
62 friend unsigned &__cpu_of(const void *);
66 //---------------------------------------------------------------------------
70 #include "processor.h"
74 Mem_space *sigma0_space;
79 inline NEEDS ["config.h"]
80 Context *context_of(const void *ptr)
82 return reinterpret_cast<Context *>
83 (reinterpret_cast<unsigned long>(ptr) & ~(Config::thread_block_size - 1));
86 inline NEEDS [context_of, "processor.h"]
88 { return context_of ((void *)Proc::stack_pointer()); }
95 void set_cpu_of(const void *ptr, unsigned cpu)
96 { (void)ptr; (void)cpu; }
99 unsigned cpu_of(const void *)
103 unsigned current_cpu()
109 inline NEEDS ["config.h"]
110 unsigned &__cpu_of(const void *ptr)
111 { return reinterpret_cast<Global_context_data*>(context_of(ptr))->_cpu; }
113 inline NEEDS [__cpu_of]
114 void set_cpu_of(const void *ptr, unsigned cpu)
115 { __cpu_of(ptr) = cpu; }
118 inline NEEDS [__cpu_of]
119 unsigned cpu_of(const void *ptr)
120 { return __cpu_of(ptr); }
122 inline NEEDS [current, cpu_of]
123 unsigned current_cpu()
124 { return cpu_of(current()); }