1 /* Copyright (C) 1997-2016 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
24 #include <nptl/pthreadP.h>
25 #include <sysdep-cancel.h>
26 #include <sys/syscall.h>
28 #ifdef __NR_rt_sigtimedwait
30 /* Return any pending signal or wait for one for the given time. */
32 do_sigwait (const sigset_t
*set
, int *sig
)
39 && (__builtin_expect (__sigismember (set
, SIGCANCEL
), 0)
41 || __builtin_expect (__sigismember (set
, SIGSETXID
), 0)
45 /* Create a temporary mask without the bit for SIGCANCEL set. */
46 // We are not copying more than we have to.
47 memcpy (&tmpset
, set
, _NSIG
/ 8);
48 __sigdelset (&tmpset
, SIGCANCEL
);
50 __sigdelset (&tmpset
, SIGSETXID
);
56 /* XXX The size argument hopefully will have to be changed to the
57 real size of the user-level sigset_t. */
58 #ifdef INTERNAL_SYSCALL
59 INTERNAL_SYSCALL_DECL (err
);
61 ret
= INTERNAL_SYSCALL (rt_sigtimedwait
, err
, 4, set
,
62 NULL
, NULL
, _NSIG
/ 8);
63 while (INTERNAL_SYSCALL_ERROR_P (ret
, err
)
64 && INTERNAL_SYSCALL_ERRNO (ret
, err
) == EINTR
);
65 if (! INTERNAL_SYSCALL_ERROR_P (ret
, err
))
71 ret
= INTERNAL_SYSCALL_ERRNO (ret
, err
);
74 ret
= INLINE_SYSCALL (rt_sigtimedwait
, 4, set
, NULL
, NULL
, _NSIG
/ 8);
75 while (ret
== -1 && errno
== EINTR
);
89 __sigwait (const sigset_t
*set
, int *sig
)
92 return do_sigwait (set
, sig
);
94 int oldtype
= LIBC_CANCEL_ASYNC ();
96 int result
= do_sigwait (set
, sig
);
98 LIBC_CANCEL_RESET (oldtype
);
102 libc_hidden_def (__sigwait
)
103 weak_alias (__sigwait
, sigwait
)
105 # include <sysdeps/posix/sigwait.c>
107 strong_alias (__sigwait
, __libc_sigwait
)