summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2005-12-06 01:29:10 +0000
committerMike Frysinger <vapier@gentoo.org>2005-12-06 01:29:10 +0000
commitaab07d0500d06e1de93280cb9900b24fd0c0875b (patch)
tree7122ec94b0498c150b69401a13f06aaea803cf50
parent680f8428162687caae571090e008b42d18f2bb5a (diff)
macro out the thread funcs in libc if threading is disabled
-rw-r--r--include/libc-internal.h8
-rw-r--r--libc/inet/getnetent.c9
-rw-r--r--libc/inet/getproto.c10
-rw-r--r--libc/inet/getservice.c10
-rw-r--r--libc/inet/resolv.c20
-rw-r--r--libc/inet/rpc/create_xid.c9
-rw-r--r--libc/inet/rpc/getrpcent.c7
-rw-r--r--libc/misc/dirent/closedir.c4
-rw-r--r--libc/misc/dirent/opendir.c2
-rw-r--r--libc/misc/dirent/readdir.c4
-rw-r--r--libc/misc/dirent/readdir64.c4
-rw-r--r--libc/misc/dirent/readdir64_r.c4
-rw-r--r--libc/misc/dirent/readdir_r.c8
-rw-r--r--libc/misc/dirent/rewinddir.c4
-rw-r--r--libc/misc/dirent/seekdir.c5
-rw-r--r--libc/misc/mntent/mntent.c9
-rw-r--r--libc/misc/syslog/syslog.c9
-rw-r--r--libc/misc/time/time.c13
-rw-r--r--libc/misc/utmp/utent.c9
-rw-r--r--libc/pwd_grp/lckpwdf.c11
-rw-r--r--libc/pwd_grp/pwd_grp.c9
-rw-r--r--libc/stdio/popen.c11
-rw-r--r--libc/stdlib/abort.c7
-rw-r--r--libc/stdlib/atexit.c9
-rw-r--r--libc/stdlib/malloc-simple/alloc.c9
-rw-r--r--libc/stdlib/malloc-standard/malloc.h9
-rw-r--r--libc/stdlib/malloc/heap.h10
-rw-r--r--libc/stdlib/random.c6
-rw-r--r--libc/stdlib/setenv.c9
29 files changed, 73 insertions, 165 deletions
diff --git a/include/libc-internal.h b/include/libc-internal.h
index 632b53ac5..469f5eba5 100644
--- a/include/libc-internal.h
+++ b/include/libc-internal.h
@@ -174,6 +174,14 @@ extern int __gettimeofday(struct timeval *__restrict __tv, *__restrict __timezon
# define gettimeofday __gettimeofday
# endif
+/* #include <pthread.h> */
+# ifndef __UCLIBC_HAS_THREADS__
+# define __pthread_mutex_init(mutex, mutexattr) ((void)0)
+# define __pthread_mutex_lock(mutex) ((void)0)
+# define __pthread_mutex_trylock(mutex) ((void)0)
+# define __pthread_mutex_unlock(mutex) ((void)0)
+# endif
+
# endif /* IS_IN_libc */
#endif /* __ASSEMBLER__ */
diff --git a/libc/inet/getnetent.c b/libc/inet/getnetent.c
index fc21dfa03..476fa6b0e 100644
--- a/libc/inet/getnetent.c
+++ b/libc/inet/getnetent.c
@@ -24,14 +24,11 @@
#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)
diff --git a/libc/inet/getproto.c b/libc/inet/getproto.c
index e7221f3a2..a5ebcb3e9 100644
--- a/libc/inet/getproto.c
+++ b/libc/inet/getproto.c
@@ -64,15 +64,13 @@
#include <string.h>
#include <errno.h>
+
#ifdef __UCLIBC_HAS_THREADS__
-#include <pthread.h>
+# 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)
diff --git a/libc/inet/getservice.c b/libc/inet/getservice.c
index e4422246b..4040dc9b6 100644
--- a/libc/inet/getservice.c
+++ b/libc/inet/getservice.c
@@ -67,16 +67,12 @@
#include <errno.h>
-
#ifdef __UCLIBC_HAS_THREADS__
-#include <pthread.h>
+# 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)
diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c
index ba0fd4674..a6dc549b8 100644
--- a/libc/inet/resolv.c
+++ b/libc/inet/resolv.c
@@ -186,15 +186,13 @@ extern char * __nameserver[MAX_SERVERS];
extern int __searchdomains;
extern char * __searchdomain[MAX_SEARCH];
+
#ifdef __UCLIBC_HAS_THREADS__
-#include <pthread.h>
+# include <pthread.h>
extern pthread_mutex_t __resolv_lock;
-# define BIGLOCK __pthread_mutex_lock(&__resolv_lock)
-# define BIGUNLOCK __pthread_mutex_unlock(&__resolv_lock);
-#else
-# define BIGLOCK
-# define BIGUNLOCK
#endif
+#define BIGLOCK __pthread_mutex_lock(&__resolv_lock)
+#define BIGUNLOCK __pthread_mutex_unlock(&__resolv_lock)
@@ -659,15 +657,12 @@ int __form_query(int id, const char *name, int type, unsigned char *packet,
#endif
#if defined(L_dnslookup) || defined(L_gethostent)
-
#ifdef __UCLIBC_HAS_THREADS__
+# 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)
#endif
#ifdef L_dnslookup
@@ -981,6 +976,7 @@ char * __nameserver[MAX_SERVERS];
int __searchdomains;
char * __searchdomain[MAX_SEARCH];
#ifdef __UCLIBC_HAS_THREADS__
+# include <pthread.h>
pthread_mutex_t __resolv_lock = PTHREAD_MUTEX_INITIALIZER;
#endif
diff --git a/libc/inet/rpc/create_xid.c b/libc/inet/rpc/create_xid.c
index 3ef1850dd..3dbf7af61 100644
--- a/libc/inet/rpc/create_xid.c
+++ b/libc/inet/rpc/create_xid.c
@@ -31,14 +31,11 @@
/* The RPC code is not threadsafe, but new code should be threadsafe. */
#ifdef __UCLIBC_HAS_THREADS__
-#include <pthread.h>
+# include <pthread.h>
static pthread_mutex_t createxid_lock = PTHREAD_MUTEX_INITIALIZER;
-# define LOCK __pthread_mutex_lock(&createxid_lock)
-# define UNLOCK __pthread_mutex_unlock(&createxid_lock);
-#else
-# define LOCK
-# define UNLOCK
#endif
+#define LOCK __pthread_mutex_lock(&createxid_lock)
+#define UNLOCK __pthread_mutex_unlock(&createxid_lock)
static int is_initialized;
static struct drand48_data __rpc_lrand48_data;
diff --git a/libc/inet/rpc/getrpcent.c b/libc/inet/rpc/getrpcent.c
index c261dfb3b..47a0b0c13 100644
--- a/libc/inet/rpc/getrpcent.c
+++ b/libc/inet/rpc/getrpcent.c
@@ -257,12 +257,9 @@ static struct rpcent *interpret(register struct rpcdata *d)
#if defined(__UCLIBC_HAS_THREADS__)
# include <pthread.h>
static pthread_mutex_t rpcdata_lock = PTHREAD_MUTEX_INITIALIZER;
-# define LOCK __pthread_mutex_lock(&rpcdata_lock)
-# define UNLOCK __pthread_mutex_unlock(&rpcdata_lock);
-#else
-# define LOCK
-# define UNLOCK
#endif
+#define LOCK __pthread_mutex_lock(&rpcdata_lock)
+#define UNLOCK __pthread_mutex_unlock(&rpcdata_lock)
static int __copy_rpcent(struct rpcent *r, struct rpcent *result_buf, char *buffer,
size_t buflen, struct rpcent **result)
diff --git a/libc/misc/dirent/closedir.c b/libc/misc/dirent/closedir.c
index 57600ab69..25c424566 100644
--- a/libc/misc/dirent/closedir.c
+++ b/libc/misc/dirent/closedir.c
@@ -19,14 +19,10 @@ int closedir(DIR * dir)
__set_errno(EBADF);
return -1;
}
-#ifdef __UCLIBC_HAS_THREADS__
__pthread_mutex_lock(&(dir->dd_lock));
-#endif
fd = dir->dd_fd;
dir->dd_fd = -1;
-#ifdef __UCLIBC_HAS_THREADS__
__pthread_mutex_unlock(&(dir->dd_lock));
-#endif
free(dir->dd_buf);
free(dir);
return __close(fd);
diff --git a/libc/misc/dirent/opendir.c b/libc/misc/dirent/opendir.c
index 9f5f75e3f..fd14213a5 100644
--- a/libc/misc/dirent/opendir.c
+++ b/libc/misc/dirent/opendir.c
@@ -51,8 +51,6 @@ DIR *opendir(const char *name)
return NULL;
}
ptr->dd_buf = buf;
-#ifdef __UCLIBC_HAS_THREADS__
__pthread_mutex_init(&(ptr->dd_lock), NULL);
-#endif
return ptr;
}
diff --git a/libc/misc/dirent/readdir.c b/libc/misc/dirent/readdir.c
index 1f196e1e7..68a465fc8 100644
--- a/libc/misc/dirent/readdir.c
+++ b/libc/misc/dirent/readdir.c
@@ -16,9 +16,7 @@ struct dirent *readdir(DIR * dir)
return NULL;
}
-#ifdef __UCLIBC_HAS_THREADS__
__pthread_mutex_lock(&(dir->dd_lock));
-#endif
do {
if (dir->dd_size <= dir->dd_nextloc) {
@@ -44,8 +42,6 @@ struct dirent *readdir(DIR * dir)
} while (de->d_ino == 0);
all_done:
-#ifdef __UCLIBC_HAS_THREADS__
__pthread_mutex_unlock(&(dir->dd_lock));
-#endif
return de;
}
diff --git a/libc/misc/dirent/readdir64.c b/libc/misc/dirent/readdir64.c
index f798c6fbb..8d22a314e 100644
--- a/libc/misc/dirent/readdir64.c
+++ b/libc/misc/dirent/readdir64.c
@@ -31,9 +31,7 @@ struct dirent64 *readdir64(DIR * dir)
return NULL;
}
-#ifdef __UCLIBC_HAS_THREADS__
__pthread_mutex_lock(&(dir->dd_lock));
-#endif
do {
if (dir->dd_size <= dir->dd_nextloc) {
@@ -59,9 +57,7 @@ struct dirent64 *readdir64(DIR * dir)
} while (de->d_ino == 0);
all_done:
-#ifdef __UCLIBC_HAS_THREADS__
__pthread_mutex_unlock(&(dir->dd_lock));
-#endif
return de;
}
diff --git a/libc/misc/dirent/readdir64_r.c b/libc/misc/dirent/readdir64_r.c
index 1daae5116..7daf890dd 100644
--- a/libc/misc/dirent/readdir64_r.c
+++ b/libc/misc/dirent/readdir64_r.c
@@ -32,9 +32,7 @@ int readdir64_r(DIR *dir, struct dirent64 *entry, struct dirent64 **result)
}
de = NULL;
-#ifdef __UCLIBC_HAS_THREADS__
__pthread_mutex_lock(&(dir->dd_lock));
-#endif
do {
if (dir->dd_size <= dir->dd_nextloc) {
@@ -68,9 +66,7 @@ int readdir64_r(DIR *dir, struct dirent64 *entry, struct dirent64 **result)
all_done:
-#ifdef __UCLIBC_HAS_THREADS__
__pthread_mutex_unlock(&(dir->dd_lock));
-#endif
return((de != NULL)? 0 : ret);
}
#endif /* __UCLIBC_HAS_LFS__ */
diff --git a/libc/misc/dirent/readdir_r.c b/libc/misc/dirent/readdir_r.c
index 1c8eeadce..25cb80b63 100644
--- a/libc/misc/dirent/readdir_r.c
+++ b/libc/misc/dirent/readdir_r.c
@@ -5,7 +5,6 @@
#include <dirent.h>
#include "dirstream.h"
-
int readdir_r(DIR *dir, struct dirent *entry, struct dirent **result)
{
int ret;
@@ -18,9 +17,7 @@ int readdir_r(DIR *dir, struct dirent *entry, struct dirent **result)
}
de = NULL;
-#ifdef __UCLIBC_HAS_THREADS__
__pthread_mutex_lock(&(dir->dd_lock));
-#endif
do {
if (dir->dd_size <= dir->dd_nextloc) {
@@ -54,8 +51,7 @@ int readdir_r(DIR *dir, struct dirent *entry, struct dirent **result)
all_done:
-#ifdef __UCLIBC_HAS_THREADS__
__pthread_mutex_unlock(&(dir->dd_lock));
-#endif
- return((de != NULL)? 0 : ret);
+
+ return((de != NULL)? 0 : ret);
}
diff --git a/libc/misc/dirent/rewinddir.c b/libc/misc/dirent/rewinddir.c
index 60ef71da7..f41ecc389 100644
--- a/libc/misc/dirent/rewinddir.c
+++ b/libc/misc/dirent/rewinddir.c
@@ -11,12 +11,8 @@ void rewinddir(DIR * dir)
__set_errno(EBADF);
return;
}
-#ifdef __UCLIBC_HAS_THREADS__
__pthread_mutex_lock(&(dir->dd_lock));
-#endif
lseek(dir->dd_fd, 0, SEEK_SET);
dir->dd_nextoff = dir->dd_nextloc = dir->dd_size = 0;
-#ifdef __UCLIBC_HAS_THREADS__
__pthread_mutex_unlock(&(dir->dd_lock));
-#endif
}
diff --git a/libc/misc/dirent/seekdir.c b/libc/misc/dirent/seekdir.c
index 139f1e1e5..507131097 100644
--- a/libc/misc/dirent/seekdir.c
+++ b/libc/misc/dirent/seekdir.c
@@ -3,19 +3,14 @@
#include <unistd.h>
#include "dirstream.h"
-
void seekdir(DIR * dir, long int offset)
{
if (!dir) {
__set_errno(EBADF);
return;
}
-#ifdef __UCLIBC_HAS_THREADS__
__pthread_mutex_lock(&(dir->dd_lock));
-#endif
dir->dd_nextoff = lseek(dir->dd_fd, offset, SEEK_SET);
dir->dd_size = dir->dd_nextloc = 0;
-#ifdef __UCLIBC_HAS_THREADS__
__pthread_mutex_unlock(&(dir->dd_lock));
-#endif
}
diff --git a/libc/misc/mntent/mntent.c b/libc/misc/mntent/mntent.c
index 1af5a6b67..35767280e 100644
--- a/libc/misc/mntent/mntent.c
+++ b/libc/misc/mntent/mntent.c
@@ -7,14 +7,11 @@
#include <mntent.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)
/* Reentrant version of getmntent. */
struct mntent *getmntent_r (FILE *filep,
diff --git a/libc/misc/syslog/syslog.c b/libc/misc/syslog/syslog.c
index e05297770..5605aecf1 100644
--- a/libc/misc/syslog/syslog.c
+++ b/libc/misc/syslog/syslog.c
@@ -86,14 +86,11 @@
#ifdef __UCLIBC_HAS_THREADS__
-#include <pthread.h>
+# 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)
static int LogFile = -1; /* fd for log */
diff --git a/libc/misc/time/time.c b/libc/misc/time/time.c
index d7cf1806e..65b925cf6 100644
--- a/libc/misc/time/time.c
+++ b/libc/misc/time/time.c
@@ -199,21 +199,12 @@ typedef struct {
} rule_struct;
#ifdef __UCLIBC_HAS_THREADS__
-
-#include <pthread.h>
-
+# include <pthread.h>
extern pthread_mutex_t _time_tzlock;
-
+#endif
#define TZLOCK __pthread_mutex_lock(&_time_tzlock)
#define TZUNLOCK __pthread_mutex_unlock(&_time_tzlock)
-#else
-
-#define TZLOCK ((void) 0)
-#define TZUNLOCK ((void) 0)
-
-#endif
-
extern rule_struct _time_tzinfo[2];
extern struct tm *_time_t2tm(const time_t *__restrict timer,
diff --git a/libc/misc/utmp/utent.c b/libc/misc/utmp/utent.c
index c3d9ab620..e03d4528f 100644
--- a/libc/misc/utmp/utent.c
+++ b/libc/misc/utmp/utent.c
@@ -23,14 +23,11 @@
#ifdef __UCLIBC_HAS_THREADS__
-#include <pthread.h>
+# include <pthread.h>
static pthread_mutex_t utmplock = PTHREAD_MUTEX_INITIALIZER;
-# define LOCK __pthread_mutex_lock(&utmplock)
-# define UNLOCK __pthread_mutex_unlock(&utmplock)
-#else
-# define LOCK
-# define UNLOCK
#endif
+#define LOCK __pthread_mutex_lock(&utmplock)
+#define UNLOCK __pthread_mutex_unlock(&utmplock)
diff --git a/libc/pwd_grp/lckpwdf.c b/libc/pwd_grp/lckpwdf.c
index 9c0b75297..2b3fa7596 100644
--- a/libc/pwd_grp/lckpwdf.c
+++ b/libc/pwd_grp/lckpwdf.c
@@ -31,14 +31,11 @@
#include <paths.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
+#endif
+#define LOCK __pthread_mutex_lock(&mylock)
+#define UNLOCK __pthread_mutex_unlock(&mylock)
/* How long to wait for getting the lock before returning with an
error. */
diff --git a/libc/pwd_grp/pwd_grp.c b/libc/pwd_grp/pwd_grp.c
index 3baa0ad33..601568599 100644
--- a/libc/pwd_grp/pwd_grp.c
+++ b/libc/pwd_grp/pwd_grp.c
@@ -402,15 +402,12 @@ int getpw(uid_t uid, char *buf)
#endif
/**********************************************************************/
#if defined(L_getpwent_r) || defined(L_getgrent_r) || defined(L_getspent_r)
-
#ifdef __UCLIBC_HAS_THREADS__
+# 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 ((void) 0)
-# define UNLOCK ((void) 0)
#endif
+#define LOCK __pthread_mutex_lock(&mylock)
+#define UNLOCK __pthread_mutex_unlock(&mylock)
#endif
#ifdef L_getpwent_r
diff --git a/libc/stdio/popen.c b/libc/stdio/popen.c
index 354227593..2e9985a39 100644
--- a/libc/stdio/popen.c
+++ b/libc/stdio/popen.c
@@ -32,14 +32,11 @@
#endif
#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 ((void) 0)
-# define UNLOCK ((void) 0)
-#endif
+#endif
+#define LOCK __pthread_mutex_lock(&mylock)
+#define UNLOCK __pthread_mutex_unlock(&mylock)
#ifndef VFORK_LOCK
# define VFORK_LOCK LOCK
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;