Skip to content

Commit 5177d5e

Browse files
author
christos
committed
Fix non _REENTRANT build.
1 parent da539a5 commit 5177d5e

File tree

20 files changed

+106
-99
lines changed

20 files changed

+106
-99
lines changed

lib/libc/compat/stdlib/compat_putenv.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: compat_putenv.c,v 1.2 2012/04/22 15:55:41 christos Exp $ */
1+
/* $NetBSD: compat_putenv.c,v 1.3 2015/01/20 18:31:24 christos Exp $ */
22

33
/*-
44
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
3030
*/
3131
#include <sys/cdefs.h>
3232
#if defined(LIBC_SCCS) && !defined(lint)
33-
__RCSID("$NetBSD: compat_putenv.c,v 1.2 2012/04/22 15:55:41 christos Exp $");
33+
__RCSID("$NetBSD: compat_putenv.c,v 1.3 2015/01/20 18:31:24 christos Exp $");
3434
#endif /* LIBC_SCCS and not lint */
3535

3636
#define __LIBC12_SOURCE__
@@ -43,7 +43,6 @@ __RCSID("$NetBSD: compat_putenv.c,v 1.2 2012/04/22 15:55:41 christos Exp $");
4343
#include <compat/include/stdlib.h>
4444

4545
#include "env.h"
46-
#include "reentrant.h"
4746
#include "local.h"
4847

4948
#ifdef __weak_alias

lib/libc/compat/stdlib/compat_random.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: compat_random.c,v 1.2 2014/06/12 18:50:12 christos Exp $ */
1+
/* $NetBSD: compat_random.c,v 1.3 2015/01/20 18:31:24 christos Exp $ */
22

33
/*-
44
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
3030
*/
3131
#include <sys/cdefs.h>
3232
#if defined(LIBC_SCCS) && !defined(lint)
33-
__RCSID("$NetBSD: compat_random.c,v 1.2 2014/06/12 18:50:12 christos Exp $");
33+
__RCSID("$NetBSD: compat_random.c,v 1.3 2015/01/20 18:31:24 christos Exp $");
3434
#endif /* LIBC_SCCS and not lint */
3535

3636
#define __LIBC12_SOURCE__
@@ -41,7 +41,6 @@ __RCSID("$NetBSD: compat_random.c,v 1.2 2014/06/12 18:50:12 christos Exp $");
4141
#include <compat/include/stdlib.h>
4242

4343
#include "env.h"
44-
#include "reentrant.h"
4544
#include "local.h"
4645

4746
#ifdef __weak_alias

lib/libc/compat/stdlib/compat_unsetenv.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: compat_unsetenv.c,v 1.3 2010/11/14 18:11:42 tron Exp $ */
1+
/* $NetBSD: compat_unsetenv.c,v 1.4 2015/01/20 18:31:24 christos Exp $ */
22

33
/*
44
* Copyright (c) 1987, 1993
@@ -34,7 +34,7 @@
3434
#if 0
3535
static char sccsid[] = "from: @(#)setenv.c 8.1 (Berkeley) 6/4/93";
3636
#else
37-
__RCSID("$NetBSD: compat_unsetenv.c,v 1.3 2010/11/14 18:11:42 tron Exp $");
37+
__RCSID("$NetBSD: compat_unsetenv.c,v 1.4 2015/01/20 18:31:24 christos Exp $");
3838
#endif
3939
#endif /* LIBC_SCCS and not lint */
4040

@@ -47,7 +47,6 @@ __RCSID("$NetBSD: compat_unsetenv.c,v 1.3 2010/11/14 18:11:42 tron Exp $");
4747
#include <compat/include/stdlib.h>
4848
#include <string.h>
4949
#include <bitstring.h>
50-
#include "reentrant.h"
5150
#include "local.h"
5251

5352
#ifdef __weak_alias

lib/libc/gdtoa/gdtoa_locks.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: gdtoa_locks.c,v 1.1 2006/01/25 15:36:13 kleink Exp $ */
1+
/* $NetBSD: gdtoa_locks.c,v 1.2 2015/01/20 18:31:25 christos Exp $ */
22

33
/*
44
* Written by Klaus Klein <kleink@NetBSD.org>, November 16, 2005.
@@ -7,4 +7,6 @@
77

88
#include "gdtoaimp.h"
99

10+
#ifdef _REENTRANT
1011
mutex_t __gdtoa_locks[2] = { MUTEX_INITIALIZER, MUTEX_INITIALIZER };
12+
#endif

lib/libc/gen/arc4random.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: arc4random.c,v 1.26 2014/11/16 20:33:04 riastradh Exp $ */
1+
/* $NetBSD: arc4random.c,v 1.27 2015/01/20 18:31:25 christos Exp $ */
22

33
/*-
44
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -52,7 +52,7 @@
5252
*/
5353

5454
#include <sys/cdefs.h>
55-
__RCSID("$NetBSD: arc4random.c,v 1.26 2014/11/16 20:33:04 riastradh Exp $");
55+
__RCSID("$NetBSD: arc4random.c,v 1.27 2015/01/20 18:31:25 christos Exp $");
5656

5757
#include "namespace.h"
5858
#include "reentrant.h"
@@ -123,7 +123,7 @@ rotate(uint32_t u, unsigned c)
123123
(c) += (d); (b) ^= (c); (b) = rotate((b), 12); \
124124
(a) += (b); (d) ^= (a); (d) = rotate((d), 8); \
125125
(c) += (d); (b) ^= (c); (b) = rotate((b), 7); \
126-
} while (0)
126+
} while (/*CONSTCOND*/0)
127127

128128
const uint8_t crypto_core_constant32[16] = "expand 32-byte k";
129129

@@ -341,7 +341,7 @@ crypto_onetimestream(const void *seed, void *buf, size_t n)
341341
uint32_t nonce[crypto_core_INPUTBYTES / sizeof(uint32_t)] = {0};
342342
uint8_t block[crypto_core_OUTPUTBYTES];
343343
uint8_t *p8, *p32;
344-
const uint8_t *nonce8 = (const uint8_t *)nonce;
344+
const uint8_t *nonce8 = (const uint8_t *)(void *)nonce;
345345
size_t ni, nb, nf;
346346

347347
/*
@@ -355,8 +355,8 @@ crypto_onetimestream(const void *seed, void *buf, size_t n)
355355
* log_2 (o 2^(8 i)) = log_2 o + log_2 2^(8 i)
356356
* = log_2 o + 8 i.
357357
*/
358-
__CTASSERT(CHAR_BIT*sizeof n <=
359-
(ilog2(crypto_core_OUTPUTBYTES) + 8*crypto_core_INPUTBYTES));
358+
__CTASSERT(CHAR_BIT * sizeof n <=
359+
(/*LINTED*/ilog2(crypto_core_OUTPUTBYTES) + 8 * crypto_core_INPUTBYTES));
360360

361361
p8 = buf;
362362
p32 = (uint8_t *)roundup2((uintptr_t)p8, 4);
@@ -419,7 +419,7 @@ arc4random_prng_addrandom(struct arc4random_prng *prng, const void *data,
419419
crypto_prng_buf(&prng->arc4_prng, buf, sizeof buf);
420420
SHA256_Update(&ctx, buf, sizeof buf);
421421

422-
if (sysctl(mib, __arraycount(mib), buf, &buflen, NULL, 0) == -1)
422+
if (sysctl(mib, (u_int)__arraycount(mib), buf, &buflen, NULL, 0) == -1)
423423
abort();
424424
if (buflen != sizeof buf)
425425
abort();
@@ -476,11 +476,6 @@ arc4random_prng_destroy(struct arc4random_prng *prng)
476476

477477
/* Library state */
478478

479-
#if !defined(_REENTRANT)
480-
#define mutex_lock(m) do {} while (0)
481-
#define mutex_unlock(m) do {} while (0)
482-
#endif
483-
484479
static struct arc4random_global {
485480
#ifdef _REENTRANT
486481
mutex_t lock;

lib/libc/gen/popen.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: popen.c,v 1.33 2015/01/20 17:28:00 christos Exp $ */
1+
/* $NetBSD: popen.c,v 1.34 2015/01/20 18:31:25 christos Exp $ */
22

33
/*
44
* Copyright (c) 1988, 1993
@@ -37,7 +37,7 @@
3737
#if 0
3838
static char sccsid[] = "@(#)popen.c 8.3 (Berkeley) 5/3/95";
3939
#else
40-
__RCSID("$NetBSD: popen.c,v 1.33 2015/01/20 17:28:00 christos Exp $");
40+
__RCSID("$NetBSD: popen.c,v 1.34 2015/01/20 18:31:25 christos Exp $");
4141
#endif
4242
#endif /* LIBC_SCCS and not lint */
4343

@@ -57,7 +57,6 @@ __RCSID("$NetBSD: popen.c,v 1.33 2015/01/20 17:28:00 christos Exp $");
5757
#include <fcntl.h>
5858

5959
#include "env.h"
60-
#include "reentrant.h"
6160

6261
#ifdef __weak_alias
6362
__weak_alias(popen,_popen)

lib/libc/gen/pthread_atfork.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: pthread_atfork.c,v 1.9 2012/03/20 16:36:05 matt Exp $ */
1+
/* $NetBSD: pthread_atfork.c,v 1.10 2015/01/20 18:31:25 christos Exp $ */
22

33
/*-
44
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
3131

3232
#include <sys/cdefs.h>
3333
#if defined(LIBC_SCCS) && !defined(lint)
34-
__RCSID("$NetBSD: pthread_atfork.c,v 1.9 2012/03/20 16:36:05 matt Exp $");
34+
__RCSID("$NetBSD: pthread_atfork.c,v 1.10 2015/01/20 18:31:25 christos Exp $");
3535
#endif /* LIBC_SCCS and not lint */
3636

3737
#include "namespace.h"
@@ -61,7 +61,9 @@ struct atfork_callback {
6161
* across the fork, forking is going to be serialized anyway.
6262
*/
6363
static struct atfork_callback atfork_builtin;
64+
#ifdef _REENTRANT
6465
static mutex_t atfork_lock = MUTEX_INITIALIZER;
66+
#endif
6567
SIMPLEQ_HEAD(atfork_callback_q, atfork_callback);
6668

6769
static struct atfork_callback_q prepareq = SIMPLEQ_HEAD_INITIALIZER(prepareq);

lib/libc/include/env.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: env.h,v 1.2 2010/11/14 22:04:36 tron Exp $ */
1+
/* $NetBSD: env.h,v 1.3 2015/01/20 18:31:25 christos Exp $ */
22

33
/*-
44
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -56,7 +56,7 @@ __writelockenv(void)
5656
}
5757

5858
static __inline bool
59-
__unlocklockenv(void)
59+
__unlockenv(void)
6060
{
6161
return true;
6262
}

lib/libc/include/reentrant.h

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: reentrant.h,v 1.17 2013/04/12 18:12:58 joerg Exp $ */
1+
/* $NetBSD: reentrant.h,v 1.18 2015/01/20 18:31:25 christos Exp $ */
22

33
/*-
44
* Copyright (c) 1997, 1998, 2003 The NetBSD Foundation, Inc.
@@ -278,31 +278,38 @@ __END_DECLS
278278

279279
#else /* _REENTRANT */
280280

281-
#define mutex_init(m, a)
282-
#define mutex_lock(m)
283-
#define mutex_trylock(m)
284-
#define mutex_unlock(m)
285-
#define mutex_destroy(m)
286-
287-
#define cond_init(c, t, a)
288-
#define cond_signal(c)
289-
#define cond_broadcast(c)
290-
#define cond_wait(c, m)
291-
#define cond_timedwait(c, m, t)
292-
#define cond_destroy(c)
293-
294-
#define rwlock_init(l, a)
295-
#define rwlock_rdlock(l)
296-
#define rwlock_wrlock(l)
297-
#define rwlock_tryrdlock(l)
298-
#define rwlock_trywrlock(l)
299-
#define rwlock_unlock(l)
300-
#define rwlock_destroy(l)
301-
302-
#define thr_keycreate(k, d)
303-
#define thr_setspecific(k, p)
304-
#define thr_getspecific(k)
305-
#define thr_keydelete(k)
281+
#ifndef __empty
282+
#define __empty do {} while (/*CONSTCOND*/0)
283+
#endif
284+
#define mutex_init(m, a) __empty
285+
#define mutex_lock(m) __empty
286+
#define mutex_trylock(m) __empty
287+
#define mutex_unlock(m) __empty
288+
#define mutex_destroy(m) __empty
289+
290+
#define cond_init(c, t, a) __empty
291+
#define cond_signal(c) __empty
292+
#define cond_broadcast(c) __empty
293+
#define cond_wait(c, m) __empty
294+
#define cond_timedwait(c, m, t) __empty
295+
#define cond_destroy(c) __empty
296+
297+
#define rwlock_init(l, a) __empty
298+
#define rwlock_rdlock(l) __empty
299+
#define rwlock_wrlock(l) __empty
300+
#define rwlock_tryrdlock(l) __empty
301+
#define rwlock_trywrlock(l) __empty
302+
#define rwlock_unlock(l) __empty
303+
#define rwlock_destroy(l) __empty
304+
305+
#define thr_keycreate(k, d) /*LINTED*/0
306+
#define thr_setspecific(k, p) __empty
307+
#define thr_getspecific(k) /*LINTED*/0
308+
#define thr_keydelete(k) __empty
309+
310+
#define mutexattr_init(ma) __empty
311+
#define mutexattr_settype(ma, t) __empty
312+
#define mutexattr_destroy(ma) __empty
306313

307314
static inline int
308315
thr_once(once_t *once_control, void (*routine)(void))
@@ -313,12 +320,12 @@ thr_once(once_t *once_control, void (*routine)(void))
313320
}
314321
return 0;
315322
}
316-
#define thr_sigsetmask(f, n, o)
317-
#define thr_self()
318-
#define thr_errno()
323+
#define thr_sigsetmask(f, n, o) __empty
324+
#define thr_self() __empty
325+
#define thr_errno() __empty
319326
#define thr_curcpu() ((unsigned int)0)
320327

321-
#define FLOCKFILE(fp)
322-
#define FUNLOCKFILE(fp)
328+
#define FLOCKFILE(fp) __empty
329+
#define FUNLOCKFILE(fp) __empty
323330

324331
#endif /* _REENTRANT */

lib/libc/rpc/clnt_simple.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: clnt_simple.c,v 1.32 2013/03/11 20:19:29 tron Exp $ */
1+
/* $NetBSD: clnt_simple.c,v 1.33 2015/01/20 18:31:25 christos Exp $ */
22

33
/*
44
* Copyright (c) 2010, Oracle America, Inc.
@@ -41,7 +41,7 @@
4141
#if 0
4242
static char sccsid[] = "@(#)clnt_simple.c 1.49 89/01/31 Copyr 1984 Sun Micro";
4343
#else
44-
__RCSID("$NetBSD: clnt_simple.c,v 1.32 2013/03/11 20:19:29 tron Exp $");
44+
__RCSID("$NetBSD: clnt_simple.c,v 1.33 2015/01/20 18:31:25 christos Exp $");
4545
#endif
4646
#endif
4747

@@ -141,26 +141,25 @@ rpc_call(
141141
/* XXX: nettype may be NULL ??? */
142142

143143
#ifdef _REENTRANT
144-
if (__isthreaded == 0) {
145-
rcp = rpc_call_private_main;
146-
} else {
144+
if (__isthreaded) {
147145
thr_once(&rpc_call_once, rpc_call_setup);
148146
rcp = thr_getspecific(rpc_call_key);
149-
}
150-
#else
151-
rcp = rpc_call_private_main;
147+
} else
152148
#endif
149+
rcp = rpc_call_private_main;
153150
if (rcp == NULL) {
154151
rcp = malloc(sizeof (*rcp));
155152
if (rcp == NULL) {
156153
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
157154
rpc_createerr.cf_error.re_errno = errno;
158155
return (rpc_createerr.cf_stat);
159156
}
160-
if (__isthreaded == 0)
161-
rpc_call_private_main = rcp;
162-
else
157+
#ifdef _REENTRANT
158+
if (__isthreaded)
163159
thr_setspecific(rpc_call_key, (void *) rcp);
160+
else
161+
#endif
162+
rpc_call_private_main = rcp;
164163
rcp->valid = 0;
165164
rcp->client = NULL;
166165
}

0 commit comments

Comments
 (0)