summaryrefslogtreecommitdiff
path: root/lib/librt
diff options
context:
space:
mode:
authorDavid Xu <davidxu@FreeBSD.org>2010-09-25 01:57:47 +0000
committerDavid Xu <davidxu@FreeBSD.org>2010-09-25 01:57:47 +0000
commitf4213b9006a6ccb41a3e5463038c6f142c10405f (patch)
tree7b4cd520f700d5e2d7a21bc8175c8574d209a3ce /lib/librt
parent1ea299ce0d3e449b1f65e0b3679e926038d3c6b8 (diff)
downloadsrc-test2-f4213b9006a6ccb41a3e5463038c6f142c10405f.tar.gz
src-test2-f4213b9006a6ccb41a3e5463038c6f142c10405f.zip
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.
Notes
Notes: svn path=/head/; revision=213153
Diffstat (limited to 'lib/librt')
-rw-r--r--lib/librt/Makefile5
-rw-r--r--lib/librt/mq.c21
2 files changed, 12 insertions, 14 deletions
diff --git a/lib/librt/Makefile b/lib/librt/Makefile
index f98d94e170c8..86be751c7c3f 100644
--- a/lib/librt/Makefile
+++ b/lib/librt/Makefile
@@ -3,14 +3,15 @@
LIB=rt
SHLIB_MAJOR= 1
CFLAGS+=-I${.CURDIR}/../libc/include -I${.CURDIR}
+.ifndef NO_THREAD_STACK_UNWIND
+CFLAGS+=-fexceptions
+.endif
CFLAGS+=-Winline -Wall -g
DPADD= ${LIBPTHREAD}
LDADD= -lpthread
WARNS?= 2
-#MAN= libthr.3
-
SRCS+= aio.c mq.c sigev_thread.c timer.c
PRECIOUSLIB=
diff --git a/lib/librt/mq.c b/lib/librt/mq.c
index f2e01ca0f2b3..750e969fad42 100644
--- a/lib/librt/mq.c
+++ b/lib/librt/mq.c
@@ -39,6 +39,7 @@
#include <signal.h>
#include "sigev_thread.h"
#include "un-namespace.h"
+#include "libc_private.h"
extern int __sys_kmq_notify(int, const struct sigevent *);
extern int __sys_kmq_open(const char *, int, mode_t,
@@ -200,12 +201,11 @@ ssize_t
__mq_timedreceive_cancel(mqd_t mqd, char *buf, size_t len,
unsigned *prio, const struct timespec *timeout)
{
- int oldtype;
int ret;
- _pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
+ _pthread_cancel_enter(1);
ret = __sys_kmq_timedreceive(mqd->oshandle, buf, len, prio, timeout);
- _pthread_setcanceltype(oldtype, NULL);
+ _pthread_cancel_leave(ret == -1);
return (ret);
}
@@ -219,12 +219,11 @@ __mq_receive(mqd_t mqd, char *buf, size_t len, unsigned *prio)
ssize_t
__mq_receive_cancel(mqd_t mqd, char *buf, size_t len, unsigned *prio)
{
- int oldtype;
int ret;
- _pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
+ _pthread_cancel_enter(1);
ret = __sys_kmq_timedreceive(mqd->oshandle, buf, len, prio, NULL);
- _pthread_setcanceltype(oldtype, NULL);
+ _pthread_cancel_leave(ret == -1);
return (ret);
}
ssize_t
@@ -239,12 +238,11 @@ ssize_t
__mq_timedsend_cancel(mqd_t mqd, char *buf, size_t len,
unsigned prio, const struct timespec *timeout)
{
- int oldtype;
int ret;
- _pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
+ _pthread_cancel_enter(1);
ret = __sys_kmq_timedsend(mqd->oshandle, buf, len, prio, timeout);
- _pthread_setcanceltype(oldtype, NULL);
+ _pthread_cancel_leave(ret == -1);
return (ret);
}
@@ -259,12 +257,11 @@ __mq_send(mqd_t mqd, char *buf, size_t len, unsigned prio)
ssize_t
__mq_send_cancel(mqd_t mqd, char *buf, size_t len, unsigned prio)
{
- int oldtype;
int ret;
- _pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
+ _pthread_cancel_enter(1);
ret = __sys_kmq_timedsend(mqd->oshandle, buf, len, prio, NULL);
- _pthread_setcanceltype(oldtype, NULL);
+ _pthread_cancel_leave(ret == -1);
return (ret);
}