xref: /haiku/src/system/libroot/posix/signal/set_signal_mask.cpp (revision a3e794ae459fec76826407f8ba8c94cd3535f128)
1 /*
2  * Copyright 2011, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Copyright 2004-2006, Axel Dörfler, axeld@pinc-software.de.
4  * All rights reserved.
5  * Distributed under the terms of the MIT License.
6  */
7 
8 
9 #include <signal.h>
10 
11 #include <errno.h>
12 
13 #include <syscall_utils.h>
14 
15 #include <symbol_versioning.h>
16 #include <syscalls.h>
17 
18 #include <errno_private.h>
19 #include <signal_private.h>
20 
21 
22 int
23 __sigprocmask_beos(int how, const sigset_t_beos* beosSet,
24 	sigset_t_beos* beosOldSet)
25 {
26 	RETURN_AND_SET_ERRNO(__pthread_sigmask_beos(how, beosSet, beosOldSet));
27 }
28 
29 
30 int
31 __pthread_sigmask_beos(int how, const sigset_t_beos* beosSet,
32 	sigset_t_beos* beosOldSet)
33 {
34 	// convert new signal set
35 	sigset_t set;
36 	if (beosSet != NULL)
37 		set = from_beos_sigset(*beosSet);
38 
39 	// set the mask
40 	sigset_t oldSet;
41 	status_t error = _kern_set_signal_mask(how, beosSet != NULL ? &set : NULL,
42 		beosOldSet != NULL ? &oldSet : NULL);
43 	if (error != B_OK)
44 		return error;
45 
46 	// convert old signal set back
47 	if (beosOldSet != NULL)
48 		*beosOldSet = to_beos_sigset(oldSet);
49 
50 	return 0;
51 }
52 
53 
54 int
55 __sigprocmask(int how, const sigset_t* set, sigset_t* oldSet)
56 {
57 	RETURN_AND_SET_ERRNO(_kern_set_signal_mask(how, set, oldSet));
58 }
59 
60 
61 int
62 __pthread_sigmask(int how, const sigset_t* set, sigset_t* oldSet)
63 {
64 	return _kern_set_signal_mask(how, set, oldSet);
65 }
66 
67 
68 DEFINE_LIBROOT_KERNEL_SYMBOL_VERSION("__sigprocmask_beos",
69 	"sigprocmask@", "BASE");
70 DEFINE_LIBROOT_KERNEL_SYMBOL_VERSION("__pthread_sigmask_beos",
71 	"pthread_sigmask@", "BASE");
72 
73 DEFINE_LIBROOT_KERNEL_SYMBOL_VERSION("__sigprocmask", "sigprocmask@@",
74 	"1_ALPHA4");
75 DEFINE_LIBROOT_KERNEL_SYMBOL_VERSION("__pthread_sigmask", "pthread_sigmask@@",
76 	"1_ALPHA4");
77