summaryrefslogtreecommitdiff
path: root/lib/libc/stdlib
diff options
context:
space:
mode:
authorkleink <kleink@NetBSD.org>1999-02-06 16:01:22 +0000
committerkleink <kleink@NetBSD.org>1999-02-06 16:01:22 +0000
commit4ba3ee1071f1b9fbb308edcce6f78e87afc66cf3 (patch)
treee8357d36816183ce98339bfabd641825c0c45160 /lib/libc/stdlib
parentaae389c32348b6d81db9dfc3617ec56e12b285e8 (diff)
Serialize freelist access with a mutex.
Diffstat (limited to 'lib/libc/stdlib')
-rw-r--r--lib/libc/stdlib/strtod.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/libc/stdlib/strtod.c b/lib/libc/stdlib/strtod.c
index 63acbc0d30e..58234999f94 100644
--- a/lib/libc/stdlib/strtod.c
+++ b/lib/libc/stdlib/strtod.c
@@ -1,4 +1,4 @@
-/* $NetBSD: strtod.c,v 1.31 1999/02/06 02:05:01 simonb Exp $ */
+/* $NetBSD: strtod.c,v 1.32 1999/02/06 16:01:22 kleink Exp $ */
/****************************************************************
*
@@ -93,7 +93,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: strtod.c,v 1.31 1999/02/06 02:05:01 simonb Exp $");
+__RCSID("$NetBSD: strtod.c,v 1.32 1999/02/06 16:01:22 kleink Exp $");
#endif /* LIBC_SCCS and not lint */
#define Unsigned_Shifts
@@ -143,6 +143,7 @@ __RCSID("$NetBSD: strtod.c,v 1.31 1999/02/06 02:05:01 simonb Exp $");
#endif
#endif
#include "extern.h"
+#include "reentrant.h"
#ifdef MALLOC
#ifdef KR_headers
@@ -391,6 +392,10 @@ Bigint {
static Bigint *freelist[Kmax+1];
+#ifdef _REENT
+ static mutex_t freelist_mutex = MUTEX_INITIALIZER;
+#endif
+
static Bigint *
Balloc
#ifdef KR_headers
@@ -402,6 +407,7 @@ Balloc
int x;
Bigint *rv;
+ mutex_lock(&freelist_mutex);
if ((rv = freelist[k]) != NULL) {
freelist[k] = rv->next;
}
@@ -412,6 +418,7 @@ Balloc
rv->maxwds = x;
}
rv->sign = rv->wds = 0;
+ mutex_unlock(&freelist_mutex);
return rv;
}
@@ -424,8 +431,10 @@ Bfree
#endif
{
if (v) {
+ mutex_lock(&freelist_mutex);
v->next = freelist[v->k];
freelist[v->k] = v;
+ mutex_unlock(&freelist_mutex);
}
}