OSDN Git Service

no need for hidden __sigpause, use an internal static function
[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, write to the Free
17    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18    02111-1307 USA.  */
19
20 #define __UCLIBC_HIDE_DEPRECATED__
21 /* psm: need the BSD version of sigpause here */
22 #include <errno.h>
23 #define __FAVOR_BSD
24 #include <signal.h>
25 #define __need_NULL
26 #include <stddef.h>
27 #ifdef __UCLIBC_HAS_THREADS_NATIVE__
28 #include <sysdep-cancel.h>
29 #endif
30
31 #include "sigset-cvt-mask.h"
32
33 /* Set the mask of blocked signals to MASK,
34    wait for a signal to arrive, and then restore the mask.  */
35 static int __internal_sigpause (int sig_or_mask, int is_sig)
36 {
37   sigset_t set;
38
39   if (is_sig)
40     {
41       /* The modern X/Open implementation is requested.  */
42       sigprocmask (SIG_BLOCK, NULL, &set);
43       /* Bound-check sig_or_mask, remove it from the set.  */
44       if (sigdelset (&set, sig_or_mask) < 0)
45         return -1;
46     }
47   else
48     sigset_set_old_mask (&set, sig_or_mask);
49
50   /* Note the sigpause() is a cancellation point.  But since we call
51      sigsuspend() which itself is a cancellation point we do not have
52      to do anything here.  */
53   return sigsuspend (&set);
54 }
55 strong_alias(__internal_sigpause,__sigpause)
56
57 #undef sigpause
58
59 /* We have to provide a default version of this function since the
60    standards demand it.  The version which is a bit more reasonable is
61    the BSD version.  So make this the default.  */
62 int sigpause (int mask)
63 {
64 #ifdef __UCLIBC_HAS_THREADS_NATIVE__
65   if (SINGLE_THREAD_P)
66     return __internal_sigpause (mask, 0);
67
68   int oldtype = LIBC_CANCEL_ASYNC ();
69
70   int result = __internal_sigpause (mask, 0);
71
72   LIBC_CANCEL_RESET (oldtype);
73
74   return result;
75 #else
76   return __internal_sigpause (mask, 0);
77 #endif
78 }