blob: b9aeaabc343be8c6883a576af562768e97d16179 [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
Josh Gao16016df2016-11-07 18:27:16 -080032#include <sys/cdefs.h>
33#include <sys/types.h>
34
Raghu Gandham93e7b9f2014-06-25 17:58:48 -070035#include <asm/sigcontext.h>
Elliott Hughes5704c422016-01-25 18:06:24 -080036#include <bits/pthread_types.h>
Elliott Hughes23415fc2018-02-13 19:09:04 -080037#include <bits/signal_types.h>
Elliott Hughes5704c422016-01-25 18:06:24 -080038#include <bits/timespec.h>
Dan Albert75ef63d2014-11-21 00:18:07 -080039#include <limits.h>
Elliott Hughesc7e9b232013-10-16 22:27:54 -070040
Elliott Hughes26a8eb52014-09-12 20:04:40 -070041#include <sys/ucontext.h>
42#define __BIONIC_HAVE_UCONTEXT_T
43
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080044__BEGIN_DECLS
45
Greg Hackmann5375bf62016-02-29 12:35:33 -080046/* The kernel headers define SIG_DFL (0) and SIG_IGN (1) but not SIG_HOLD, since
47 * SIG_HOLD is only used by the deprecated SysV signal API.
48 */
Elliott Hughes5470c182016-07-22 11:36:17 -070049#define SIG_HOLD __BIONIC_CAST(reinterpret_cast, sighandler_t, 2)
Greg Hackmann5375bf62016-02-29 12:35:33 -080050
Elliott Hughes0990d4f2014-04-30 09:45:40 -070051/* We take a few real-time signals for ourselves. May as well use the same names as glibc. */
52#define SIGRTMIN (__libc_current_sigrtmin())
53#define SIGRTMAX (__libc_current_sigrtmax())
Elliott Hughes5470c182016-07-22 11:36:17 -070054int __libc_current_sigrtmin(void) __INTRODUCED_IN(21);
55int __libc_current_sigrtmax(void) __INTRODUCED_IN(21);
Elliott Hughes0990d4f2014-04-30 09:45:40 -070056
zijunzhao38c53442023-02-09 20:28:18 +000057extern const char* _Nonnull const sys_siglist[_NSIG];
58extern const char* _Nonnull const sys_signame[_NSIG]; /* BSD compatibility. */
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080059
Elliott Hughesa0cd9bc2014-03-07 15:41:25 -080060#define si_timerid si_tid /* glibc compatibility. */
61
zijunzhao38c53442023-02-09 20:28:18 +000062int sigaction(int __signal, const struct sigaction* _Nullable __new_action, struct sigaction* _Nullable __old_action);
63int sigaction64(int __signal, const struct sigaction64* _Nullable __new_action, struct sigaction64* _Nullable __old_action) __INTRODUCED_IN(28);
Elliott Hughesc7e9b232013-10-16 22:27:54 -070064
Elliott Hughesfaa74342017-08-11 17:34:44 -070065int siginterrupt(int __signal, int __flag);
Elliott Hughesc7e9b232013-10-16 22:27:54 -070066
zijunzhao38c53442023-02-09 20:28:18 +000067sighandler_t _Nonnull signal(int __signal, sighandler_t _Nullable __handler) __INTRODUCED_IN(21);
68int sigaddset(sigset_t* _Nonnull __set, int __signal) __INTRODUCED_IN(21);
69int sigaddset64(sigset64_t* _Nonnull __set, int __signal) __INTRODUCED_IN(28);
70int sigdelset(sigset_t* _Nonnull __set, int __signal) __INTRODUCED_IN(21);
71int sigdelset64(sigset64_t* _Nonnull __set, int __signal) __INTRODUCED_IN(28);
72int sigemptyset(sigset_t* _Nonnull __set) __INTRODUCED_IN(21);
73int sigemptyset64(sigset64_t* _Nonnull __set) __INTRODUCED_IN(28);
74int sigfillset(sigset_t* _Nonnull __set) __INTRODUCED_IN(21);
75int sigfillset64(sigset64_t* _Nonnull __set) __INTRODUCED_IN(28);
76int sigismember(const sigset_t* _Nonnull __set, int __signal) __INTRODUCED_IN(21);
77int sigismember64(const sigset64_t* _Nonnull __set, int __signal) __INTRODUCED_IN(28);
Elliott Hughesc7e9b232013-10-16 22:27:54 -070078
zijunzhao38c53442023-02-09 20:28:18 +000079int sigpending(sigset_t* _Nonnull __set);
80int sigpending64(sigset64_t* _Nonnull __set) __INTRODUCED_IN(28);
81int sigprocmask(int __how, const sigset_t* _Nullable __new_set, sigset_t* _Nullable __old_set);
82int sigprocmask64(int __how, const sigset64_t* _Nullable __new_set, sigset64_t* _Nullable __old_set) __INTRODUCED_IN(28);
83int sigsuspend(const sigset_t* _Nonnull __mask);
84int sigsuspend64(const sigset64_t* _Nonnull __mask) __INTRODUCED_IN(28);
85int sigwait(const sigset_t* _Nonnull __set, int* _Nonnull __signal);
86int sigwait64(const sigset64_t* _Nonnull __set, int* _Nonnull __signal) __INTRODUCED_IN(28);
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080087
Elliott Hughesfaa74342017-08-11 17:34:44 -070088int sighold(int __signal)
Josh Gao34c599a2016-04-29 13:45:25 -070089 __attribute__((deprecated("use sigprocmask() or pthread_sigmask() instead")))
Josh Gao2e8e5e62017-04-20 12:58:31 -070090 __INTRODUCED_IN(26);
Elliott Hughesfaa74342017-08-11 17:34:44 -070091int sigignore(int __signal)
Josh Gao2e8e5e62017-04-20 12:58:31 -070092 __attribute__((deprecated("use sigaction() instead"))) __INTRODUCED_IN(26);
Elliott Hughesfaa74342017-08-11 17:34:44 -070093int sigpause(int __signal)
Josh Gao2e8e5e62017-04-20 12:58:31 -070094 __attribute__((deprecated("use sigsuspend() instead"))) __INTRODUCED_IN(26);
Elliott Hughesfaa74342017-08-11 17:34:44 -070095int sigrelse(int __signal)
Josh Gao34c599a2016-04-29 13:45:25 -070096 __attribute__((deprecated("use sigprocmask() or pthread_sigmask() instead")))
Josh Gao2e8e5e62017-04-20 12:58:31 -070097 __INTRODUCED_IN(26);
zijunzhao38c53442023-02-09 20:28:18 +000098sighandler_t _Nonnull sigset(int __signal, sighandler_t _Nullable __handler)
Josh Gao2e8e5e62017-04-20 12:58:31 -070099 __attribute__((deprecated("use sigaction() instead"))) __INTRODUCED_IN(26);
Greg Hackmann5375bf62016-02-29 12:35:33 -0800100
Elliott Hughesfaa74342017-08-11 17:34:44 -0700101int raise(int __signal);
102int kill(pid_t __pid, int __signal);
103int killpg(int __pgrp, int __signal);
Elliott Hughesf106a392019-10-03 16:09:04 -0700104int tgkill(int __tgid, int __tid, int __signal);
Elliott Hughesc7e9b232013-10-16 22:27:54 -0700105
zijunzhao38c53442023-02-09 20:28:18 +0000106int sigaltstack(const stack_t* _Nullable __new_signal_stack, stack_t* _Nullable __old_signal_stack);
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800107
zijunzhao38c53442023-02-09 20:28:18 +0000108void psiginfo(const siginfo_t* _Nonnull __info, const char* _Nullable __msg) __INTRODUCED_IN(17);
109void psignal(int __signal, const char* _Nullable __msg) __INTRODUCED_IN(17);
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800110
Elliott Hughesfaa74342017-08-11 17:34:44 -0700111int pthread_kill(pthread_t __pthread, int __signal);
Josh Gao726b63f2018-08-27 16:00:58 -0700112#if defined(__USE_GNU)
Elliott Hughesc0f46562018-11-09 15:38:52 -0800113int pthread_sigqueue(pthread_t __pthread, int __signal, const union sigval __value) __INTRODUCED_IN(29);
Josh Gao726b63f2018-08-27 16:00:58 -0700114#endif
115
zijunzhao38c53442023-02-09 20:28:18 +0000116int pthread_sigmask(int __how, const sigset_t* _Nullable __new_set, sigset_t* _Nullable __old_set);
117int pthread_sigmask64(int __how, const sigset64_t* _Nullable __new_set, sigset64_t* _Nullable __old_set) __INTRODUCED_IN(28);
Dan Albert75ef63d2014-11-21 00:18:07 -0800118
Elliott Hughesfaa74342017-08-11 17:34:44 -0700119int sigqueue(pid_t __pid, int __signal, const union sigval __value) __INTRODUCED_IN(23);
zijunzhao38c53442023-02-09 20:28:18 +0000120int sigtimedwait(const sigset_t* _Nonnull __set, siginfo_t* _Nullable __info, const struct timespec* _Nullable __timeout) __INTRODUCED_IN(23);
121int sigtimedwait64(const sigset64_t* _Nonnull __set, siginfo_t* _Nullable __info, const struct timespec* _Nullable __timeout) __INTRODUCED_IN(28);
122int sigwaitinfo(const sigset_t* _Nonnull __set, siginfo_t* _Nullable __info) __INTRODUCED_IN(23);
123int sigwaitinfo64(const sigset64_t* _Nonnull __set, siginfo_t* _Nullable __info) __INTRODUCED_IN(28);
Yabin Cui63481602014-12-01 17:41:04 -0800124
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800125__END_DECLS
126
Elliott Hughes3e235912018-02-01 14:21:51 -0800127#endif