* kern/lock.h (decl_simple_lock_data): Define macro. (simple_unlock): Define so that lock is assigned to itself and add a comment saying why this was done. (simple_lock_try): Define so that lock data is cast to a boolean with the value TRUE and assigned to itself. Add a comment saying why this was done. * kern/sched_prim.c [!MACH_SLOCKS] (lock): Declare and initialize.
--- kern/lock.h | 20 +++++++++++++++++--- kern/sched_prim.c | 12 ++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/kern/lock.h b/kern/lock.h index 4f38ea3..f02ae8b 100644 --- a/kern/lock.h +++ b/kern/lock.h @@ -91,10 +91,13 @@ extern void check_simple_locks(void); #endif /* NCPUS > 1 */ #else /* MACH_SLOCKS */ + +#define decl_simple_lock_data(class,name) \ +class simple_lock_t name; + /* * Do not allocate storage for locks if not needed. */ -#define decl_simple_lock_data(class,name) #define simple_lock_addr(lock) ((simple_lock_t)0) /* @@ -102,8 +105,19 @@ extern void check_simple_locks(void); */ #define simple_lock_init(l) #define simple_lock(l) -#define simple_unlock(l) -#define simple_lock_try(l) (TRUE) /* always succeeds */ + +/* Quiet GCC warnings about + * set but unused variables during + * simple_unlock(). + */ +#define simple_unlock(l) (*l = *l) + +/* Quiet GCC warnings about + * set but unused variables during + * simple_lock_try(). Always succeeds. + */ +#define simple_lock_try(l) (*(boolean_t *)l->lock_data = *(boolean_t *)l->lock_data = TRUE) + #define simple_lock_taken(l) (1) /* always succeeds */ #define check_simple_locks() #define simple_lock_pause() diff --git a/kern/sched_prim.c b/kern/sched_prim.c index 2946701..f91c5c9 100644 --- a/kern/sched_prim.c +++ b/kern/sched_prim.c @@ -238,6 +238,8 @@ void assert_wait( thread_t thread; #if MACH_SLOCKS simple_lock_t lock; +#else /* MACH_SLOCKS */ + decl_simple_lock_data( , lock); #endif /* MACH_SLOCKS */ spl_t s; @@ -252,8 +254,10 @@ void assert_wait( q = &wait_queue[index]; #if MACH_SLOCKS lock = &wait_lock[index]; +#else /* MACH_SLOCKS */ + lock = wait_lock[index]; #endif /* MACH_SLOCKS */ simple_lock(lock); thread_lock(thread); enqueue_tail(q, (queue_entry_t) thread); @@ -296,6 +300,8 @@ void clear_wait( queue_t q; #if MACH_SLOCKS simple_lock_t lock; +#else /* MACH_SLOCKS */ + decl_simple_lock_data( , lock); #endif /* MACH_SLOCKS */ event_t event; spl_t s; @@ -318,6 +324,8 @@ void clear_wait( q = &wait_queue[index]; #if MACH_SLOCKS lock = &wait_lock[index]; +#else /* MACH_SLOCKS */ + lock = wait_lock[index]; #endif /* MACH_SLOCKS */ simple_lock(lock); /* @@ -399,6 +407,8 @@ void thread_wakeup_prim( thread_t thread, next_th; #if MACH_SLOCKS simple_lock_t lock; +#else /* MACH_SLOCKS */ + decl_simple_lock_data( , lock); #endif /* MACH_SLOCKS */ spl_t s; int state; @@ -408,6 +418,8 @@ void thread_wakeup_prim( s = splsched(); #if MACH_SLOCKS lock = &wait_lock[index]; +#else /* MACH_SLOCKS */ + lock = wait_lock[index]; #endif /* MACH_SLOCKS */ simple_lock(lock); thread = (thread_t) queue_first(q); -- 1.8.1.4