From aacd88fabff8a96450162b564a75985ebfd8364a Mon Sep 17 00:00:00 2001 From: kugel Date: Sat, 19 Feb 2011 00:09:08 +0000 Subject: [PATCH] Cleanup preprocessor around corelock usage and move its definition outside #ifdef ASSEMBLER_THREADS git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29330 a1c6a512-1295-4272-9138-f99709370657 --- firmware/export/thread.h | 39 ++++++++++++++++++++------------------- firmware/kernel.c | 4 +++- firmware/thread.c | 4 ++-- 3 files changed, 25 insertions(+), 22 deletions(-) diff --git a/firmware/export/thread.h b/firmware/export/thread.h index ba49951af..179979a98 100644 --- a/firmware/export/thread.h +++ b/firmware/export/thread.h @@ -125,22 +125,6 @@ struct regs uint32_t start; /* 40 - Thread start address, or NULL when started */ }; -#ifdef CPU_PP -#ifdef HAVE_CORELOCK_OBJECT -/* No reliable atomic instruction available - use Peterson's algorithm */ -struct corelock -{ - volatile unsigned char myl[NUM_CORES]; - volatile unsigned char turn; -} __attribute__((packed)); - -/* Too big to inline everywhere */ -void corelock_init(struct corelock *cl); -void corelock_lock(struct corelock *cl); -int corelock_try_lock(struct corelock *cl); -void corelock_unlock(struct corelock *cl); -#endif /* HAVE_CORELOCK_OBJECT */ -#endif /* CPU_PP */ #elif defined(CPU_MIPS) struct regs { @@ -171,6 +155,23 @@ struct regs #endif #endif /* PLATFORM_NATIVE */ +#ifdef CPU_PP +#ifdef HAVE_CORELOCK_OBJECT +/* No reliable atomic instruction available - use Peterson's algorithm */ +struct corelock +{ + volatile unsigned char myl[NUM_CORES]; + volatile unsigned char turn; +} __attribute__((packed)); + +/* Too big to inline everywhere */ +void corelock_init(struct corelock *cl); +void corelock_lock(struct corelock *cl); +int corelock_try_lock(struct corelock *cl); +void corelock_unlock(struct corelock *cl); +#endif /* HAVE_CORELOCK_OBJECT */ +#endif /* CPU_PP */ + /* NOTE: The use of the word "queue" may also refer to a linked list of threads being maintained that are normally dealt with in FIFO order and not necessarily kernel event_queue */ @@ -266,7 +267,7 @@ struct thread_entry object where thread is blocked - used for implicit unblock and explicit wake states: STATE_BLOCKED/STATE_BLOCKED_W_TMO */ -#if NUM_CORES > 1 +#ifdef HAVE_CORELOCK_OBJECT struct corelock *obj_cl; /* Object corelock where thead is blocked - states: STATE_BLOCKED/STATE_BLOCKED_W_TMO */ struct corelock waiter_cl; /* Corelock for thread_wait */ @@ -323,7 +324,7 @@ struct thread_entry /* Specify current thread in a function taking an ID. */ #define THREAD_ID_CURRENT ((unsigned int)-1) -#if NUM_CORES > 1 +#ifdef HAVE_CORELOCK_OBJECT /* Operations to be performed just before stopping a thread and starting a new one if specified before calling switch_thread */ enum @@ -356,7 +357,7 @@ struct core_entry threads */ #endif long next_tmo_check; /* soonest time to check tmo threads */ -#if NUM_CORES > 1 +#ifdef HAVE_CORELOCK_OBJECT struct thread_blk_ops blk_ops; /* operations to perform when blocking a thread */ struct corelock rtr_cl; /* Lock for rtr list */ diff --git a/firmware/kernel.c b/firmware/kernel.c index ee4257405..588bbd2a7 100644 --- a/firmware/kernel.c +++ b/firmware/kernel.c @@ -68,7 +68,9 @@ void (*tick_funcs[MAX_NUM_TICK_TASKS+1])(void); static struct { struct event_queue *queues[MAX_NUM_QUEUES+1]; - IF_COP( struct corelock cl; ) +#ifdef HAVE_CORELOCK_OBJECT + struct corelock cl; +#endif } all_queues SHAREDBSS_ATTR; /**************************************************************************** diff --git a/firmware/thread.c b/firmware/thread.c index bfbaf462a..ea7315085 100644 --- a/firmware/thread.c +++ b/firmware/thread.c @@ -967,7 +967,7 @@ void check_tmo_threads(void) * life again. */ if (state == STATE_BLOCKED_W_TMO) { -#if NUM_CORES > 1 +#ifdef HAVE_CORELOCK_OBJECT /* Lock the waiting thread's kernel object */ struct corelock *ocl = curr->obj_cl; @@ -1782,7 +1782,7 @@ void thread_exit(void) */ void remove_thread(unsigned int thread_id) { -#if NUM_CORES > 1 +#ifdef HAVE_CORELOCK_OBJECT /* core is not constant here because of core switching */ unsigned int core = CURRENT_CORE; unsigned int old_core = NUM_CORES; -- 2.11.4.GIT