OSDN Git Service

test: NPTL: sync WRITE_BUFFER_SIZE with glibc test
[uclinux-h8/uClibc.git] / libc / signal / sigpause.c
1 /* Copyright (C) 1991,92,94-98,2000,2002,2003,2004
2    Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library; if not, see
17    <http://www.gnu.org/licenses/>.  */
18
19 #include <signal.h>
20 #define __need_NULL
21 #include <stddef.h>
22 #include <cancel.h>
23
24 #include "sigset-cvt-mask.h"
25
26 /* Set the mask of blocked signals to MASK,
27    wait for a signal to arrive, and then restore the mask.  */
28 static int __sigpause (int sig_or_mask, int is_sig)
29 {
30   sigset_t set;
31
32   if (is_sig)
33     {
34       /* The modern X/Open implementation is requested.  */
35       sigprocmask (SIG_BLOCK, NULL, &set);
36       /* Bound-check sig_or_mask, remove it from the set.  */
37       if (sigdelset (&set, sig_or_mask) < 0)
38         return -1;
39     }
40   else
41     sigset_set_old_mask (&set, sig_or_mask);
42
43   /* Note the sigpause() is a cancellation point.  But since we call
44      sigsuspend() which itself is a cancellation point we do not have
45      to do anything here.  */
46   /* uClibc note: not true on uClibc, we call the non-cancellable version */
47   return __NC(sigsuspend)(&set);
48 }
49
50 int __bsd_sigpause(int mask);
51 int __bsd_sigpause(int mask)
52 {
53         return __sigpause(mask, 0);
54 }
55
56 /* We have to provide a default version of this function since the
57    standards demand it.  The version which is a bit more reasonable is
58    the BSD version.  So make this the default.  */
59 static int __NC(sigpause)(int sig)
60 {
61         return __sigpause(sig, 1);
62 }
63 CANCELLABLE_SYSCALL(int, sigpause, (int sig), (sig))