summaryrefslogtreecommitdiffstats
path: root/lib/libthr
diff options
context:
space:
mode:
authordavidxu <davidxu@FreeBSD.org>2010-09-25 01:57:47 +0000
committerdavidxu <davidxu@FreeBSD.org>2010-09-25 01:57:47 +0000
commit74604ed9c419ab380cacaaeb78e4c26f9f37e0ad (patch)
tree7b4cd520f700d5e2d7a21bc8175c8574d209a3ce /lib/libthr
parentdf0d735bfefbd56b7c7cbca4590c651f83e3c831 (diff)
downloadFreeBSD-src-74604ed9c419ab380cacaaeb78e4c26f9f37e0ad.zip
FreeBSD-src-74604ed9c419ab380cacaaeb78e4c26f9f37e0ad.tar.gz
To support stack unwinding for cancellation points, add -fexceptions flag
for them, two functions _pthread_cancel_enter and _pthread_cancel_leave are added to let thread enter and leave a cancellation point, it also makes it possible that other functions can be cancellation points in libraries without having to be rewritten in libthr.
Diffstat (limited to 'lib/libthr')
-rw-r--r--lib/libthr/Makefile4
-rw-r--r--lib/libthr/pthread.map2
-rw-r--r--lib/libthr/thread/thr_cancel.c12
-rw-r--r--lib/libthr/thread/thr_init.c4
-rw-r--r--lib/libthr/thread/thr_private.h3
5 files changed, 20 insertions, 5 deletions
diff --git a/lib/libthr/Makefile b/lib/libthr/Makefile
index 8b7af3a..a51b446 100644
--- a/lib/libthr/Makefile
+++ b/lib/libthr/Makefile
@@ -26,9 +26,7 @@ CFLAGS+=-I${.CURDIR}/../../libexec/rtld-elf/${MACHINE_CPUARCH}
CFLAGS+=-I${.CURDIR}/../libthread_db
CFLAGS+=-Winline
-LIBTHR_UNWIND_STACK=yes
-
-.ifdef LIBTHR_UNWIND_STACK
+.ifndef NO_THREAD_UNWIND_STACK
CFLAGS+=-I${.CURDIR}/../../contrib/gcc -fexceptions
CFLAGS+=-D_PTHREAD_FORCED_UNWIND
.endif
diff --git a/lib/libthr/pthread.map b/lib/libthr/pthread.map
index bcb5c08..5e36239 100644
--- a/lib/libthr/pthread.map
+++ b/lib/libthr/pthread.map
@@ -246,6 +246,8 @@ FBSDprivate_1.0 {
_pthread_attr_setstackaddr;
_pthread_attr_setstacksize;
_pthread_cancel;
+ _pthread_cancel_enter;
+ _pthread_cancel_leave;
_pthread_cleanup_pop;
_pthread_cleanup_push;
_pthread_cond_broadcast;
diff --git a/lib/libthr/thread/thr_cancel.c b/lib/libthr/thread/thr_cancel.c
index cd456b7..89f0ee1 100644
--- a/lib/libthr/thread/thr_cancel.c
+++ b/lib/libthr/thread/thr_cancel.c
@@ -162,3 +162,15 @@ _thr_cancel_leave(struct pthread *curthread, int maycancel)
!THR_IN_CRITICAL(curthread) && maycancel))
_pthread_exit(PTHREAD_CANCELED);
}
+
+void
+_pthread_cancel_enter(int maycancel)
+{
+ _thr_cancel_enter2(_get_curthread(), maycancel);
+}
+
+void
+_pthread_cancel_leave(int maycancel)
+{
+ _thr_cancel_leave(_get_curthread(), maycancel);
+}
diff --git a/lib/libthr/thread/thr_init.c b/lib/libthr/thread/thr_init.c
index 56541a8..e8a01d3 100644
--- a/lib/libthr/thread/thr_init.c
+++ b/lib/libthr/thread/thr_init.c
@@ -248,7 +248,9 @@ static pthread_func_t jmp_table[][2] = {
{DUAL_ENTRY(_pthread_sigmask)}, /* PJT_SIGMASK */
{DUAL_ENTRY(_pthread_testcancel)}, /* PJT_TESTCANCEL */
{DUAL_ENTRY(__pthread_cleanup_pop_imp)},/* PJT_CLEANUP_POP_IMP */
- {DUAL_ENTRY(__pthread_cleanup_push_imp)}/* PJT_CLEANUP_PUSH_IMP */
+ {DUAL_ENTRY(__pthread_cleanup_push_imp)},/* PJT_CLEANUP_PUSH_IMP */
+ {DUAL_ENTRY(_pthread_cancel_enter)}, /* PJT_CANCEL_ENTER */
+ {DUAL_ENTRY(_pthread_cancel_leave)} /* PJT_CANCEL_LEAVE */
};
static int init_once = 0;
diff --git a/lib/libthr/thread/thr_private.h b/lib/libthr/thread/thr_private.h
index a42b4ec..e5a82b9 100644
--- a/lib/libthr/thread/thr_private.h
+++ b/lib/libthr/thread/thr_private.h
@@ -716,7 +716,8 @@ int _sched_yield(void);
void _pthread_cleanup_push(void (*)(void *), void *);
void _pthread_cleanup_pop(int);
void _pthread_exit_mask(void *status, sigset_t *mask) __dead2 __hidden;
-
+void _pthread_cancel_enter(int maycancel);
+void _pthread_cancel_leave(int maycancel);
/* #include <fcntl.h> */
#ifdef _SYS_FCNTL_H_
OpenPOWER on IntegriCloud