Home | History | Annotate | Download | only in include
      1 /*
      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  */
     28 
     29 #ifndef _SIGNAL_H_
     30 #define _SIGNAL_H_
     31 
     32 #include <sys/cdefs.h>
     33 #include <sys/types.h>
     34 
     35 #include <asm/sigcontext.h>
     36 #include <bits/pthread_types.h>
     37 #include <bits/signal_types.h>
     38 #include <bits/timespec.h>
     39 #include <limits.h>
     40 
     41 #include <sys/ucontext.h>
     42 #define __BIONIC_HAVE_UCONTEXT_T
     43 
     44 __BEGIN_DECLS
     45 
     46 /* 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  */
     49 #define SIG_HOLD __BIONIC_CAST(reinterpret_cast, sighandler_t, 2)
     50 
     51 /* 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())
     54 int __libc_current_sigrtmin(void) __INTRODUCED_IN(21);
     55 int __libc_current_sigrtmax(void) __INTRODUCED_IN(21);
     56 
     57 extern const char* const sys_siglist[_NSIG];
     58 extern const char* const sys_signame[_NSIG]; /* BSD compatibility. */
     59 
     60 #define si_timerid si_tid /* glibc compatibility. */
     61 
     62 int sigaction(int __signal, const struct sigaction* __new_action, struct sigaction* __old_action);
     63 int sigaction64(int __signal, const struct sigaction64* __new_action, struct sigaction64* __old_action) __INTRODUCED_IN(28);
     64 
     65 int siginterrupt(int __signal, int __flag);
     66 
     67 #if __ANDROID_API__ >= __ANDROID_API_L__
     68 sighandler_t signal(int __signal, sighandler_t __handler) __INTRODUCED_IN(21);
     69 int sigaddset(sigset_t* __set, int __signal) __INTRODUCED_IN(21);
     70 int sigaddset64(sigset64_t* __set, int __signal) __INTRODUCED_IN(28);
     71 int sigdelset(sigset_t* __set, int __signal) __INTRODUCED_IN(21);
     72 int sigdelset64(sigset64_t* __set, int __signal) __INTRODUCED_IN(28);
     73 int sigemptyset(sigset_t* __set) __INTRODUCED_IN(21);
     74 int sigemptyset64(sigset64_t* __set) __INTRODUCED_IN(28);
     75 int sigfillset(sigset_t* __set) __INTRODUCED_IN(21);
     76 int sigfillset64(sigset64_t* __set) __INTRODUCED_IN(28);
     77 int sigismember(const sigset_t* __set, int __signal) __INTRODUCED_IN(21);
     78 int sigismember64(const sigset64_t* __set, int __signal) __INTRODUCED_IN(28);
     79 #else
     80 // Implemented as static inlines before 21.
     81 #endif
     82 
     83 int sigpending(sigset_t* __set);
     84 int sigpending64(sigset64_t* __set) __INTRODUCED_IN(28);
     85 int sigprocmask(int __how, const sigset_t* __new_set, sigset_t* __old_set);
     86 int sigprocmask64(int __how, const sigset64_t* __new_set, sigset64_t* __old_set) __INTRODUCED_IN(28);
     87 int sigsuspend(const sigset_t* __mask);
     88 int sigsuspend64(const sigset64_t* __mask) __INTRODUCED_IN(28);
     89 int sigwait(const sigset_t* __set, int* __signal);
     90 int sigwait64(const sigset64_t* __set, int* __signal) __INTRODUCED_IN(28);
     91 
     92 int sighold(int __signal)
     93   __attribute__((deprecated("use sigprocmask() or pthread_sigmask() instead")))
     94   __INTRODUCED_IN(26);
     95 int sigignore(int __signal)
     96   __attribute__((deprecated("use sigaction() instead"))) __INTRODUCED_IN(26);
     97 int sigpause(int __signal)
     98   __attribute__((deprecated("use sigsuspend() instead"))) __INTRODUCED_IN(26);
     99 int sigrelse(int __signal)
    100   __attribute__((deprecated("use sigprocmask() or pthread_sigmask() instead")))
    101   __INTRODUCED_IN(26);
    102 sighandler_t sigset(int __signal, sighandler_t __handler)
    103   __attribute__((deprecated("use sigaction() instead"))) __INTRODUCED_IN(26);
    104 
    105 int raise(int __signal);
    106 int kill(pid_t __pid, int __signal);
    107 int killpg(int __pgrp, int __signal);
    108 int tgkill(int __tgid, int __tid, int __signal) __INTRODUCED_IN_32(16);
    109 
    110 int sigaltstack(const stack_t* __new_signal_stack, stack_t* __old_signal_stack);
    111 
    112 void psiginfo(const siginfo_t* __info, const char* __msg) __INTRODUCED_IN(17);
    113 void psignal(int __signal, const char* __msg) __INTRODUCED_IN(17);
    114 
    115 int pthread_kill(pthread_t __pthread, int __signal);
    116 int pthread_sigmask(int __how, const sigset_t* __new_set, sigset_t* __old_set);
    117 int pthread_sigmask64(int __how, const sigset64_t* __new_set, sigset64_t* __old_set) __INTRODUCED_IN(28);
    118 
    119 int sigqueue(pid_t __pid, int __signal, const union sigval __value) __INTRODUCED_IN(23);
    120 int sigtimedwait(const sigset_t* __set, siginfo_t* __info, const struct timespec* __timeout) __INTRODUCED_IN(23);
    121 int sigtimedwait64(const sigset64_t* __set, siginfo_t* __info, const struct timespec* __timeout) __INTRODUCED_IN(28);
    122 int sigwaitinfo(const sigset_t* __set, siginfo_t* __info) __INTRODUCED_IN(23);
    123 int sigwaitinfo64(const sigset64_t* __set, siginfo_t* __info) __INTRODUCED_IN(28);
    124 
    125 __END_DECLS
    126 
    127 #include <android/legacy_signal_inlines.h>
    128 
    129 #endif
    130