kernel_structs: Add macro CPU_ID for getting current CPU ID
In case of a single core it resolves to 0. In many cases it reduces code size and execution time compared to reading id in runtime. Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
parent
aa34fa80aa
commit
49337973e0
@ -257,6 +257,8 @@ __attribute_const__ struct k_thread *z_smp_current_get(void);
|
||||
#define _current _kernel.cpus[0].current
|
||||
#endif
|
||||
|
||||
#define CPU_ID ((CONFIG_MP_MAX_NUM_CPUS == 1) ? 0 : _current_cpu->id)
|
||||
|
||||
/* This is always invoked from a context where preemption is disabled */
|
||||
#define z_current_thread_set(thread) ({ _current_cpu->current = (thread); })
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user