Mercurial > flash_v2
annotate packages/language/c/libc/current/include/signal.h @ 64:c38311975d4f ecos-sw-2000-01-28
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
| author | jlarmour |
|---|---|
| date | Fri, 28 Jan 2000 04:59:39 +0000 |
| parents | 443894e2e912 |
| children | bf00f99aec69 |
| rev | line source |
|---|---|
| 2 | 1 #ifndef CYGONCE_LIBC_SIGNAL_H |
| 2 #define CYGONCE_LIBC_SIGNAL_H | |
| 3 //======================================================================== | |
| 4 // | |
| 5 // signal.h | |
| 6 // | |
| 7 // Definitions for ISO C and POSIX 1003.1 signals | |
| 8 // | |
| 9 //======================================================================== | |
| 10 //####COPYRIGHTBEGIN#### | |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
11 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
12 // ------------------------------------------- |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
13 // The contents of this file are subject to the Red Hat eCos Public License |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
14 // Version 1.0 (the "License"); you may not use this file except in |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
15 // compliance with the License. You may obtain a copy of the License at |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
16 // http://sourceware.cygnus.com/ecos |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
17 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
18 // Software distributed under the License is distributed on an |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
19 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
20 // License for the specific language governing rights and limitations under |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
21 // the License. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
22 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
23 // The Original Code is eCos - Embedded Configurable Operating System, |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
24 // released September 30, 1998. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
25 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
26 // The Initial Developer of the Original Code is Red Hat. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
27 // Portions created by Red Hat are |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
28 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
29 // All Rights Reserved. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
30 // ------------------------------------------- |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
31 // |
| 2 | 32 //####COPYRIGHTEND#### |
| 33 //======================================================================== | |
| 34 //#####DESCRIPTIONBEGIN#### | |
| 35 // | |
| 36 // Author(s): jlarmour | |
| 37 // Contributors: jlarmour | |
| 38 // Date: 1999-02-03 | |
| 39 // Purpose: Provides description of interface to ISO C and POSIX 1003.1 | |
| 40 // signal functionality | |
| 41 // Description: | |
| 42 // Usage: #include <signal.h> | |
| 43 // | |
| 44 //####DESCRIPTIONEND#### | |
| 45 // | |
| 46 //======================================================================== | |
| 47 | |
| 48 // CONFIGURATION | |
| 49 | |
| 50 #include <pkgconf/libc.h> // C library configuration | |
| 51 | |
| 52 #ifdef CYGPKG_LIBC_SIGNALS | |
| 53 | |
| 54 // INCLUDES | |
| 55 | |
| 56 #include <cyg/infra/cyg_type.h> // Common type definitions and support | |
| 57 | |
| 58 #ifdef CYGSEM_LIBC_SIGNALS_POSIX | |
| 59 # include <unistd.h> // _POSIX_* macros | |
| 60 #endif | |
| 61 | |
| 62 | |
| 63 // TYPE DEFINITIONS | |
| 64 | |
| 65 // Integral type that can be accessed atomically - from ISO C 7.7 | |
| 66 typedef cyg_atomic sig_atomic_t; | |
| 67 | |
| 68 // Type of signal handler functions | |
| 69 typedef void (*__sighandler_t)(int); | |
| 70 | |
| 71 #ifdef CYGSEM_LIBC_SIGNALS_POSIX | |
| 72 | |
| 73 // Signal sets from POSIX 1003.1 chap 3.3.3 and other chaps | |
| 74 typedef cyg_uint32 sigset_t; | |
| 75 | |
| 76 // POSIX 1003.1 chap 3.3.1.2 | |
| 77 union sigval { | |
| 78 int sival_int; // used when application-defined value is an int | |
| 79 void *sival_ptr; // used when application-defined value is a pointer | |
| 80 }; | |
| 81 | |
| 82 // Signal information structure passed to a __siginfoaction_t style handler | |
| 83 // from POSIX 1003.1 chap 3.3.1.3 | |
| 84 typedef struct { | |
| 85 int si_signo; // signal number | |
| 86 int si_code; // cause of signal | |
| 87 union sigval si_value; // signal value | |
| 88 } siginfo_t; | |
| 89 | |
| 90 | |
| 91 // Type of signal handler used if SA_SIGINFO is set in flags to sigaction | |
| 92 // from POSIX 1003.1 chap 3.3.1.3 | |
| 93 typedef void (*__siginfoaction_t)(int __signo, siginfo_t *__info, | |
| 94 void *__context); | |
| 95 | |
| 96 // struct sigaction describes the action to be taken when we get a signal | |
| 97 // From POSIX 1003.1 chap. 3.3.4.2 | |
| 98 struct sigaction { | |
| 99 sigset_t sa_mask; // Additional signals to be blocked | |
| 100 int sa_flags; // Special flags | |
| 101 union { | |
| 102 __sighandler_t sa_handler; // signal handler | |
| 103 __siginfoaction_t sa_sigaction; // Function to call instead of | |
| 104 // sa_handler if SA_SIGINFO is | |
| 105 // set in sa_flags | |
| 106 } __sigactionhandler; | |
| 107 #define sa_handler __sigactionhandler.sa_handler | |
| 108 #define sa_sigaction __sigactionhandler.sa_sigaction | |
| 109 }; | |
| 110 | |
| 111 | |
| 112 #endif // ifdef CYGSEM_LIBC_SIGNALS_POSIX | |
| 113 | |
| 114 | |
| 115 // CONSTANTS | |
| 116 | |
| 117 // Signal handlers for use with signal(). We avoid 0 because in an embedded | |
| 118 // system this may be e.g. start of ROM and thus a possible function pointer | |
| 119 // for reset! | |
| 120 | |
| 121 #define SIG_DFL ((__sighandler_t) 1) // Default action | |
| 122 #define SIG_IGN ((__sighandler_t) 2) // Ignore action | |
| 123 #define SIG_ERR ((__sighandler_t)-1) // Error return | |
| 124 | |
| 125 // NB. We do not need to restrict SIG* definitions (e.g. by eliminating | |
| 126 // POSIX signals) when using strict ISO C (permitted in 7.7) | |
| 127 | |
| 128 #define SIGNULL 0 // Reserved signal - do not use (POSIX 3.3.1.1) | |
| 129 #define SIGHUP 1 // Hangup on controlling terminal (POSIX) | |
| 130 #define SIGINT 2 // Interactive attention (ISO C) | |
| 131 #define SIGQUIT 3 // Interactive termination (POSIX) | |
| 132 #define SIGILL 4 // Illegal instruction (not reset when caught) (ISO C) | |
| 133 #define SIGTRAP 5 // Trace trap (not reset when caught) | |
| 134 #define SIGIOT 6 // IOT instruction | |
| 135 #define SIGABRT 6 // Abnormal termination - used by abort() (ISO C) | |
| 136 #define SIGEMT 7 // EMT instruction | |
| 137 #define SIGFPE 8 // Floating Point Exception e.g. div by 0 (ISO C) | |
| 138 #define SIGKILL 9 // Kill (cannot be caught or ignored) (POSIX) | |
| 139 #if 1 // FIXME - should be #ifdef _POSIX_MEMORY_PROTECTION? | |
| 140 # define SIGBUS 10 // Bus error (POSIX) | |
| 141 #endif | |
| 142 #define SIGSEGV 11 // Invalid memory reference (ISO C) | |
| 143 #define SIGSYS 12 // Bad argument to system call (used by anything?) | |
| 144 #define SIGPIPE 13 // Write on a pipe with no one to read it (POSIX) | |
| 145 #define SIGALRM 14 // Alarm timeout (POSIX) | |
| 146 #define SIGTERM 15 // Software termination request (ISO C) | |
| 147 #define SIGUSR1 16 // Application-defined signal 1 (POSIX) | |
| 148 #define SIGUSR2 17 // Application-defined signal 2 (POSIX) | |
| 149 | |
| 150 #define CYGNUM_LIBC_SIGNALS 18 // Maximum signal number + 1 | |
| 151 | |
| 152 #ifdef _POSIX_JOB_CONTROL | |
| 153 # define SIGCHLD 18 // Child process terminated or stopped (POSIX) | |
| 154 # define SIGCONT 19 // Continue if stopped (POSIX) | |
| 155 # define SIGSTOP 20 // Stop (cannot be caught or ignored) (POSIX) | |
| 156 # define SIGTSTP 21 // Interactive stop (POSIX) | |
| 157 # define SIGTTIN 22 // Terminal read attempted by backgrounded | |
| 158 // process (POSIX) | |
| 159 # define SIGTTOU 23 // Terminal write attempted by backgrounded | |
| 160 // process (POSIX) | |
| 161 #undef CYGNUM_LIBC_SIGNALS | |
| 162 #define CYGNUM_LIBC_SIGNALS 24 | |
| 163 #endif | |
| 164 | |
| 165 // FIXME - strictly by POSIX in 3.3.1.1 we should define SIGRTMIN/SIGRTMAX | |
| 166 // But if so, to what value if it _isn't_ supported?! | |
| 167 | |
| 168 #ifdef CYGSEM_LIBC_SIGNALS_POSIX | |
| 169 // sa_flag bits in struct sigaction | |
| 170 #define SA_NOCLDSTOP 1 // Don't generate SIGCHLD when children stop | |
| 171 #define SA_SIGINFO 2 // Use the __siginfoaction_t style signal | |
| 172 // handler, instead of the single argument handler | |
| 173 #endif // ifdef CYGSEM_LIBC_SIGNALS_POSIX | |
| 174 | |
| 175 | |
| 176 // FUNCTION PROTOTYPES | |
| 177 | |
| 178 #ifdef __cplusplus | |
| 179 extern "C" { | |
| 180 #endif | |
| 181 | |
| 182 //=========================================================================== | |
| 183 | |
| 184 // ISO C functions | |
| 185 | |
| 186 ////////////////////////////// | |
| 187 // signal() - ISO C 7.7.1 // | |
| 188 ////////////////////////////// | |
| 189 // | |
| 190 // Installs a new signal handler for the specified signal, and returns | |
| 191 // the old handler | |
| 192 // | |
| 193 | |
| 194 extern __sighandler_t | |
| 195 signal(int __sig, __sighandler_t __handler); | |
| 196 | |
| 197 /////////////////////////// | |
| 198 // raise() - ISO C 7.7.2 // | |
| 199 /////////////////////////// | |
| 200 // | |
| 201 // Raises the signal, which will cause the current signal handler for | |
| 202 // that signal to be called | |
| 203 // | |
| 204 | |
| 205 extern int | |
| 206 raise(int __sig); | |
| 207 | |
| 208 | |
| 209 #ifdef __cplusplus | |
| 210 } // extern "C" | |
| 211 #endif | |
| 212 | |
| 213 #include <signal.inl> | |
| 214 | |
| 215 #endif // ifdef CYGPKG_LIBC_SIGNALS | |
| 216 | |
| 217 #endif // CYGONCE_LIBC_SIGNAL_H multiple inclusion protection | |
| 218 | |
| 219 // EOF signal.h |
