1 /* 2 * Copyright 2002-2011, Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT license. 4 * 5 * Author: 6 * Daniel Reinhold, danielre@users.sf.net 7 * Ingo Weinhold, ingo_weinhold@gmx.de 8 */ 9 10 11 #include <signal.h> 12 13 #include <errno.h> 14 15 #include <signal_defs.h> 16 #include <syscalls.h> 17 18 #include <symbol_versioning.h> 19 20 #include <errno_private.h> 21 #include <signal_private.h> 22 23 24 // #pragma - backward compatibility implementations 25 26 27 int 28 __sigemptyset_beos(sigset_t_beos* set) 29 { 30 *set = (sigset_t_beos)0; 31 return 0; 32 } 33 34 35 int 36 __sigfillset_beos(sigset_t_beos* set) 37 { 38 *set = ~(sigset_t_beos)0; 39 return 0; 40 } 41 42 43 int 44 __sigismember_beos(const sigset_t_beos* set, int signal) 45 { 46 if (signal <= 0 || signal > MAX_SIGNAL_NUMBER_BEOS) { 47 __set_errno(EINVAL); 48 return -1; 49 } 50 51 return (*set & SIGNAL_TO_MASK(signal)) != 0 ? 1 : 0; 52 } 53 54 55 int 56 __sigaddset_beos(sigset_t_beos* set, int signal) 57 { 58 if (signal <= 0 || signal > MAX_SIGNAL_NUMBER_BEOS) { 59 __set_errno(EINVAL); 60 return -1; 61 } 62 63 *set |= SIGNAL_TO_MASK(signal); 64 return 0; 65 } 66 67 68 int 69 __sigdelset_beos(sigset_t_beos* set, int signal) 70 { 71 if (signal <= 0 || signal > MAX_SIGNAL_NUMBER_BEOS) { 72 __set_errno(EINVAL); 73 return -1; 74 } 75 76 *set &= ~SIGNAL_TO_MASK(signal); 77 return 0; 78 } 79 80 81 // #pragma - current implementations 82 83 84 int 85 __sigemptyset(sigset_t* set) 86 { 87 *set = (sigset_t)0; 88 return 0; 89 } 90 91 92 int 93 __sigfillset(sigset_t* set) 94 { 95 *set = ~(sigset_t)0; 96 return 0; 97 } 98 99 100 int 101 __sigismember(const sigset_t* set, int signal) 102 { 103 if (signal <= 0 || signal > MAX_SIGNAL_NUMBER) { 104 __set_errno(EINVAL); 105 return -1; 106 } 107 108 return (*set & SIGNAL_TO_MASK(signal)) != 0 ? 1 : 0; 109 } 110 111 112 int 113 __sigaddset(sigset_t* set, int signal) 114 { 115 if (signal <= 0 || signal > MAX_SIGNAL_NUMBER) { 116 __set_errno(EINVAL); 117 return -1; 118 } 119 120 *set |= SIGNAL_TO_MASK(signal); 121 return 0; 122 } 123 124 125 int 126 __sigdelset(sigset_t* set, int signal) 127 { 128 if (signal <= 0 || signal > MAX_SIGNAL_NUMBER) { 129 __set_errno(EINVAL); 130 return -1; 131 } 132 133 *set &= ~SIGNAL_TO_MASK(signal); 134 return 0; 135 } 136 137 138 // #pragma - versioned symbols 139 140 141 DEFINE_LIBROOT_KERNEL_SYMBOL_VERSION("__sigemptyset_beos", "sigemptyset@", 142 "BASE"); 143 DEFINE_LIBROOT_KERNEL_SYMBOL_VERSION("__sigfillset_beos", "sigfillset@", 144 "BASE"); 145 DEFINE_LIBROOT_KERNEL_SYMBOL_VERSION("__sigismember_beos", "sigismember@", 146 "BASE"); 147 DEFINE_LIBROOT_KERNEL_SYMBOL_VERSION("__sigaddset_beos", "sigaddset@", "BASE"); 148 DEFINE_LIBROOT_KERNEL_SYMBOL_VERSION("__sigdelset_beos", "sigdelset@", "BASE"); 149 150 DEFINE_LIBROOT_KERNEL_SYMBOL_VERSION("__sigemptyset", "sigemptyset@@", 151 "1_ALPHA4"); 152 DEFINE_LIBROOT_KERNEL_SYMBOL_VERSION("__sigfillset", "sigfillset@@", 153 "1_ALPHA4"); 154 DEFINE_LIBROOT_KERNEL_SYMBOL_VERSION("__sigismember", "sigismember@@", 155 "1_ALPHA4"); 156 DEFINE_LIBROOT_KERNEL_SYMBOL_VERSION("__sigaddset", "sigaddset@@", "1_ALPHA4"); 157 DEFINE_LIBROOT_KERNEL_SYMBOL_VERSION("__sigdelset", "sigdelset@@", "1_ALPHA4"); 158