diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2020-02-10 00:52:50 +0000 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2020-02-10 01:03:54 +0000 |
commit | e9644c20ce4718ca99953cab0d306b7789303c8e (patch) | |
tree | 89e57ee542ffff864375f9631e4301bbea3991ea /sysdeps/mach | |
parent | 1cec114b17ad2d5b019074e3cd419cb331feac7a (diff) | |
download | glibc-e9644c20ce4718ca99953cab0d306b7789303c8e.tar.gz glibc-e9644c20ce4718ca99953cab0d306b7789303c8e.tar.xz glibc-e9644c20ce4718ca99953cab0d306b7789303c8e.zip |
htl: Make sem_wait/sem_timedwait interruptible
Diffstat (limited to 'sysdeps/mach')
-rw-r--r-- | sysdeps/mach/htl/pt-block-intr.c | 6 | ||||
-rw-r--r-- | sysdeps/mach/htl/pt-block.c | 19 | ||||
-rw-r--r-- | sysdeps/mach/htl/pt-timedblock-intr.c | 3 | ||||
-rw-r--r-- | sysdeps/mach/htl/pt-timedblock.c | 8 |
4 files changed, 33 insertions, 3 deletions
diff --git a/sysdeps/mach/htl/pt-block-intr.c b/sysdeps/mach/htl/pt-block-intr.c new file mode 100644 index 0000000000..f15beb3a0f --- /dev/null +++ b/sysdeps/mach/htl/pt-block-intr.c @@ -0,0 +1,6 @@ +#include <pt-internal.h> +#define RETTYPE error_t +#define RETURN(val) return val +#define __pthread_block __pthread_block_intr +#define MSG_OPTIONS MACH_RCV_INTERRUPT +#include "pt-block.c" diff --git a/sysdeps/mach/htl/pt-block.c b/sysdeps/mach/htl/pt-block.c index e1500dce33..28bae157d1 100644 --- a/sysdeps/mach/htl/pt-block.c +++ b/sysdeps/mach/htl/pt-block.c @@ -24,15 +24,30 @@ #include <pt-internal.h> +#ifndef MSG_OPTIONS +# define MSG_OPTIONS 0 +#endif + +#ifndef RETTYPE +# define RETTYPE void +#endif + +#ifndef RETURN +# define RETURN(val) +#endif + /* Block THREAD. */ -void +RETTYPE __pthread_block (struct __pthread *thread) { mach_msg_header_t msg; error_t err; - err = __mach_msg (&msg, MACH_RCV_MSG, 0, sizeof msg, + err = __mach_msg (&msg, MACH_RCV_MSG | MSG_OPTIONS, 0, sizeof msg, thread->wakeupmsg.msgh_remote_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if ((MSG_OPTIONS & MACH_RCV_INTERRUPT) && err == MACH_RCV_INTERRUPTED) + RETURN(EINTR); assert_perror (err); + RETURN(0); } diff --git a/sysdeps/mach/htl/pt-timedblock-intr.c b/sysdeps/mach/htl/pt-timedblock-intr.c new file mode 100644 index 0000000000..70e132716b --- /dev/null +++ b/sysdeps/mach/htl/pt-timedblock-intr.c @@ -0,0 +1,3 @@ +#define __pthread_timedblock __pthread_timedblock_intr +#define MSG_OPTIONS MACH_RCV_INTERRUPT +#include "pt-timedblock.c" diff --git a/sysdeps/mach/htl/pt-timedblock.c b/sysdeps/mach/htl/pt-timedblock.c index 63af869c90..ead070e397 100644 --- a/sysdeps/mach/htl/pt-timedblock.c +++ b/sysdeps/mach/htl/pt-timedblock.c @@ -26,6 +26,10 @@ #include <pt-internal.h> +#ifndef MSG_OPTIONS +# define MSG_OPTIONS 0 +#endif + /* Block THREAD. */ error_t __pthread_timedblock (struct __pthread *thread, @@ -54,11 +58,13 @@ __pthread_timedblock (struct __pthread *thread, /* Need to do a carry. */ timeout -= (now.tv_nsec - abstime->tv_nsec + 999999) / 1000000; - err = __mach_msg (&msg, MACH_RCV_MSG | MACH_RCV_TIMEOUT, 0, + err = __mach_msg (&msg, MACH_RCV_MSG | MACH_RCV_TIMEOUT | MSG_OPTIONS, 0, sizeof msg, thread->wakeupmsg.msgh_remote_port, timeout, MACH_PORT_NULL); if (err == EMACH_RCV_TIMED_OUT) return ETIMEDOUT; + if ((MSG_OPTIONS & MACH_RCV_INTERRUPT) && err == MACH_RCV_INTERRUPTED) + return EINTR; assert_perror (err); return 0; |