From d9af87c40b3a613a7a2a312d4529e566d0565a2c Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Fri, 16 Apr 2010 22:01:59 +0000 Subject: Use API call instead of accessing a global variable for receiving the current thread. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25657 a1c6a512-1295-4272-9138-f99709370657 --- firmware/kernel.c | 23 ++++++++++------------- firmware/thread.c | 2 +- uisimulator/sdl/thread-sdl.c | 2 +- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/firmware/kernel.c b/firmware/kernel.c index 29907f3082..27f3b0d08b 100644 --- a/firmware/kernel.c +++ b/firmware/kernel.c @@ -57,8 +57,6 @@ volatile long current_tick SHAREDDATA_ATTR = 0; /* List of tick tasks - final element always NULL for termination */ void (*tick_funcs[MAX_NUM_TICK_TASKS+1])(void); -extern struct core_entry cores[NUM_CORES]; - /* This array holds all queues that are initiated. It is used for broadcast. */ static struct { @@ -535,7 +533,7 @@ void queue_wait(struct event_queue *q, struct queue_event *ev) #ifdef HAVE_PRIORITY_SCHEDULING KERNEL_ASSERT(QUEUE_GET_THREAD(q) == NULL || - QUEUE_GET_THREAD(q) == cores[CURRENT_CORE].running, + QUEUE_GET_THREAD(q) == thread_id_entry(THREAD_ID_CURRENT), "queue_wait->wrong thread\n"); #endif @@ -547,7 +545,7 @@ void queue_wait(struct event_queue *q, struct queue_event *ev) if (q->read == q->write) { - struct thread_entry *current = cores[CURRENT_CORE].running; + struct thread_entry *current = thread_id_entry(THREAD_ID_CURRENT); do { @@ -582,7 +580,7 @@ void queue_wait_w_tmo(struct event_queue *q, struct queue_event *ev, int ticks) #ifdef HAVE_EXTENDED_MESSAGING_AND_NAME KERNEL_ASSERT(QUEUE_GET_THREAD(q) == NULL || - QUEUE_GET_THREAD(q) == cores[CURRENT_CORE].running, + QUEUE_GET_THREAD(q) == thread_id_entry(THREAD_ID_CURRENT), "queue_wait_w_tmo->wrong thread\n"); #endif @@ -594,7 +592,7 @@ void queue_wait_w_tmo(struct event_queue *q, struct queue_event *ev, int ticks) if (q->read == q->write && ticks > 0) { - struct thread_entry *current = cores[CURRENT_CORE].running; + struct thread_entry *current = thread_id_entry(THREAD_ID_CURRENT); IF_COP( current->obj_cl = &q->cl; ) current->bqp = &q->queue; @@ -669,7 +667,7 @@ intptr_t queue_send(struct event_queue *q, long id, intptr_t data) { struct queue_sender_list *send = q->send; struct thread_entry **spp = &send->senders[wr]; - struct thread_entry *current = cores[CURRENT_CORE].running; + struct thread_entry *current = thread_id_entry(THREAD_ID_CURRENT); if(UNLIKELY(*spp)) { @@ -878,8 +876,7 @@ void mutex_init(struct mutex *m) /* Gain ownership of a mutex object or block until it becomes free */ void mutex_lock(struct mutex *m) { - const unsigned int core = CURRENT_CORE; - struct thread_entry *current = cores[core].running; + struct thread_entry *current = thread_id_entry(THREAD_ID_CURRENT); if(current == MUTEX_GET_THREAD(m)) { @@ -918,10 +915,10 @@ void mutex_lock(struct mutex *m) void mutex_unlock(struct mutex *m) { /* unlocker not being the owner is an unlocking violation */ - KERNEL_ASSERT(MUTEX_GET_THREAD(m) == cores[CURRENT_CORE].running, + KERNEL_ASSERT(MUTEX_GET_THREAD(m) == thread_id_entry(THREAD_ID_CURRENT), "mutex_unlock->wrong thread (%s != %s)\n", MUTEX_GET_THREAD(m)->name, - cores[CURRENT_CORE].running->name); + thread_id_entry(THREAD_ID_CURRENT)->name); if(m->count > 0) { @@ -989,7 +986,7 @@ void semaphore_wait(struct semaphore *s) } /* too many waits - block until dequeued... */ - current = cores[CURRENT_CORE].running; + current = thread_id_entry(THREAD_ID_CURRENT); IF_COP( current->obj_cl = &s->cl; ) current->bqp = &s->queue; @@ -1051,7 +1048,7 @@ int wakeup_wait(struct wakeup *w, int timeout) if(LIKELY(w->signalled == 0 && timeout != TIMEOUT_NOBLOCK)) { - struct thread_entry * current = cores[CURRENT_CORE].running; + struct thread_entry * current = thread_id_entry(THREAD_ID_CURRENT); IF_COP( current->obj_cl = &w->cl; ) current->bqp = &w->queue; diff --git a/firmware/thread.c b/firmware/thread.c index 81ef42a6b0..7c2cfb23e9 100644 --- a/firmware/thread.c +++ b/firmware/thread.c @@ -119,7 +119,7 @@ /* Cast to the the machine pointer size, whose size could be < 4 or > 32 * (someday :). */ #define DEADBEEF ((uintptr_t)0xdeadbeefdeadbeefull) -struct core_entry cores[NUM_CORES] IBSS_ATTR; +static struct core_entry cores[NUM_CORES] IBSS_ATTR; struct thread_entry threads[MAXTHREADS] IBSS_ATTR; static const char main_thread_name[] = "main"; diff --git a/uisimulator/sdl/thread-sdl.c b/uisimulator/sdl/thread-sdl.c index ef7c86c3b4..e9b5fc205d 100644 --- a/uisimulator/sdl/thread-sdl.c +++ b/uisimulator/sdl/thread-sdl.c @@ -50,7 +50,7 @@ static char __name[32]; ({ fprintf(stderr, str); exit(-1); }) /* Thread/core entries as in rockbox core */ -struct core_entry cores[NUM_CORES]; +static struct core_entry cores[NUM_CORES]; struct thread_entry threads[MAXTHREADS]; /* Jump buffers for graceful exit - kernel threads don't stay neatly * in their start routines responding to messages so this is the only -- cgit v1.2.3