summaryrefslogtreecommitdiff
path: root/libc/stdlib
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2002-06-10 21:44:45 +0000
committerEric Andersen <andersen@codepoet.org>2002-06-10 21:44:45 +0000
commit417197ca7ced6f14701137a989dfe0e88edeb6e9 (patch)
tree47e110110c162cf7040b87781200ad7e6c9c8c29 /libc/stdlib
parent257573b929dc1096a46f8c2d40781477b123f23f (diff)
Kill the libc-lock headers, which we do not use and which are
not correct for uClibc. Fix setenv locking to behave itself. -Erik
Diffstat (limited to 'libc/stdlib')
-rw-r--r--libc/stdlib/setenv.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/libc/stdlib/setenv.c b/libc/stdlib/setenv.c
index 7f6a1501c..02959ab95 100644
--- a/libc/stdlib/setenv.c
+++ b/libc/stdlib/setenv.c
@@ -26,16 +26,17 @@
#include <unistd.h>
#ifdef __UCLIBC_HAS_THREADS__
-/* This lock protects against simultaneous modifications of `environ'. */
-# include <bits/libc-lock.h>
-__libc_lock_define_initialized (static, envlock)
-# define LOCK __libc_lock_lock (envlock)
-# define UNLOCK __libc_lock_unlock (envlock)
+/* protects against simultaneous modifications of `environ'. */
+#include <pthread.h>
+static pthread_mutex_t envlock = PTHREAD_MUTEX_INITIALIZER;
+# define LOCK pthread_mutex_lock(&envlock)
+# define UNLOCK pthread_mutex_unlock(&envlock);
#else
# define LOCK
# define UNLOCK
#endif
+
/* If this variable is not a null pointer we allocated the current
environment. */
static char **last_environ;
@@ -55,7 +56,7 @@ int __add_to_environ (const char *name, const char *value,
const size_t namelen = strlen (name);
const size_t vallen = value != NULL ? strlen (value) + 1 : 0;
- LOCK;
+ pthread_mutex_lock(&envlock);
/* We have to get the pointer now that we have the lock and not earlier
since another thread might have created a new environment. */