[kernel][thread] change the way get_current_thread is inlined
Previously, was relying on a regular definition with the arch_ops.h code overriding it with a static inline. This has been annoying for some years since it forces the declarations to be in order. Change it to simple declare an inline wrapper around an arch_ routine that does whatever it needs to do.
This commit is contained in:
@@ -231,11 +231,11 @@ static inline uint arch_curr_cpu_num(void) {
|
||||
|
||||
#if !ARM_ISA_ARMV7M
|
||||
/* use the cpu local thread context pointer to store current_thread */
|
||||
static inline struct thread *get_current_thread(void) {
|
||||
static inline struct thread *arch_get_current_thread(void) {
|
||||
return (struct thread *)arm_read_tpidrprw();
|
||||
}
|
||||
|
||||
static inline void set_current_thread(struct thread *t) {
|
||||
static inline void arch_set_current_thread(struct thread *t) {
|
||||
arm_write_tpidrprw((uint32_t)t);
|
||||
}
|
||||
#else // ARM_ISA_ARM7M
|
||||
@@ -243,11 +243,11 @@ static inline void set_current_thread(struct thread *t) {
|
||||
/* use a global pointer to store the current_thread */
|
||||
extern struct thread *_current_thread;
|
||||
|
||||
static inline struct thread *get_current_thread(void) {
|
||||
static inline struct thread *arch_get_current_thread(void) {
|
||||
return _current_thread;
|
||||
}
|
||||
|
||||
static inline void set_current_thread(struct thread *t) {
|
||||
static inline void arch_set_current_thread(struct thread *t) {
|
||||
_current_thread = t;
|
||||
}
|
||||
|
||||
@@ -372,11 +372,11 @@ static inline uint arch_curr_cpu_num(void) {
|
||||
/* use a global pointer to store the current_thread */
|
||||
extern struct thread *_current_thread;
|
||||
|
||||
static inline struct thread *get_current_thread(void) {
|
||||
static inline struct thread *arch_get_current_thread(void) {
|
||||
return _current_thread;
|
||||
}
|
||||
|
||||
static inline void set_current_thread(struct thread *t) {
|
||||
static inline void arch_set_current_thread(struct thread *t) {
|
||||
_current_thread = t;
|
||||
}
|
||||
|
||||
|
||||
@@ -213,11 +213,11 @@ static inline uint32_t arch_cycle_count(void) {
|
||||
}
|
||||
|
||||
/* use the cpu local thread context pointer to store current_thread */
|
||||
static inline struct thread *get_current_thread(void) {
|
||||
static inline struct thread *arch_get_current_thread(void) {
|
||||
return (struct thread *)ARM64_READ_SYSREG(tpidr_el1);
|
||||
}
|
||||
|
||||
static inline void set_current_thread(struct thread *t) {
|
||||
static inline void arch_set_current_thread(struct thread *t) {
|
||||
ARM64_WRITE_SYSREG(tpidr_el1, (uint64_t)t);
|
||||
}
|
||||
|
||||
|
||||
@@ -68,11 +68,11 @@ static inline int atomic_swap(volatile int *ptr, int val) {
|
||||
/* use a global pointer to store the current_thread */
|
||||
extern struct thread *_current_thread;
|
||||
|
||||
static inline struct thread *get_current_thread(void) {
|
||||
static inline struct thread *arch_get_current_thread(void) {
|
||||
return _current_thread;
|
||||
}
|
||||
|
||||
static inline void set_current_thread(struct thread *t) {
|
||||
static inline void arch_set_current_thread(struct thread *t) {
|
||||
_current_thread = t;
|
||||
}
|
||||
|
||||
|
||||
@@ -59,11 +59,11 @@ static inline int atomic_swap(volatile int *ptr, int val) {
|
||||
/* use a global pointer to store the current_thread */
|
||||
extern struct thread *_current_thread;
|
||||
|
||||
static inline struct thread *get_current_thread(void) {
|
||||
static inline struct thread *arch_get_current_thread(void) {
|
||||
return _current_thread;
|
||||
}
|
||||
|
||||
static inline void set_current_thread(struct thread *t) {
|
||||
static inline void arch_set_current_thread(struct thread *t) {
|
||||
_current_thread = t;
|
||||
}
|
||||
|
||||
|
||||
@@ -66,11 +66,11 @@ static inline int atomic_cmpxchg(volatile int *ptr, int oldval, int newval) {
|
||||
/* use a global pointer to store the current_thread */
|
||||
extern struct thread *_current_thread;
|
||||
|
||||
static inline struct thread *get_current_thread(void) {
|
||||
static inline struct thread *arch_get_current_thread(void) {
|
||||
return _current_thread;
|
||||
}
|
||||
|
||||
static inline void set_current_thread(struct thread *t) {
|
||||
static inline void arch_set_current_thread(struct thread *t) {
|
||||
_current_thread = t;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,11 +45,11 @@ static inline int atomic_swap(volatile int *ptr, int val) {
|
||||
// as pointing to thread local storage.
|
||||
register struct thread *__current_thread asm("tp");
|
||||
|
||||
static inline struct thread *get_current_thread(void) {
|
||||
static inline struct thread *arch_get_current_thread(void) {
|
||||
return __current_thread;
|
||||
}
|
||||
|
||||
static inline void set_current_thread(struct thread *t) {
|
||||
static inline void arch_set_current_thread(struct thread *t) {
|
||||
__current_thread = t;
|
||||
}
|
||||
|
||||
|
||||
@@ -87,11 +87,11 @@ static inline uint32_t arch_cycle_count(void) {
|
||||
/* use a global pointer to store the current_thread */
|
||||
extern struct thread *_current_thread;
|
||||
|
||||
static inline struct thread *get_current_thread(void) {
|
||||
static inline struct thread *arch_get_current_thread(void) {
|
||||
return _current_thread;
|
||||
}
|
||||
|
||||
static inline void set_current_thread(struct thread *t) {
|
||||
static inline void arch_set_current_thread(struct thread *t) {
|
||||
_current_thread = t;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <arch/defines.h>
|
||||
#include <arch/ops.h>
|
||||
#include <arch/thread.h>
|
||||
#include <arch/arch_ops.h>
|
||||
#include <kernel/spinlock.h>
|
||||
#include <kernel/wait.h>
|
||||
#include <lk/compiler.h>
|
||||
@@ -174,8 +175,13 @@ struct timer;
|
||||
enum handler_return thread_timer_tick(struct timer *, lk_time_t now, void *arg);
|
||||
|
||||
/* the current thread */
|
||||
thread_t *get_current_thread(void);
|
||||
void set_current_thread(thread_t *);
|
||||
static inline thread_t *get_current_thread(void) {
|
||||
return arch_get_current_thread();
|
||||
}
|
||||
|
||||
static inline void set_current_thread(thread_t *t) {
|
||||
arch_set_current_thread(t);
|
||||
}
|
||||
|
||||
/* scheduler lock */
|
||||
extern spin_lock_t thread_lock;
|
||||
|
||||
Reference in New Issue
Block a user