blob: 5e7416165e421ef161bd3035e6153a9309b61720 [file] [log] [blame]
The Android Open Source Project1dc9e472009-03-03 19:28:35 -08001/*
2 * Copyright (C) 2008 The Android Open Source Project
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in
12 * the documentation and/or other materials provided with the
13 * distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
Elliott Hughesc7e9b232013-10-16 22:27:54 -070028
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080029#ifndef _SIGNAL_H_
30#define _SIGNAL_H_
31
Elliott Hughesda73f652012-11-30 16:40:55 -080032#include <errno.h>
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080033#include <sys/cdefs.h>
David 'Digit' Turnerc1b44ec2012-10-17 19:10:11 +020034#include <limits.h> /* For LONG_BIT */
35#include <string.h> /* For memset() */
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080036#include <sys/types.h>
Elliott Hughesc7e9b232013-10-16 22:27:54 -070037
38#if defined(__LP64__)
39/* For 64-bit, the kernel's struct sigaction doesn't match the POSIX one,
40 * so we need to expose our own and translate behind the scenes. */
41# define sigaction __kernel_sigaction
42# include <asm/signal.h>
43# undef sigaction
44#else
45/* For 32-bit, we're stuck with the definitions we already shipped,
46 * even though they contain a sigset_t that's too small. */
47# include <asm/signal.h>
48#endif
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080049
David 'Digit' Turnerc1b44ec2012-10-17 19:10:11 +020050#define __ARCH_SI_UID_T __kernel_uid32_t
51#include <asm/siginfo.h>
52#undef __ARCH_SI_UID_T
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080053
54__BEGIN_DECLS
55
David 'Digit' Turnerc124baa2012-07-12 19:06:15 +020056typedef int sig_atomic_t;
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080057
David 'Digit' Turnerc1b44ec2012-10-17 19:10:11 +020058/* _NSIG is used by the SIGRTMAX definition under <asm/signal.h>, however
59 * its definition is part of a #if __KERNEL__ .. #endif block in the original
60 * kernel headers and is thus not part of our cleaned-up versions.
61 *
62 * Looking at the current kernel sources, it is defined as 64 for all
63 * architectures except for the 'mips' one which set it to 128.
64 */
65#ifndef _NSIG
66# define _NSIG 64
67#endif
68
Elliott Hughesda73f652012-11-30 16:40:55 -080069extern const char* const sys_siglist[];
70extern const char* const sys_signame[];
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080071
Elliott Hughesc7e9b232013-10-16 22:27:54 -070072typedef __sighandler_t sig_t; /* BSD compatibility. */
73typedef __sighandler_t sighandler_t; /* glibc compatibility. */
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080074
Elliott Hughesc7e9b232013-10-16 22:27:54 -070075#if __LP64__
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080076
Elliott Hughesc7e9b232013-10-16 22:27:54 -070077struct sigaction {
78 unsigned int sa_flags;
79 union {
80 sighandler_t sa_handler;
81 void (*sa_sigaction)(int, struct siginfo*, void*);
82 };
83 sigset_t sa_mask;
84 void (*sa_restorer)(void);
85};
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080086
Elliott Hughesc7e9b232013-10-16 22:27:54 -070087#endif
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080088
Elliott Hughes40d105c2013-10-16 12:53:58 -070089extern int sigaction(int, const struct sigaction*, struct sigaction*);
Elliott Hughesc7e9b232013-10-16 22:27:54 -070090
91extern sighandler_t signal(int, sighandler_t);
92extern sighandler_t bsd_signal(int, sighandler_t);
93extern sighandler_t sysv_signal(int, sighandler_t);
94
Elliott Hughes40d105c2013-10-16 12:53:58 -070095extern int siginterrupt(int, int);
Elliott Hughesc7e9b232013-10-16 22:27:54 -070096
97extern int sigaddset(sigset_t*, int);
98extern int sigdelset(sigset_t*, int);
99extern int sigemptyset(sigset_t*);
100extern int sigfillset(sigset_t*);
101extern int sigismember(const sigset_t*, int);
102
Elliott Hughes40d105c2013-10-16 12:53:58 -0700103extern int sigpending(sigset_t*) __nonnull((1));
104extern int sigprocmask(int, const sigset_t*, sigset_t*);
105extern int sigsuspend(const sigset_t*) __nonnull((1));
106extern int sigwait(const sigset_t*, int*) __nonnull((1, 2));
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800107
108extern int raise(int);
109extern int kill(pid_t, int);
Elliott Hughes40d105c2013-10-16 12:53:58 -0700110extern int killpg(int, int);
Elliott Hughesc7e9b232013-10-16 22:27:54 -0700111
Elliott Hughes40d105c2013-10-16 12:53:58 -0700112extern int sigaltstack(const stack_t*, stack_t*);
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800113
Elliott Hughes40d105c2013-10-16 12:53:58 -0700114extern void psiginfo(const siginfo_t*, const char*);
115extern void psignal(int, const char*);
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800116
117__END_DECLS
118
119#endif /* _SIGNAL_H_ */