summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorguenther <>2016-04-05 04:29:21 +0000
committerguenther <>2016-04-05 04:29:21 +0000
commit8d615e14801649271e105df0f420c20902909031 (patch)
treee8d5ce0d5bf2356480a7a736afad190933d9930c /src
parenta2aa52ba00eccc94337e2f8d54df755b70b64bd6 (diff)
downloadopenbsd-8d615e14801649271e105df0f420c20902909031.tar.gz
openbsd-8d615e14801649271e105df0f420c20902909031.tar.bz2
openbsd-8d615e14801649271e105df0f420c20902909031.zip
Prefer _MUTEX_*LOCK over _THREAD_PRIVATE_MUTEX_*LOCK() when thread-specific
data isn't necessary. ok mpi@, ok&tweak natano@
Diffstat (limited to 'src')
-rw-r--r--src/lib/libc/net/res_random.c8
-rw-r--r--src/lib/libc/stdlib/random.c8
2 files changed, 8 insertions, 8 deletions
diff --git a/src/lib/libc/net/res_random.c b/src/lib/libc/net/res_random.c
index 72b9c41a2a..763e420bb8 100644
--- a/src/lib/libc/net/res_random.c
+++ b/src/lib/libc/net/res_random.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: res_random.c,v 1.23 2015/10/05 02:57:16 guenther Exp $ */ 1/* $OpenBSD: res_random.c,v 1.24 2016/04/05 04:29:21 guenther Exp $ */
2 2
3/* 3/*
4 * Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de> 4 * Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
@@ -230,12 +230,12 @@ __res_randomid(void)
230 struct timespec ts; 230 struct timespec ts;
231 pid_t pid; 231 pid_t pid;
232 u_int r; 232 u_int r;
233 _THREAD_PRIVATE_MUTEX(random); 233 static void *randomid_mutex;
234 234
235 clock_gettime(CLOCK_MONOTONIC, &ts); 235 clock_gettime(CLOCK_MONOTONIC, &ts);
236 pid = getpid(); 236 pid = getpid();
237 237
238 _THREAD_PRIVATE_MUTEX_LOCK(random); 238 _MUTEX_LOCK(&randomid_mutex);
239 239
240 if (ru_counter >= RU_MAX || ts.tv_sec > ru_reseed || pid != ru_pid) { 240 if (ru_counter >= RU_MAX || ts.tv_sec > ru_reseed || pid != ru_pid) {
241 res_initid(); 241 res_initid();
@@ -248,7 +248,7 @@ __res_randomid(void)
248 248
249 r = permute15(ru_seed ^ pmod(ru_g, ru_seed2 + ru_x, RU_N)) | ru_msb; 249 r = permute15(ru_seed ^ pmod(ru_g, ru_seed2 + ru_x, RU_N)) | ru_msb;
250 250
251 _THREAD_PRIVATE_MUTEX_UNLOCK(random); 251 _MUTEX_UNLOCK(&randomid_mutex);
252 252
253 return (r); 253 return (r);
254} 254}
diff --git a/src/lib/libc/stdlib/random.c b/src/lib/libc/stdlib/random.c
index e293648ecd..41d5f64b58 100644
--- a/src/lib/libc/stdlib/random.c
+++ b/src/lib/libc/stdlib/random.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: random.c,v 1.29 2015/01/16 16:48:51 deraadt Exp $ */ 1/* $OpenBSD: random.c,v 1.30 2016/04/05 04:29:21 guenther Exp $ */
2/* 2/*
3 * Copyright (c) 1983 Regents of the University of California. 3 * Copyright (c) 1983 Regents of the University of California.
4 * All rights reserved. 4 * All rights reserved.
@@ -175,11 +175,11 @@ static int rand_sep = SEP_3;
175 175
176static int random_deterministic; 176static int random_deterministic;
177 177
178_THREAD_PRIVATE_MUTEX(random); 178static void *random_mutex;
179static long random_l(void); 179static long random_l(void);
180 180
181#define LOCK() _THREAD_PRIVATE_MUTEX_LOCK(random) 181#define LOCK() _MUTEX_LOCK(&random_mutex)
182#define UNLOCK() _THREAD_PRIVATE_MUTEX_UNLOCK(random) 182#define UNLOCK() _MUTEX_UNLOCK(&random_mutex)
183 183
184/* 184/*
185 * srandom: 185 * srandom: