From aab07d0500d06e1de93280cb9900b24fd0c0875b Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 6 Dec 2005 01:29:10 +0000 Subject: macro out the thread funcs in libc if threading is disabled --- libc/stdlib/abort.c | 7 ++----- libc/stdlib/atexit.c | 9 +++------ libc/stdlib/malloc-simple/alloc.c | 9 +++------ libc/stdlib/malloc-standard/malloc.h | 9 +++------ libc/stdlib/malloc/heap.h | 10 ++-------- libc/stdlib/random.c | 6 ++---- libc/stdlib/setenv.c | 9 +++------ 7 files changed, 18 insertions(+), 41 deletions(-) (limited to 'libc/stdlib') diff --git a/libc/stdlib/abort.c b/libc/stdlib/abort.c index fb042544f..83a052abe 100644 --- a/libc/stdlib/abort.c +++ b/libc/stdlib/abort.c @@ -75,12 +75,9 @@ static int been_there_done_that = 0; #ifdef __UCLIBC_HAS_THREADS__ # include static pthread_mutex_t mylock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; -# define LOCK __pthread_mutex_lock(&mylock) -# define UNLOCK __pthread_mutex_unlock(&mylock) -#else -# define LOCK -# define UNLOCK #endif +#define LOCK __pthread_mutex_lock(&mylock) +#define UNLOCK __pthread_mutex_unlock(&mylock) extern int __raise (int __sig) __THROW attribute_hidden; diff --git a/libc/stdlib/atexit.c b/libc/stdlib/atexit.c index a01fb29e2..fcf85391a 100644 --- a/libc/stdlib/atexit.c +++ b/libc/stdlib/atexit.c @@ -45,14 +45,11 @@ #include #ifdef __UCLIBC_HAS_THREADS__ -#include +# include extern pthread_mutex_t mylock; -# define LOCK __pthread_mutex_lock(&mylock) -# define UNLOCK __pthread_mutex_unlock(&mylock); -#else -# define LOCK -# define UNLOCK #endif +#define LOCK __pthread_mutex_lock(&mylock) +#define UNLOCK __pthread_mutex_unlock(&mylock) typedef void (*aefuncp) (void); /* atexit function pointer */ diff --git a/libc/stdlib/malloc-simple/alloc.c b/libc/stdlib/malloc-simple/alloc.c index 382f8db44..d20768738 100644 --- a/libc/stdlib/malloc-simple/alloc.c +++ b/libc/stdlib/malloc-simple/alloc.c @@ -111,14 +111,11 @@ void free(void *ptr) #ifdef L_memalign #ifdef __UCLIBC_HAS_THREADS__ -#include +# include pthread_mutex_t __malloc_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; -# define LOCK __pthread_mutex_lock(&__malloc_lock) -# define UNLOCK __pthread_mutex_unlock(&__malloc_lock); -#else -# define LOCK -# define UNLOCK #endif +#define LOCK __pthread_mutex_lock(&__malloc_lock) +#define UNLOCK __pthread_mutex_unlock(&__malloc_lock) /* List of blocks allocated with memalign or valloc */ struct alignlist diff --git a/libc/stdlib/malloc-standard/malloc.h b/libc/stdlib/malloc-standard/malloc.h index dbac0c9d2..0e8aed363 100644 --- a/libc/stdlib/malloc-standard/malloc.h +++ b/libc/stdlib/malloc-standard/malloc.h @@ -26,14 +26,11 @@ #ifdef __UCLIBC_HAS_THREADS__ -#include +# include extern pthread_mutex_t __malloc_lock; -# define LOCK __pthread_mutex_lock(&__malloc_lock) -# define UNLOCK __pthread_mutex_unlock(&__malloc_lock); -#else -# define LOCK -# define UNLOCK #endif +#define LOCK __pthread_mutex_lock(&__malloc_lock) +#define UNLOCK __pthread_mutex_unlock(&__malloc_lock) diff --git a/libc/stdlib/malloc/heap.h b/libc/stdlib/malloc/heap.h index 0210d9098..ab1a73896 100644 --- a/libc/stdlib/malloc/heap.h +++ b/libc/stdlib/malloc/heap.h @@ -135,14 +135,8 @@ extern void __heap_dump (struct heap *heap, const char *str); extern void __heap_check (struct heap *heap, const char *str); -#ifdef HEAP_USE_LOCKING -# define __heap_lock(heap) __pthread_mutex_lock (&(heap)->lock) -# define __heap_unlock(heap) __pthread_mutex_unlock (&(heap)->lock) -#else /* !__UCLIBC_HAS_THREADS__ */ -/* Without threads, mutex operations are a nop. */ -# define __heap_lock(heap) (void)0 -# define __heap_unlock(heap) (void)0 -#endif /* HEAP_USE_LOCKING */ +#define __heap_lock(heap) __pthread_mutex_lock (&(heap)->lock) +#define __heap_unlock(heap) __pthread_mutex_unlock (&(heap)->lock) /* Delete the free-area FA from HEAP. */ diff --git a/libc/stdlib/random.c b/libc/stdlib/random.c index 28f3cd24d..d40420740 100644 --- a/libc/stdlib/random.c +++ b/libc/stdlib/random.c @@ -31,15 +31,13 @@ #include #include #include + #ifdef __UCLIBC_HAS_THREADS__ -#include +# include /* POSIX.1c requires that there is mutual exclusion for the `rand' and `srand' functions to prevent concurrent calls from modifying common data. */ static pthread_mutex_t lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; -#else -#define __pthread_mutex_lock(x) -#define __pthread_mutex_unlock(x) #endif /* An improved random number generation package. In addition to the standard diff --git a/libc/stdlib/setenv.c b/libc/stdlib/setenv.c index 8704717a7..07af88465 100644 --- a/libc/stdlib/setenv.c +++ b/libc/stdlib/setenv.c @@ -29,14 +29,11 @@ #include #ifdef __UCLIBC_HAS_THREADS__ -#include +# include static pthread_mutex_t mylock = PTHREAD_MUTEX_INITIALIZER; -# define LOCK __pthread_mutex_lock(&mylock) -# define UNLOCK __pthread_mutex_unlock(&mylock); -#else -# define LOCK -# define UNLOCK #endif +#define LOCK __pthread_mutex_lock(&mylock) +#define UNLOCK __pthread_mutex_unlock(&mylock) extern int __unsetenv (__const char *__name) attribute_hidden; -- cgit v1.2.3