summaryrefslogtreecommitdiff
path: root/lib/librthread
diff options
context:
space:
mode:
authorJeremie Courreges-Anglas <jca@cvs.openbsd.org>2017-11-04 22:53:58 +0000
committerJeremie Courreges-Anglas <jca@cvs.openbsd.org>2017-11-04 22:53:58 +0000
commitd9fa4bd9a3fc4cca904ffcf8f640020d6e0538be (patch)
treeca254e2971b46758ba17bb858ace8a0e4258346c /lib/librthread
parentf62b8a875ce265c1684cc9af05545b04e3b21b9a (diff)
Revert recent changes to unbreak ports/net/samba
While it is not clear (to me) why that ports ends up with corrupted shared libs, reverting those changes fixes the issue and should allow us to close p2k17 more smoothly. Discussed with a bunch, ok ajacoutot@ guenther@
Diffstat (limited to 'lib/librthread')
-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
4 files changed, 37 insertions, 3 deletions
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