Upload Tizen:Base source
[external/eglibc.git] / sysdeps / unix / sysv / linux / sigpending.c
1 /* Copyright (C) 1997,1998,1999,2000,2003,2006
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 #include <errno.h>
21 #include <signal.h>
22 #include <unistd.h>
23
24 #include <sysdep.h>
25 #include <sys/syscall.h>
26 #include <bp-checks.h>
27
28 #include <kernel-features.h>
29
30
31 /* The variable is shared between all wrappers around signal handling
32    functions which have RT equivalents.  The definition is in sigaction.c.  */
33 extern int __libc_missing_rt_sigs;
34
35
36 /* Change the set of blocked signals to SET,
37    wait until a signal arrives, and restore the set of blocked signals.  */
38 int
39 sigpending (set)
40      sigset_t *set;
41 {
42 #if __ASSUME_REALTIME_SIGNALS > 0
43   return INLINE_SYSCALL (rt_sigpending, 2, CHECK_SIGSET (set), _NSIG / 8);
44 #else
45 # ifdef __NR_rt_sigpending
46   /* First try the RT signals.  */
47   if (!__libc_missing_rt_sigs)
48     {
49       /* XXX The size argument hopefully will have to be changed to the
50          real size of the user-level sigset_t.  */
51       int saved_errno = errno;
52       int result = INLINE_SYSCALL (rt_sigpending, 2, CHECK_SIGSET (set), _NSIG / 8);
53
54       if (result >= 0 || errno != ENOSYS)
55         return result;
56
57       __set_errno (saved_errno);
58       __libc_missing_rt_sigs = 1;
59     }
60 # endif
61
62   return INLINE_SYSCALL (sigpending, 1, CHECK_SIGSET (set));
63 #endif
64 }