diff options
Diffstat (limited to 'libc/stdlib')
-rw-r--r-- | libc/stdlib/abort.c | 7 | ||||
-rw-r--r-- | libc/stdlib/atexit.c | 9 | ||||
-rw-r--r-- | libc/stdlib/malloc-simple/alloc.c | 9 | ||||
-rw-r--r-- | libc/stdlib/malloc-standard/malloc.h | 9 | ||||
-rw-r--r-- | libc/stdlib/malloc/heap.h | 10 | ||||
-rw-r--r-- | libc/stdlib/random.c | 6 | ||||
-rw-r--r-- | libc/stdlib/setenv.c | 9 |
7 files changed, 18 insertions, 41 deletions
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 <pthread.h> 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 <atomic.h> #ifdef __UCLIBC_HAS_THREADS__ -#include <pthread.h> +# include <pthread.h> 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 <pthread.h> +# include <pthread.h> 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 <pthread.h> +# include <pthread.h> 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 <limits.h> #include <stddef.h> #include <stdlib.h> + #ifdef __UCLIBC_HAS_THREADS__ -#include <pthread.h> +# include <pthread.h> /* 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 <unistd.h> #ifdef __UCLIBC_HAS_THREADS__ -#include <pthread.h> +# include <pthread.h> 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; |