|
| 1 | +/* |
| 2 | + * Copyright (c) 2018 Intel Corporation |
| 3 | + * |
| 4 | + * SPDX-License-Identifier: Apache-2.0 |
| 5 | + */ |
| 6 | +#ifndef ZEPHYR_INCLUDE_POSIX_SIGNAL_H_ |
| 7 | +#define ZEPHYR_INCLUDE_POSIX_SIGNAL_H_ |
| 8 | + |
| 9 | +/* include posix_types.h before posix_features.h (here) to avoid build errors against newlib */ |
| 10 | +#include <zephyr/posix/posix_types.h> |
| 11 | +#include "posix_features.h" |
| 12 | + |
| 13 | +#ifdef __cplusplus |
| 14 | +extern "C" { |
| 15 | +#endif |
| 16 | + |
| 17 | +#define SIGHUP 1 /**< Hangup */ |
| 18 | +#define SIGINT 2 /**< Interrupt */ |
| 19 | +#define SIGQUIT 3 /**< Quit */ |
| 20 | +#define SIGILL 4 /**< Illegal instruction */ |
| 21 | +#define SIGTRAP 5 /**< Trace/breakpoint trap */ |
| 22 | +#define SIGABRT 6 /**< Aborted */ |
| 23 | +#define SIGBUS 7 /**< Bus error */ |
| 24 | +#define SIGFPE 8 /**< Arithmetic exception */ |
| 25 | +#define SIGKILL 9 /**< Killed */ |
| 26 | +#define SIGUSR1 10 /**< User-defined signal 1 */ |
| 27 | +#define SIGSEGV 11 /**< Invalid memory reference */ |
| 28 | +#define SIGUSR2 12 /**< User-defined signal 2 */ |
| 29 | +#define SIGPIPE 13 /**< Broken pipe */ |
| 30 | +#define SIGALRM 14 /**< Alarm clock */ |
| 31 | +#define SIGTERM 15 /**< Terminated */ |
| 32 | +/* 16 not used */ |
| 33 | +#define SIGCHLD 17 /**< Child status changed */ |
| 34 | +#define SIGCONT 18 /**< Continued */ |
| 35 | +#define SIGSTOP 19 /**< Stop executing */ |
| 36 | +#define SIGTSTP 20 /**< Stopped */ |
| 37 | +#define SIGTTIN 21 /**< Stopped (read) */ |
| 38 | +#define SIGTTOU 22 /**< Stopped (write) */ |
| 39 | +#define SIGURG 23 /**< Urgent I/O condition */ |
| 40 | +#define SIGXCPU 24 /**< CPU time limit exceeded */ |
| 41 | +#define SIGXFSZ 25 /**< File size limit exceeded */ |
| 42 | +#define SIGVTALRM 26 /**< Virtual timer expired */ |
| 43 | +#define SIGPROF 27 /**< Profiling timer expired */ |
| 44 | +/* 28 not used */ |
| 45 | +#define SIGPOLL 29 /**< Pollable event occurred */ |
| 46 | +/* 30 not used */ |
| 47 | +#define SIGSYS 31 /**< Bad system call */ |
| 48 | + |
| 49 | +#define SIGRTMIN 32 |
| 50 | +#if defined(CONFIG_POSIX_REALTIME_SIGNALS) || defined(__DOXYGEN__) |
| 51 | +BUILD_ASSERT(CONFIG_POSIX_RTSIG_MAX >= 0); |
| 52 | +#define SIGRTMAX (SIGRTMIN + CONFIG_POSIX_RTSIG_MAX) |
| 53 | +#else |
| 54 | +#define SIGRTMAX SIGRTMIN |
| 55 | +#endif |
| 56 | + |
| 57 | +typedef struct { |
| 58 | + unsigned long sig[DIV_ROUND_UP(SIGRTMAX + 1, BITS_PER_LONG)]; |
| 59 | +} sigset_t; |
| 60 | + |
| 61 | +#ifndef SIGEV_NONE |
| 62 | +#define SIGEV_NONE 1 |
| 63 | +#endif |
| 64 | + |
| 65 | +#ifndef SIGEV_SIGNAL |
| 66 | +#define SIGEV_SIGNAL 2 |
| 67 | +#endif |
| 68 | + |
| 69 | +#ifndef SIGEV_THREAD |
| 70 | +#define SIGEV_THREAD 3 |
| 71 | +#endif |
| 72 | + |
| 73 | +#ifndef SIG_BLOCK |
| 74 | +#define SIG_BLOCK 0 |
| 75 | +#endif |
| 76 | +#ifndef SIG_SETMASK |
| 77 | +#define SIG_SETMASK 1 |
| 78 | +#endif |
| 79 | +#ifndef SIG_UNBLOCK |
| 80 | +#define SIG_UNBLOCK 2 |
| 81 | +#endif |
| 82 | + |
| 83 | +#define SIG_DFL ((void *)0) |
| 84 | +#define SIG_IGN ((void *)1) |
| 85 | +#define SIG_ERR ((void *)-1) |
| 86 | + |
| 87 | +#define SI_USER 1 |
| 88 | +#define SI_QUEUE 2 |
| 89 | +#define SI_TIMER 3 |
| 90 | +#define SI_ASYNCIO 4 |
| 91 | +#define SI_MESGQ 5 |
| 92 | + |
| 93 | +typedef int sig_atomic_t; /* Atomic entity type (ANSI) */ |
| 94 | + |
| 95 | +union sigval { |
| 96 | + void *sival_ptr; |
| 97 | + int sival_int; |
| 98 | +}; |
| 99 | + |
| 100 | +struct sigevent { |
| 101 | + void (*sigev_notify_function)(union sigval val); |
| 102 | + pthread_attr_t *sigev_notify_attributes; |
| 103 | + union sigval sigev_value; |
| 104 | + int sigev_notify; |
| 105 | + int sigev_signo; |
| 106 | +}; |
| 107 | + |
| 108 | +typedef struct { |
| 109 | + int si_signo; |
| 110 | + int si_code; |
| 111 | + union sigval si_value; |
| 112 | +} siginfo_t; |
| 113 | + |
| 114 | +struct sigaction { |
| 115 | + void (*sa_handler)(int signno); |
| 116 | + sigset_t sa_mask; |
| 117 | + int sa_flags; |
| 118 | + void (*sa_sigaction)(int signo, siginfo_t *info, void *context); |
| 119 | +}; |
| 120 | + |
| 121 | +typedef void (*sighandler_t)(int signo); |
| 122 | + |
| 123 | +unsigned int alarm(unsigned int seconds); |
| 124 | +int kill(pid_t pid, int sig); |
| 125 | +int pause(void); |
| 126 | +int raise(int signo); |
| 127 | +TOOLCHAIN_DISABLE_WARNING(TOOLCHAIN_WARNING_SHADOW); |
| 128 | +int sigaction(int sig, const struct sigaction *ZRESTRICT act, struct sigaction *ZRESTRICT oact); |
| 129 | +TOOLCHAIN_ENABLE_WARNING(TOOLCHAIN_WARNING_SHADOW); |
| 130 | +int sigpending(sigset_t *set); |
| 131 | +int sigsuspend(const sigset_t *sigmask); |
| 132 | +int sigwait(const sigset_t *ZRESTRICT set, int *ZRESTRICT signo); |
| 133 | +char *strsignal(int signum); |
| 134 | +int sigemptyset(sigset_t *set); |
| 135 | +int sigfillset(sigset_t *set); |
| 136 | +int sigaddset(sigset_t *set, int signo); |
| 137 | +int sigdelset(sigset_t *set, int signo); |
| 138 | +int sigismember(const sigset_t *set, int signo); |
| 139 | +sighandler_t signal(int signo, sighandler_t handler); |
| 140 | +int sigprocmask(int how, const sigset_t *ZRESTRICT set, sigset_t *ZRESTRICT oset); |
| 141 | + |
| 142 | +int pthread_sigmask(int how, const sigset_t *ZRESTRICT set, sigset_t *ZRESTRICT oset); |
| 143 | + |
| 144 | +#ifdef __cplusplus |
| 145 | +} |
| 146 | +#endif |
| 147 | + |
| 148 | +#endif /* ZEPHYR_INCLUDE_POSIX_SIGNAL_H_ */ |
0 commit comments