summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gnu/usr.bin/binutils-2.17/ld/emultempl/elf32.em6
-rw-r--r--gnu/usr.bin/binutils-2.17/ld/lexsup.c4
-rw-r--r--include/pthread.h35
-rw-r--r--lib/libc/Symbols.list2
-rw-r--r--lib/libc/hidden/pthread.h4
-rw-r--r--lib/libc/include/thread_private.h10
-rw-r--r--lib/libc/shlib_version4
-rw-r--r--lib/libc/thread/Makefile.inc3
-rw-r--r--lib/libc/thread/rthread.c12
-rw-r--r--lib/libc/thread/rthread_cleanup.c84
-rw-r--r--lib/libc/thread/rthread_once.c12
-rw-r--r--lib/librthread/Symbols.map2
-rw-r--r--lib/librthread/pthread.h4
-rw-r--r--lib/librthread/rthread.c32
-rw-r--r--lib/librthread/shlib_version2
15 files changed, 61 insertions, 155 deletions
diff --git a/gnu/usr.bin/binutils-2.17/ld/emultempl/elf32.em b/gnu/usr.bin/binutils-2.17/ld/emultempl/elf32.em
index 1a3d0123bf5..9fc5229bdcf 100644
--- a/gnu/usr.bin/binutils-2.17/ld/emultempl/elf32.em
+++ b/gnu/usr.bin/binutils-2.17/ld/emultempl/elf32.em
@@ -2161,13 +2161,7 @@ cat >>e${EMULATION_NAME}.c <<EOF
link_info.flags_1 |= (bfd_vma) DF_1_ORIGIN;
}
else if (strcmp (optarg, "defs") == 0)
-#ifndef __OpenBSD__
- /* we don't link shared objs against libc, so -zdefs/--no-undefined
- usually generates false positives */
link_info.unresolved_syms_in_objects = RM_GENERATE_ERROR;
-#else
- { }
-#endif
else if (strcmp (optarg, "muldefs") == 0)
link_info.allow_multiple_definition = TRUE;
else if (strcmp (optarg, "combreloc") == 0)
diff --git a/gnu/usr.bin/binutils-2.17/ld/lexsup.c b/gnu/usr.bin/binutils-2.17/ld/lexsup.c
index 61e23529ca4..dda6ffe861f 100644
--- a/gnu/usr.bin/binutils-2.17/ld/lexsup.c
+++ b/gnu/usr.bin/binutils-2.17/ld/lexsup.c
@@ -865,12 +865,8 @@ parse_args (unsigned argc, char **argv)
link_info.keep_memory = FALSE;
break;
case OPTION_NO_UNDEFINED:
-#ifndef __OpenBSD__
- /* we don't link shared objs against libc, so -zdefs/--no-undefined
- usually generates false positives */
link_info.unresolved_syms_in_objects
= how_to_report_unresolved_symbols;
-#endif
break;
case OPTION_ALLOW_SHLIB_UNDEFINED:
link_info.unresolved_syms_in_shared_libs = RM_IGNORE;
diff --git a/include/pthread.h b/include/pthread.h
index 937fef369bd..ecbb76a5f22 100644
--- a/include/pthread.h
+++ b/include/pthread.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pthread.h,v 1.2 2017/10/28 21:23:14 guenther Exp $ */
+/* $OpenBSD: pthread.h,v 1.3 2017/11/04 22:53:57 jca Exp $ */
/*
* Copyright (c) 1993, 1994 by Chris Provenzano, proven@mit.edu
@@ -180,40 +180,9 @@ enum pthread_mutextype {
#define PTHREAD_MUTEX_DEFAULT PTHREAD_MUTEX_STRICT_NP
/*
- * On-stack structure for the pthread_cleanup_{push,pop} macros
- * The actual values are xor'ed with random cookies.
- */
-struct __thread_cleanup {
- __uintptr_t __tc_magic;
- __uintptr_t __tc_next;
- __uintptr_t __tc_fn;
- __uintptr_t __tc_arg;
-};
-
-/*
- * These macro must be used in pairs in the same scope, such that
- * pthread_cleanup_push() can start a block declaring a variable and
- * pthread_cleanup_pop() closes that same block. Any other usage
- * violates the requirements of the POSIX and Single UNIX standards.
- */
-#define pthread_cleanup_push(cb, arg) \
- { /* MATCHED BY CLOSE BRACKET IN pthread_cleanup_pop() */ \
- struct __thread_cleanup __tc; \
- _thread_cleanup_push(cb, arg, &__tc);
-
-#define pthread_cleanup_pop(execute) \
- _thread_cleanup_pop(execute, &__tc); \
- } /* MATCHED BY OPEN BRACKET IN pthread_cleanup_push() */
-
-
-
-/*
* Thread function prototype definitions:
*/
__BEGIN_DECLS
-void _thread_cleanup_pop(int _execute, struct __thread_cleanup *_tc);
-void _thread_cleanup_push(void (*_fn)(void *), void *_arg,
- struct __thread_cleanup *_tc);
int pthread_atfork(void (*)(void), void (*)(void), void (*)(void));
int pthread_attr_destroy(pthread_attr_t *);
int pthread_attr_getstack(const pthread_attr_t *,
@@ -228,6 +197,8 @@ int pthread_attr_setstack(pthread_attr_t *, void *, size_t);
int pthread_attr_setstackaddr(pthread_attr_t *, void *);
int pthread_attr_setguardsize(pthread_attr_t *, size_t);
int pthread_attr_setdetachstate(pthread_attr_t *, int);
+void pthread_cleanup_pop(int);
+void pthread_cleanup_push(void (*) (void *), void *routine_arg);
int pthread_condattr_destroy(pthread_condattr_t *);
int pthread_condattr_init(pthread_condattr_t *);
diff --git a/lib/libc/Symbols.list b/lib/libc/Symbols.list
index 52e223ac98d..d6346040a78 100644
--- a/lib/libc/Symbols.list
+++ b/lib/libc/Symbols.list
@@ -1671,8 +1671,6 @@ _spinlock
_spinlocktry
_spinunlock
_thread_atfork
-_thread_cleanup_pop
-_thread_cleanup_push
_thread_dofork
_thread_set_callbacks
pthread_atfork
diff --git a/lib/libc/hidden/pthread.h b/lib/libc/hidden/pthread.h
index 5991bc4cfee..e16712dfbb1 100644
--- a/lib/libc/hidden/pthread.h
+++ b/lib/libc/hidden/pthread.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pthread.h,v 1.3 2017/10/28 21:23:14 guenther Exp $ */
+/* $OpenBSD: pthread.h,v 1.4 2017/11/04 22:53:57 jca Exp $ */
/*
* Copyright (c) 2015 Philip Guenther <guenther@openbsd.org>
*
@@ -20,8 +20,6 @@
#include_next <pthread.h>
-PROTO_NORMAL(_thread_cleanup_pop);
-PROTO_NORMAL(_thread_cleanup_push);
PROTO_STD_DEPRECATED(pthread_atfork);
PROTO_STD_DEPRECATED(pthread_cond_broadcast);
PROTO_STD_DEPRECATED(pthread_cond_destroy);
diff --git a/lib/libc/include/thread_private.h b/lib/libc/include/thread_private.h
index 6c695ee5ee8..fd530d7dff1 100644
--- a/lib/libc/include/thread_private.h
+++ b/lib/libc/include/thread_private.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: thread_private.h,v 1.31 2017/10/28 21:23:14 guenther Exp $ */
+/* $OpenBSD: thread_private.h,v 1.32 2017/11/04 22:53:57 jca Exp $ */
/* PUBLIC DOMAIN: No Rights Reserved. Marco S Hyman <marc@snafu.org> */
@@ -344,6 +344,12 @@ struct rthread_storage {
void *data;
};
+struct rthread_cleanup_fn {
+ void (*fn)(void *);
+ void *arg;
+ struct rthread_cleanup_fn *next;
+};
+
struct tib;
struct stack;
struct pthread {
@@ -361,7 +367,7 @@ struct pthread {
pthread_cond_t blocking_cond;
struct pthread_attr attr;
struct rthread_storage *local_storage;
- struct __thread_cleanup *cleanup_fns;
+ struct rthread_cleanup_fn *cleanup_fns;
/* cancel received in a delayed cancel block? */
int delayed_cancel;
diff --git a/lib/libc/shlib_version b/lib/libc/shlib_version
index 9dcf58fd5f6..7fe672d9c92 100644
--- a/lib/libc/shlib_version
+++ b/lib/libc/shlib_version
@@ -1,4 +1,4 @@
-major=91
-minor=1
+major=92
+minor=0
# note: If changes were made to include/thread_private.h or if system
# calls were added/changed then librthread/shlib_version also be updated.
diff --git a/lib/libc/thread/Makefile.inc b/lib/libc/thread/Makefile.inc
index 9eb1622f883..075a9b8da17 100644
--- a/lib/libc/thread/Makefile.inc
+++ b/lib/libc/thread/Makefile.inc
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile.inc,v 1.12 2017/10/28 21:23:14 guenther Exp $
+# $OpenBSD: Makefile.inc,v 1.13 2017/11/04 22:53:57 jca Exp $
.PATH: ${LIBCSRCDIR}/thread
@@ -6,7 +6,6 @@ SRCS+= callbacks.c atfork.c
# threads infrastructure
SRCS+= rthread.c \
- rthread_cleanup.c \
rthread_condattr.c \
rthread_debug.c \
rthread_file.c \
diff --git a/lib/libc/thread/rthread.c b/lib/libc/thread/rthread.c
index a92d3a20328..66405cf477a 100644
--- a/lib/libc/thread/rthread.c
+++ b/lib/libc/thread/rthread.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rthread.c,v 1.5 2017/10/28 21:23:14 guenther Exp $ */
+/* $OpenBSD: rthread.c,v 1.6 2017/11/04 22:53:57 jca Exp $ */
/*
* Copyright (c) 2004,2005 Ted Unangst <tedu@openbsd.org>
* All Rights Reserved.
@@ -112,7 +112,7 @@ DEF_STRONG(pthread_self);
void
pthread_exit(void *retval)
{
- struct __thread_cleanup *clfn;
+ struct rthread_cleanup_fn *clfn;
struct tib *tib;
pthread_t thread = pthread_self();
@@ -131,8 +131,12 @@ pthread_exit(void *retval)
thread->retval = retval;
- while ((clfn = thread->cleanup_fns) != NULL)
- _thread_cleanup_pop(1, clfn);
+ for (clfn = thread->cleanup_fns; clfn; ) {
+ struct rthread_cleanup_fn *oclfn = clfn;
+ clfn = clfn->next;
+ oclfn->fn(oclfn->arg);
+ free(oclfn);
+ }
_rthread_tls_destructors(thread);
if (_thread_cb.tc_thread_release != NULL)
diff --git a/lib/libc/thread/rthread_cleanup.c b/lib/libc/thread/rthread_cleanup.c
index 4accd64494d..e69de29bb2d 100644
--- a/lib/libc/thread/rthread_cleanup.c
+++ b/lib/libc/thread/rthread_cleanup.c
@@ -1,84 +0,0 @@
-/* $OpenBSD: rthread_cleanup.c,v 1.1 2017/10/28 21:23:14 guenther Exp $ */
-/*
- * Copyright (c) 2017 Philip Guenther <guenther@openbsd.org>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <string.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <syslog.h>
-
-#include "thread_private.h"
-
-/* If this is static then clang will optimize it away */
-uintptr_t cleanup_cookie[4] __dso_hidden
- __attribute__((section(".openbsd.randomdata")));
-
-void
-_thread_cleanup_push(void (*fn)(void *), void *arg,
- struct __thread_cleanup *tc)
-{
- pthread_t self = pthread_self();
-
- tc->__tc_magic = cleanup_cookie[0];
- tc->__tc_next = cleanup_cookie[1] ^ (uintptr_t)self->cleanup_fns;
- tc->__tc_fn = cleanup_cookie[2] ^ (uintptr_t)fn;
- tc->__tc_arg = cleanup_cookie[3] ^ (uintptr_t)arg;
- self->cleanup_fns = tc;
-}
-DEF_STRONG(_thread_cleanup_push);
-
-static const char bad_magic[] = ": corrupted buffer in pthread_cleanup_pop";
-static const char bad_pop[] = ": non-LIFO pthread_cleanup_pop";
-
-void
-_thread_cleanup_pop(int execute, struct __thread_cleanup *tc)
-{
- pthread_t self = pthread_self();
-
- if (__predict_false(tc->__tc_magic != cleanup_cookie[0] ||
- tc != self->cleanup_fns)) {
- char buf[1024];
- const char *msg;
- size_t msgsiz;
-
- /* <10> is LOG_CRIT */
- strlcpy(buf, "<10>", sizeof buf);
-
- /* Make sure progname does not fill the whole buffer */
- if (tc->__tc_magic != cleanup_cookie[0]) {
- msgsiz = sizeof bad_magic;
- msg = bad_magic;
- } else {
- msgsiz = sizeof bad_pop;
- msg = bad_pop;
- }
- strlcat(buf, __progname, sizeof(buf) - msgsiz);
- strlcat(buf, msg, sizeof buf);
-
- sendsyslog(buf, strlen(buf), LOG_CONS);
- abort();
- }
-
- self->cleanup_fns = (void *)(cleanup_cookie[1] ^ tc->__tc_next);
- if (execute) {
- void (*fn)(void *), *arg;
-
- fn = (void *)(cleanup_cookie[2] ^ tc->__tc_fn);
- arg = (void *)(cleanup_cookie[3] ^ tc->__tc_arg);
- fn(arg);
- }
-}
-DEF_STRONG(_thread_cleanup_pop);
diff --git a/lib/libc/thread/rthread_once.c b/lib/libc/thread/rthread_once.c
index 014532e56c4..a9b6749d75f 100644
--- a/lib/libc/thread/rthread_once.c
+++ b/lib/libc/thread/rthread_once.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rthread_once.c,v 1.2 2017/10/28 21:25:24 guenther Exp $ */
+/* $OpenBSD: rthread_once.c,v 1.3 2017/11/04 22:53:57 jca Exp $ */
/*
* Copyright (c) 2004,2005 Ted Unangst <tedu@openbsd.org>
* All Rights Reserved.
@@ -17,23 +17,13 @@
*/
#include <pthread.h>
-#include <stdlib.h>
-
-static void
-mutex_unlock(void *arg)
-{
- if (pthread_mutex_unlock(arg))
- abort();
-}
int
pthread_once(pthread_once_t *once_control, void (*init_routine)(void))
{
pthread_mutex_lock(&once_control->mutex);
if (once_control->state == PTHREAD_NEEDS_INIT) {
- pthread_cleanup_push(mutex_unlock, &once_control->mutex);
init_routine();
- pthread_cleanup_pop(0);
once_control->state = PTHREAD_DONE_INIT;
}
pthread_mutex_unlock(&once_control->mutex);
diff --git a/lib/librthread/Symbols.map b/lib/librthread/Symbols.map
index d3792546d80..a7aa4ce407d 100644
--- a/lib/librthread/Symbols.map
+++ b/lib/librthread/Symbols.map
@@ -29,6 +29,8 @@
pthread_barrierattr_init;
pthread_barrierattr_setpshared;
pthread_cancel;
+ pthread_cleanup_pop;
+ pthread_cleanup_push;
pthread_create;
pthread_detach;
pthread_getconcurrency;
diff --git a/lib/librthread/pthread.h b/lib/librthread/pthread.h
index 7617ce883f1..20da637727e 100644
--- a/lib/librthread/pthread.h
+++ b/lib/librthread/pthread.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pthread.h,v 1.5 2017/10/28 21:23:14 guenther Exp $ */
+/* $OpenBSD: pthread.h,v 1.6 2017/11/04 22:53:57 jca Exp $ */
/*
* Copyright (c) 2016 Philip Guenther <guenther@openbsd.org>
*
@@ -51,6 +51,8 @@ PROTO_STD_DEPRECATED(pthread_barrierattr_getpshared);
PROTO_STD_DEPRECATED(pthread_barrierattr_init);
PROTO_STD_DEPRECATED(pthread_barrierattr_setpshared);
PROTO_STD_DEPRECATED(pthread_cancel);
+PROTO_STD_DEPRECATED(pthread_cleanup_pop);
+PROTO_STD_DEPRECATED(pthread_cleanup_push);
PROTO_STD_DEPRECATED(pthread_condattr_getclock);
PROTO_STD_DEPRECATED(pthread_condattr_setclock);
PROTO_STD_DEPRECATED(pthread_create);
diff --git a/lib/librthread/rthread.c b/lib/librthread/rthread.c
index 4e4902d0218..8825e7844af 100644
--- a/lib/librthread/rthread.c
+++ b/lib/librthread/rthread.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rthread.c,v 1.98 2017/10/29 08:45:53 mpi Exp $ */
+/* $OpenBSD: rthread.c,v 1.99 2017/11/04 22:53:57 jca Exp $ */
/*
* Copyright (c) 2004,2005 Ted Unangst <tedu@openbsd.org>
* All Rights Reserved.
@@ -494,6 +494,36 @@ pthread_setcanceltype(int type, int *oldtypep)
return (0);
}
+void
+pthread_cleanup_push(void (*fn)(void *), void *arg)
+{
+ struct rthread_cleanup_fn *clfn;
+ pthread_t self = pthread_self();
+
+ clfn = calloc(1, sizeof(*clfn));
+ if (!clfn)
+ return;
+ clfn->fn = fn;
+ clfn->arg = arg;
+ clfn->next = self->cleanup_fns;
+ self->cleanup_fns = clfn;
+}
+
+void
+pthread_cleanup_pop(int execute)
+{
+ struct rthread_cleanup_fn *clfn;
+ pthread_t self = pthread_self();
+
+ clfn = self->cleanup_fns;
+ if (clfn) {
+ self->cleanup_fns = clfn->next;
+ if (execute)
+ clfn->fn(clfn->arg);
+ free(clfn);
+ }
+}
+
int
pthread_getconcurrency(void)
{
diff --git a/lib/librthread/shlib_version b/lib/librthread/shlib_version
index 361604a5eb3..970cef2afcf 100644
--- a/lib/librthread/shlib_version
+++ b/lib/librthread/shlib_version
@@ -1,2 +1,2 @@
major=25
-minor=0
+minor=1