-# $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
CDIAGFLAGS=
LDADD = -Wl,-znodelete,-zinitfirst,-znodlopen
+.if defined(NOPIC)
+CFLAGS+=-DNO_PIC
+.endif
+
.PATH: ${.CURDIR}/arch/${MACHINE_CPU}
SRCS= rthread.c \
rthread_attr.c \
-/* $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.
#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
_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
_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
}
#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
* be used when linking -static.
*/
static void *__libc_overrides[] __used = {
- &CERROR_SYMBOL,
+ &__cerror,
&__errno,
&_thread_arc4_lock,
&_thread_arc4_unlock,
-/* $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.
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
-/* $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>
* $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
pthread_t me;
pid_t (*sys_fork)(void);
pid_t newid;
-#if defined(__ELF__)
+#ifndef NO_PIC
sigset_t nmask, omask;
#endif
* binding in the other locking functions can succeed.
*/
-#if defined(__ELF__)
+#ifndef NO_PIC
if (_DYNAMIC)
_rthread_dl_lock(0);
#endif
_thread_malloc_lock();
_thread_arc4_lock();
-#if defined(__ELF__)
+#ifndef NO_PIC
if (_DYNAMIC) {
sigfillset(&nmask);
_thread_sys_sigprocmask(SIG_BLOCK, &nmask, &omask);
newid = sys_fork();
-#if defined(__ELF__)
+#ifndef NO_PIC
if (_DYNAMIC) {
_rthread_bind_lock(1);
_thread_sys_sigprocmask(SIG_SETMASK, &omask, NULL);
_thread_atexit_unlock();
if (newid == 0) {
-#if defined(__ELF__)
+#ifndef NO_PIC
/* reinitialize the lock in the child */
if (_DYNAMIC)
_rthread_dl_lock(2);
/* single threaded now */
__isthreaded = 0;
}
-#if defined(__ELF__)
+#ifndef NO_PIC
else if (_DYNAMIC)
_rthread_dl_lock(1);
#endif