summaryrefslogtreecommitdiff
path: root/libc/inet/rpc/create_xid.c
diff options
context:
space:
mode:
Diffstat (limited to 'libc/inet/rpc/create_xid.c')
-rw-r--r--libc/inet/rpc/create_xid.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/libc/inet/rpc/create_xid.c b/libc/inet/rpc/create_xid.c
index 3b90d7a48..18b9c6e35 100644
--- a/libc/inet/rpc/create_xid.c
+++ b/libc/inet/rpc/create_xid.c
@@ -31,12 +31,9 @@ libc_hidden_proto(gettimeofday)
/* The RPC code is not threadsafe, but new code should be threadsafe. */
-#ifdef __UCLIBC_HAS_THREADS__
-# include <pthread.h>
-static pthread_mutex_t createxid_lock = PTHREAD_MUTEX_INITIALIZER;
-#endif
-#define LOCK __pthread_mutex_lock(&createxid_lock)
-#define UNLOCK __pthread_mutex_unlock(&createxid_lock)
+#include <bits/uClibc_mutex.h>
+__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_MUTEX_INITIALIZER);
+
static int is_initialized;
static struct drand48_data __rpc_lrand48_data;
@@ -46,7 +43,7 @@ u_long _create_xid (void)
{
unsigned long res;
- LOCK;
+ __UCLIBC_MUTEX_LOCK(mylock);
if (!is_initialized)
{
@@ -59,7 +56,7 @@ u_long _create_xid (void)
lrand48_r (&__rpc_lrand48_data, &res);
- UNLOCK;
+ __UCLIBC_MUTEX_UNLOCK(mylock);
return res;
}