signal.h 2.5 KB
Newer Older
R
Rich Felker 已提交
1 2 3 4 5 6 7
#ifndef _SIGNAL_H
#define _SIGNAL_H

#ifdef __cplusplus
extern "C" {
#endif

8 9 10
#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE)

11 12 13 14
#ifdef _GNU_SOURCE
#define __siginfo siginfo
#endif

R
Rich Felker 已提交
15 16 17 18 19
#define __NEED_size_t
#define __NEED_pid_t
#define __NEED_uid_t
#define __NEED_struct_timespec
#define __NEED_pthread_t
R
Rich Felker 已提交
20
#define __NEED_pthread_attr_t
R
Rich Felker 已提交
21 22 23 24 25 26 27
#define __NEED_time_t
#define __NEED_clock_t
#define __NEED_sigset_t
#define __NEED_siginfo_t

#include <bits/alltypes.h>

R
Rich Felker 已提交
28
struct sigaction {
R
Rich Felker 已提交
29 30 31 32 33 34 35 36 37 38 39
	union {
		void (*sa_handler)(int);
		void (*sa_sigaction)(int, siginfo_t *, void *);
	} __sa_handler;
	sigset_t sa_mask;
	int sa_flags;
	void (*__sa_restorer)(void);	
};
#define sa_handler   __sa_handler.sa_handler
#define sa_sigaction __sa_handler.sa_sigaction

R
Rich Felker 已提交
40
typedef struct {
R
Rich Felker 已提交
41 42 43 44 45
	void *ss_sp;
	int ss_flags;
	size_t ss_size;
} stack_t;

R
Rich Felker 已提交
46
union sigval {
R
Rich Felker 已提交
47 48 49 50
	int sival_int;
	void *sival_ptr;
};

R
Rich Felker 已提交
51 52 53 54 55 56
struct sigevent {
	union sigval sigev_value;
	int sigev_signo;
	int sigev_notify;
	void (*sigev_notify_function)(union sigval);
	pthread_attr_t *sigev_notify_attributes;
57
	char __pad[56-3*sizeof(long)];
R
Rich Felker 已提交
58 59 60 61 62 63
};

#define SIGEV_SIGNAL 0
#define SIGEV_NONE 1
#define SIGEV_THREAD 2

R
Rich Felker 已提交
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
int __libc_current_sigrtmin(void);
int __libc_current_sigrtmax(void);

#define SIGRTMIN  (__libc_current_sigrtmin())
#define SIGRTMAX  (__libc_current_sigrtmax())

int kill(pid_t, int);

int sigemptyset(sigset_t *);
int sigfillset(sigset_t *);
int sigaddset(sigset_t *, int);
int sigdelset(sigset_t *, int);
int sigismember(const sigset_t *, int);

int sigprocmask(int, const sigset_t *, sigset_t *);
int sigsuspend(const sigset_t *);
int sigaction(int, const struct sigaction *, struct sigaction *);
int sigpending(sigset_t *);
int sigwait(const sigset_t *, int *);
int sigwaitinfo(const sigset_t *, siginfo_t *);
int sigtimedwait(const sigset_t *, siginfo_t *, const struct timespec *);
int sigqueue(pid_t, int, const union sigval);

87 88
int pthread_sigmask(int, const sigset_t *, sigset_t *);
int pthread_kill(pthread_t, int);
R
Rich Felker 已提交
89

90
#endif
R
Rich Felker 已提交
91

92 93 94
#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE)
int killpg(pid_t, int);
int sigaltstack(const stack_t *, stack_t *);
R
Rich Felker 已提交
95 96
int sighold(int);
int sigignore(int);
97 98 99
int siginterrupt(int, int);
int sigpause(int);
int sigrelse(int);
R
Rich Felker 已提交
100
void (*sigset(int, void (*)(int)))(int);
101
#endif
R
Rich Felker 已提交
102 103

#ifdef _GNU_SOURCE
104
typedef void (*sighandler_t)(int);
105
void (*bsd_signal(int, void (*)(int)))(int);
106
#define SA_NOMASK SA_NODEFER
R
Rich Felker 已提交
107 108
#endif

109 110
#include <bits/signal.h>

111 112 113 114 115
typedef int sig_atomic_t;

void (*signal(int, void (*)(int)))(int);
int raise(int);

R
Rich Felker 已提交
116 117 118 119 120
#ifdef __cplusplus
}
#endif

#endif