summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/librthread/Makefile6
-rw-r--r--lib/librthread/rthread.c17
-rw-r--r--lib/librthread/rthread.h4
-rw-r--r--lib/librthread/rthread_fork.c16
4 files changed, 21 insertions, 22 deletions
diff --git a/lib/librthread/Makefile b/lib/librthread/Makefile
index 1af81daa7a3..c4fae147425 100644
--- a/lib/librthread/Makefile
+++ b/lib/librthread/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.39 2014/07/16 20:02:17 okan Exp $
+# $OpenBSD: Makefile,v 1.40 2015/05/19 20:50:06 guenther Exp $
LIB=pthread
LIBCSRCDIR= ${.CURDIR}/../libc
@@ -10,6 +10,10 @@ CFLAGS+=-I${LIBCSRCDIR}/arch/${MACHINE_CPU} -I${LIBCSRCDIR}/include
CDIAGFLAGS=
LDADD = -Wl,-znodelete,-zinitfirst,-znodlopen
+.if defined(NOPIC)
+CFLAGS+=-DNO_PIC
+.endif
+
.PATH: ${.CURDIR}/arch/${MACHINE_CPU}
SRCS= rthread.c \
rthread_attr.c \
diff --git a/lib/librthread/rthread.c b/lib/librthread/rthread.c
index 5f9ca87471c..aff3817f42c 100644
--- a/lib/librthread/rthread.c
+++ b/lib/librthread/rthread.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rthread.c,v 1.82 2015/05/10 18:33:15 guenther Exp $ */
+/* $OpenBSD: rthread.c,v 1.83 2015/05/19 20:50:06 guenther Exp $ */
/*
* Copyright (c) 2004,2005 Ted Unangst <tedu@openbsd.org>
* All Rights Reserved.
@@ -26,7 +26,7 @@
#include <sys/socket.h>
#include <sys/mman.h>
#include <sys/msg.h>
-#if defined(__ELF__)
+#ifndef NO_PIC
#include <sys/exec_elf.h>
#pragma weak _DYNAMIC
#endif
@@ -205,7 +205,7 @@ _rthread_init(void)
_rthread_debug(1, "rthread init\n");
-#if defined(__ELF__) && !defined(__vax__)
+#ifndef NO_PIC
if (_DYNAMIC) {
/*
* To avoid recursion problems in ld.so, we need to trigger the
@@ -654,7 +654,7 @@ _thread_dump_info(void)
_spinunlock(&_thread_lock);
}
-#if defined(__ELF__)
+#ifndef NO_PIC
/*
* _rthread_dl_lock() provides the locking for dlopen(), dlclose(), and
* the function called via atexit() to invoke all destructors. The latter
@@ -722,17 +722,12 @@ _rthread_bind_lock(int what)
}
#endif
-#ifdef __ELF__
-#define CERROR_SYMBOL __cerror
-#else
-#define CERROR_SYMBOL _cerror
-#endif
/*
* XXX: Bogus type signature, but we only need to be able to emit a
* reference to it below.
*/
-extern void CERROR_SYMBOL(void);
+extern void __cerror(void);
/*
* All weak references used within libc that are redefined in libpthread
@@ -740,7 +735,7 @@ extern void CERROR_SYMBOL(void);
* be used when linking -static.
*/
static void *__libc_overrides[] __used = {
- &CERROR_SYMBOL,
+ &__cerror,
&__errno,
&_thread_arc4_lock,
&_thread_arc4_unlock,
diff --git a/lib/librthread/rthread.h b/lib/librthread/rthread.h
index 9e087a90595..7176252353a 100644
--- a/lib/librthread/rthread.h
+++ b/lib/librthread/rthread.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rthread.h,v 1.51 2015/04/29 06:01:37 guenther Exp $ */
+/* $OpenBSD: rthread.h,v 1.52 2015/05/19 20:50:06 guenther Exp $ */
/*
* Copyright (c) 2004,2005 Ted Unangst <tedu@openbsd.org>
* All Rights Reserved.
@@ -219,7 +219,7 @@ void _rthread_tls_destructors(pthread_t);
void _rthread_debug(int, const char *, ...)
__attribute__((__format__ (printf, 2, 3)));
void _rthread_debug_init(void);
-#if defined(__ELF__)
+#ifndef NO_PIC
void _rthread_dl_lock(int what);
void _rthread_bind_lock(int);
#endif
diff --git a/lib/librthread/rthread_fork.c b/lib/librthread/rthread_fork.c
index 7bca5b0595f..a1cda56f76f 100644
--- a/lib/librthread/rthread_fork.c
+++ b/lib/librthread/rthread_fork.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rthread_fork.c,v 1.12 2015/05/10 18:33:15 guenther Exp $ */
+/* $OpenBSD: rthread_fork.c,v 1.13 2015/05/19 20:50:06 guenther Exp $ */
/*
* Copyright (c) 2008 Kurt Miller <kurt@openbsd.org>
@@ -30,7 +30,7 @@
* $FreeBSD: /repoman/r/ncvs/src/lib/libc_r/uthread/uthread_atfork.c,v 1.1 2004/12/10 03:36:45 grog Exp $
*/
-#if defined(__ELF__)
+#ifndef NO_PIC
#include <sys/types.h>
#include <sys/exec_elf.h>
#pragma weak _DYNAMIC
@@ -56,7 +56,7 @@ _dofork(int is_vfork)
pthread_t me;
pid_t (*sys_fork)(void);
pid_t newid;
-#if defined(__ELF__)
+#ifndef NO_PIC
sigset_t nmask, omask;
#endif
@@ -75,7 +75,7 @@ _dofork(int is_vfork)
* binding in the other locking functions can succeed.
*/
-#if defined(__ELF__)
+#ifndef NO_PIC
if (_DYNAMIC)
_rthread_dl_lock(0);
#endif
@@ -84,7 +84,7 @@ _dofork(int is_vfork)
_thread_malloc_lock();
_thread_arc4_lock();
-#if defined(__ELF__)
+#ifndef NO_PIC
if (_DYNAMIC) {
sigfillset(&nmask);
_thread_sys_sigprocmask(SIG_BLOCK, &nmask, &omask);
@@ -94,7 +94,7 @@ _dofork(int is_vfork)
newid = sys_fork();
-#if defined(__ELF__)
+#ifndef NO_PIC
if (_DYNAMIC) {
_rthread_bind_lock(1);
_thread_sys_sigprocmask(SIG_SETMASK, &omask, NULL);
@@ -106,7 +106,7 @@ _dofork(int is_vfork)
_thread_atexit_unlock();
if (newid == 0) {
-#if defined(__ELF__)
+#ifndef NO_PIC
/* reinitialize the lock in the child */
if (_DYNAMIC)
_rthread_dl_lock(2);
@@ -128,7 +128,7 @@ _dofork(int is_vfork)
/* single threaded now */
__isthreaded = 0;
}
-#if defined(__ELF__)
+#ifndef NO_PIC
else if (_DYNAMIC)
_rthread_dl_lock(1);
#endif