xref: /haiku/headers/private/libroot/signal_private.h (revision f2b4344867e97c3f4e742a1b4a15e6879644601a)
1 /*
2  * Copyright 2011, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _LIBROOT_SIGNAL_PRIVATE_H
6 #define _LIBROOT_SIGNAL_PRIVATE_H
7 
8 
9 #include <signal.h>
10 #include <sys/cdefs.h>
11 
12 #include <signal_defs.h>
13 
14 
15 #define MAX_SIGNAL_NUMBER_BEOS		29
16 
17 
18 typedef __haiku_int32 sigset_t_beos;
19 
20 struct sigaction_beos {
21 	__sighandler_t	sa_handler;
22 	sigset_t_beos	sa_mask;
23 	int				sa_flags;
24 	void*			sa_userdata;
25 };
26 
27 
28 static inline sigset_t_beos
29 to_beos_sigset(sigset_t set)
30 {
31 	// restrict to BeOS signals
32 	sigset_t_beos beosSet = (sigset_t_beos)(set
33 		& SIGNAL_RANGE_TO_MASK(1, MAX_SIGNAL_NUMBER_BEOS));
34 
35 	// if SIGBUS is set, set SIGSEGV, since they have the same number in BeOS
36 	if ((set & SIGNAL_TO_MASK(SIGBUS)) != 0)
37 		beosSet |= SIGNAL_TO_MASK(SIGSEGV);
38 
39 	return beosSet;
40 }
41 
42 
43 static inline sigset_t
44 from_beos_sigset(sigset_t_beos beosSet)
45 {
46 	sigset_t set = beosSet;
47 
48 	// if SIGSEGV is set, set SIGBUS, since they have the same number in BeOS
49 	if ((set & SIGNAL_TO_MASK(SIGSEGV)) != 0)
50 		set |= SIGNAL_TO_MASK(SIGBUS);
51 
52 	return set;
53 }
54 
55 
56 __BEGIN_DECLS
57 
58 
59 __sighandler_t __signal_beos(int signal, __sighandler_t signalHandler);
60 __sighandler_t __signal(int signal, __sighandler_t signalHandler);
61 
62 int __sigaction_beos(int signal, const struct sigaction_beos* beosAction,
63 	struct sigaction_beos* beosOldAction);
64 int __sigaction(int signal, const struct sigaction* action,
65 	struct sigaction* oldAction);
66 
67 __sighandler_t __sigset_beos(int signal, __sighandler_t signalHandler);
68 __sighandler_t __sigset(int signal, __sighandler_t signalHandler);
69 
70 int __sigignore_beos(int signal);
71 int __sigignore(int signal);
72 
73 int __sighold_beos(int signal);
74 int __sighold(int signal);
75 
76 int __sigrelse_beos(int signal);
77 int __sigrelse(int signal);
78 
79 int __sigpause_beos(int signal);
80 int __sigpause(int signal);
81 
82 int __siginterrupt_beos(int signal, int flag);
83 int __siginterrupt(int signal, int flag);
84 
85 int __pthread_sigmask_beos(int how, const sigset_t_beos* beosSet,
86 	sigset_t_beos* beosOldSet);
87 int __sigprocmask_beos(int how, const sigset_t_beos* beosSet,
88 	sigset_t_beos* beosOldSet);
89 
90 int __pthread_sigmask(int how, const sigset_t* set, sigset_t* oldSet);
91 int __sigprocmask(int how, const sigset_t* set, sigset_t* oldSet);
92 
93 int __sigpending_beos(sigset_t_beos* beosSet);
94 int __sigpending(sigset_t* set);
95 
96 int __sigsuspend_beos(const sigset_t_beos* beosMask);
97 int __sigsuspend(const sigset_t* mask);
98 
99 int __sigwait_beos(const sigset_t_beos* beosSet, int* _signal);
100 int __sigwait(const sigset_t* set, int* _signal);
101 
102 int __sigemptyset_beos(sigset_t_beos* set);
103 int __sigfillset_beos(sigset_t_beos* set);
104 int __sigismember_beos(const sigset_t_beos* set, int signal);
105 int __sigaddset_beos(sigset_t_beos* set, int signal);
106 int __sigdelset_beos(sigset_t_beos* set, int signal);
107 
108 int __sigemptyset(sigset_t* set);
109 int __sigfillset(sigset_t* set);
110 int __sigismember(const sigset_t* set, int signal);
111 int __sigaddset(sigset_t* set, int signal);
112 int __sigdelset(sigset_t* set, int signal);
113 
114 
115 __END_DECLS
116 
117 
118 #endif	// _LIBROOT_SIGNAL_PRIVATE_H
119