* hurd/hurdselect.c: Include <sysdep-cancel.h>.
(_hurd_select): Surround call to __mach_msg with enabling async cancel.
* sysdeps/mach/hurd/accept4.c: Include <sysdep-cancel.h>.
(__libc_accept4): Surround call to __socket_accept with enabling async cancel,
and use HURD_DPORT_USE_CANCEL instead of HURD_DPORT_USE.
* sysdeps/mach/hurd/connect.c: Include <sysdep-cancel.h>.
(__connect): Surround call to __file_name_lookup and __socket_connect
with enabling async cancel, and use HURD_DPORT_USE_CANCEL instead of
HURD_DPORT_USE.
* sysdeps/mach/hurd/fdatasync.c: Include <sysdep-cancel.h>.
(fdatasync): Surround call to __file_sync with enabling async cancel, and use
HURD_DPORT_USE_CANCEL instead of HURD_DPORT_USE.
* sysdeps/mach/hurd/fsync.c: Include <sysdep-cancel.h>.
(fsync): Surround call to __file_sync with enabling async cancel, and use
HURD_DPORT_USE_CANCEL instead of HURD_DPORT_USE.
* sysdeps/mach/hurd/ioctl.c: Include <sysdep-cancel.h>.
(__ioctl): When request is TIOCDRAIN, surround call to send_rpc with enabling
async cancel, and use HURD_DPORT_USE_CANCEL instead of HURD_DPORT_USE.
* sysdeps/mach/hurd/msync.c: Include <sysdep-cancel.h>.
(msync): Surround call to __vm_object_sync with enabling async cancel.
* sysdeps/mach/hurd/sigsuspend.c: Include <sysdep-cancel.h>.
(__sigsuspend): Surround call to __mach_msg with enabling async cancel.
* sysdeps/mach/hurd/sigwait.c: Include <sysdep-cancel.h>.
(__sigwait): Surround wait code with enabling async cancel.
* sysdeps/mach/msync.c: Include <sysdep-cancel.h>.
(msync): Surround call to __vm_msync with enabling async cancel.
* sysdeps/mach/sleep.c: Include <sysdep-cancel.h>.
(__sleep): Surround call to __mach_msg with enabling async cancel.
* sysdeps/mach/usleep.c: Include <sysdep-cancel.h>.
(usleep): Surround call to __vm_msync with enabling async cancel.
#include <stdint.h>
#include <limits.h>
#include <time.h>
+#include <sysdep-cancel.h>
/* All user select types. */
#define SELECT_ALL (SELECT_READ | SELECT_WRITE | SELECT_URG)
to = MACH_MSG_TIMEOUT_NONE;
}
+ int cancel_oldtype = LIBC_CANCEL_ASYNC();
while ((msgerr = __mach_msg (&msg.head,
MACH_RCV_MSG | MACH_RCV_INTERRUPT | options,
0, sizeof msg, portset, to,
MACH_PORT_NULL)) == MACH_MSG_SUCCESS)
{
+ LIBC_CANCEL_RESET (cancel_oldtype);
+
/* We got a message. Decode it. */
#ifdef MACH_MSG_TYPE_BIT
const union typeword inttype =
options |= MACH_RCV_TIMEOUT;
}
}
+ LIBC_CANCEL_RESET (cancel_oldtype);
if (msgerr == MACH_RCV_INTERRUPTED)
/* Interruption on our side (e.g. signal reception). */
#include <hurd.h>
#include <hurd/fd.h>
#include <hurd/socket.h>
+#include <sysdep-cancel.h>
/* Await a connection on socket FD.
When a connection arrives, open a new socket to communicate with it,
char *buf = (char *) addr;
mach_msg_type_number_t buflen;
int type;
+ int cancel_oldtype;
flags = sock_to_o_flags (flags);
if (flags & ~(O_CLOEXEC | O_NONBLOCK))
return __hurd_fail (EINVAL);
- if (err = HURD_DPORT_USE (fd, __socket_accept (port, &new, &aport)))
+ cancel_oldtype = LIBC_CANCEL_ASYNC();
+ err = HURD_DPORT_USE_CANCEL (fd, __socket_accept (port, &new, &aport));
+ LIBC_CANCEL_RESET (cancel_oldtype);
+ if (err)
return __hurd_dfail (fd, err);
if (addr != NULL)
#include <hurd/socket.h>
#include <sys/un.h>
#include <hurd/ifsock.h>
+#include <sysdep-cancel.h>
#include "hurd/hurdsocket.h"
/* Open a connection on socket FD to peer at ADDR (which LEN bytes long).
error_t err;
addr_port_t aport;
const struct sockaddr_un *addr = addrarg.__sockaddr_un__;
+ int cancel_oldtype;
if (addr->sun_family == AF_LOCAL)
{
char *name = _hurd_sun_path_dupa (addr, len);
/* For the local domain, we must look up the name as a file and talk
to it with the ifsock protocol. */
- file_t file = __file_name_lookup (name, 0, 0);
+ file_t file;
+ cancel_oldtype = LIBC_CANCEL_ASYNC();
+ file = __file_name_lookup (name, 0, 0);
+ LIBC_CANCEL_RESET (cancel_oldtype);
if (file == MACH_PORT_NULL)
return -1;
err = __ifsock_getsockaddr (file, &aport);
else
err = EIEIO;
- err = HURD_DPORT_USE (fd,
+ err = HURD_DPORT_USE_CANCEL (fd,
({
if (err)
err = __socket_create_address (port,
&aport);
if (! err)
{
+ cancel_oldtype = LIBC_CANCEL_ASYNC();
err = __socket_connect (port, aport);
+ LIBC_CANCEL_RESET (cancel_oldtype);
__mach_port_deallocate (__mach_task_self (),
aport);
}
#include <unistd.h>
#include <hurd.h>
#include <hurd/fd.h>
+#include <sysdep-cancel.h>
/* Make all changes done to FD's file data actually appear on disk. */
int
fdatasync (int fd)
{
- error_t err = HURD_DPORT_USE (fd, __file_sync (port, 1, 1));
+ error_t err;
+ int cancel_oldtype;
+
+ cancel_oldtype = LIBC_CANCEL_ASYNC();
+ err = HURD_DPORT_USE_CANCEL (fd, __file_sync (port, 1, 1));
+ LIBC_CANCEL_RESET (cancel_oldtype);
if (err)
{
if (err == EOPNOTSUPP)
#include <unistd.h>
#include <hurd.h>
#include <hurd/fd.h>
+#include <sysdep-cancel.h>
/* Make all changes done to FD actually appear on disk. */
int
fsync (int fd)
{
- error_t err = HURD_DPORT_USE (fd, __file_sync (port, 1, 0));
+ error_t err;
+ int cancel_oldtype;
+
+ cancel_oldtype = LIBC_CANCEL_ASYNC();
+ err = HURD_DPORT_USE_CANCEL (fd, __file_sync (port, 1, 0));
+ LIBC_CANCEL_RESET (cancel_oldtype);
if (err)
{
if (err == EOPNOTSUPP)
#include <stdint.h>
#include <hurd/ioctl.h>
#include <mach/mig_support.h>
+#include <sysdep-cancel.h>
#include <hurd/ioctls.defs>
/* Marshal the arguments into the request message and make the RPC.
This wrapper function handles EBACKGROUND returns, turning them
into either SIGTTOU or EIO. */
- err = HURD_DPORT_USE (fd, _hurd_ctty_output (port, ctty, send_rpc));
+ if (request == TIOCDRAIN)
+ {
+ /* This is a cancellation point. */
+ int cancel_oldtype = LIBC_CANCEL_ASYNC();
+ err = HURD_DPORT_USE_CANCEL (fd, _hurd_ctty_output (port, ctty, send_rpc));
+ LIBC_CANCEL_RESET (cancel_oldtype);
+ }
+ else
+ err = HURD_DPORT_USE (fd, _hurd_ctty_output (port, ctty, send_rpc));
#ifdef MACH_MSG_TYPE_BIT
t = (mach_msg_type_t *) msg.data;
#include <sys/types.h>
#include <sys/mman.h>
#include <errno.h>
+#include <sysdep-cancel.h>
#include <hurd/hurd.h>
vm_offset_t offset;
kern_return_t err;
+ int cancel_oldtype;
if (flags & (MS_SYNC | MS_ASYNC) == (MS_SYNC | MS_ASYNC))
return __hurd_fail (EINVAL);
else
sync_len = len;
+ cancel_oldtype = LIBC_CANCEL_ASYNC();
err = __vm_object_sync (obj, cur - begin + offset, sync_len,
should_flush, 1, should_iosync);
+ LIBC_CANCEL_RESET (cancel_oldtype);
__mach_port_deallocate (__mach_task_self (), obj);
if (err)
#include <hurd.h>
#include <hurd/signal.h>
#include <hurd/msg.h>
+#include <sysdep-cancel.h>
/* Change the set of blocked signals to SET,
wait until a signal arrives, and restore the set of blocked signals. */
sigset_t newmask, oldmask, pending;
mach_port_t wait;
mach_msg_header_t msg;
+ int cancel_oldtype;
if (set != NULL)
/* Crash before locking. */
__msg_sig_post (_hurd_msgport, 0, 0, __mach_task_self ());
/* Wait for the signal thread's message. */
+
+ cancel_oldtype = LIBC_CANCEL_ASYNC();
__mach_msg (&msg, MACH_RCV_MSG, 0, sizeof (msg), wait,
MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
+ LIBC_CANCEL_RESET (cancel_oldtype);
__mach_port_destroy (__mach_task_self (), wait);
/* Restore the old mask and check for pending signals again. */
#include <hurd/msg.h>
#include <hurd/sigpreempt.h>
#include <assert.h>
+#include <sysdep-cancel.h>
/* Select any of pending signals from SET or wait for any to arrive. */
int
jmp_buf buf;
mach_port_t wait;
mach_msg_header_t msg;
+ int cancel_oldtype;
sighandler_t
preempt_fun (struct hurd_signal_preemptor *pe,
__sigemptyset (&mask);
ss = _hurd_self_sigstate ();
+ cancel_oldtype = LIBC_CANCEL_ASYNC();
_hurd_sigstate_lock (ss);
/* See if one of these signals is currently pending. */
all_done:
_hurd_sigstate_unlock (ss);
+ LIBC_CANCEL_RESET (cancel_oldtype);
__mach_port_destroy (__mach_task_self (), wait);
*sig = signo;
#include <sys/mman.h>
#include <errno.h>
#include <mach.h>
+#include <sysdep-cancel.h>
/* Some Mach variants have vm_msync and some don't. Those that have it
define the VM_SYNC_* bits when we include <mach/mach_types.h>. */
{
vm_sync_t sync_flags = 0;
kern_return_t err;
+ int cancel_oldtype;
if (flags & MS_SYNC)
sync_flags |= VM_SYNC_SYNCHRONOUS;
if (flags & MS_INVALIDATE)
sync_flags |= VM_SYNC_INVALIDATE;
- if (err = __vm_msync (__mach_task_self (),
- (vm_address_t) addr, (vm_size_t) len, sync_flags))
+ cancel_oldtype = LIBC_CANCEL_ASYNC();
+ err = __vm_msync (__mach_task_self (),
+ (vm_address_t) addr, (vm_size_t) len, sync_flags);
+ LIBC_CANCEL_RESET (cancel_oldtype);
+ if (err)
{
errno = err;
return -1;
#include <time.h>
#include <unistd.h>
#include <mach.h>
+#include <sysdep-cancel.h>
/* Make the process sleep for SECONDS seconds, or until a signal arrives
and is not ignored. The function returns the number of seconds less
{
time_t before, after;
mach_port_t recv;
+ int cancel_oldtype;
recv = __mach_reply_port ();
before = time_now ();
+ cancel_oldtype = LIBC_CANCEL_ASYNC();
(void) __mach_msg (NULL, MACH_RCV_MSG|MACH_RCV_TIMEOUT|MACH_RCV_INTERRUPT,
0, 0, recv, seconds * 1000, MACH_PORT_NULL);
+ LIBC_CANCEL_RESET (cancel_oldtype);
after = time_now ();
__mach_port_destroy (__mach_task_self (), recv);
#include <mach.h>
#include <sys/time.h>
#include <unistd.h>
+#include <sysdep-cancel.h>
/* Sleep USECONDS microseconds, or until a previously set timer goes off. */
int
usleep (useconds_t useconds)
{
mach_port_t recv;
+ int cancel_oldtype;
useconds_t useconds_up = useconds + 999;
if (useconds_up < useconds)
recv = __mach_reply_port ();
+ cancel_oldtype = LIBC_CANCEL_ASYNC();
(void) __mach_msg (NULL, MACH_RCV_MSG|MACH_RCV_TIMEOUT|MACH_RCV_INTERRUPT,
0, 0, recv, useconds_up / 1000, MACH_PORT_NULL);
+ LIBC_CANCEL_RESET (cancel_oldtype);
__mach_port_destroy (mach_task_self (), recv);
return 0;