OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [compat/] [posix/] [current/] [include/] [signal.h] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
#ifndef CYGONCE_SIGNAL_H
2
#define CYGONCE_SIGNAL_H
3
//=============================================================================
4
//
5
//      signal.h
6
//
7
//      POSIX signal header
8
//
9
//=============================================================================
10
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
11
// -------------------------------------------                              
12
// This file is part of eCos, the Embedded Configurable Operating System.   
13
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
14
//
15
// eCos is free software; you can redistribute it and/or modify it under    
16
// the terms of the GNU General Public License as published by the Free     
17
// Software Foundation; either version 2 or (at your option) any later      
18
// version.                                                                 
19
//
20
// eCos is distributed in the hope that it will be useful, but WITHOUT      
21
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
22
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
23
// for more details.                                                        
24
//
25
// You should have received a copy of the GNU General Public License        
26
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
27
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
28
//
29
// As a special exception, if other files instantiate templates or use      
30
// macros or inline functions from this file, or you compile this file      
31
// and link it with other works to produce a work based on this file,       
32
// this file does not by itself cause the resulting work to be covered by   
33
// the GNU General Public License. However the source code for this file    
34
// must still be made available in accordance with section (3) of the GNU   
35
// General Public License v2.                                               
36
//
37
// This exception does not invalidate any other reasons why a work based    
38
// on this file might be covered by the GNU General Public License.         
39
// -------------------------------------------                              
40
// ####ECOSGPLCOPYRIGHTEND####                                              
41
//=============================================================================
42
//#####DESCRIPTIONBEGIN####
43
//
44
// Author(s):     nickg, jlarmour
45
// Contributors:  
46
// Date:          2000-03-17
47
// Purpose:       POSIX signal header
48
// Description:   This header contains all the definitions needed to support
49
//                the POSIX signal API under eCos.
50
//              
51
// Usage:         This file can either be included directly, or indirectly via
52
//                the C library signal.h header.
53
//              
54
//
55
//####DESCRIPTIONEND####
56
//
57
//=============================================================================
58
 
59
#include <pkgconf/hal.h>
60
#include <pkgconf/kernel.h>
61
#include <pkgconf/posix.h>
62
 
63
#ifdef CYGPKG_POSIX_SIGNALS
64
 
65
#include <stddef.h>             // NULL, size_t
66
 
67
#include <limits.h>
68
#include <sys/types.h>
69
 
70
//-----------------------------------------------------------------------------
71
// POSIX feature test macros
72
 
73
// We do not support job control
74
#undef _POSIX_JOB_CONTROL
75
 
76
//-----------------------------------------------------------------------------
77
// Manifest constants
78
 
79
#ifdef _POSIX_REALTIME_SIGNALS
80
// For now we define the topmost 8 signals as realtime
81
#define SIGRTMIN                24
82
#define SIGRTMAX                31
83
#endif
84
 
85
//-----------------------------------------------------------------------------
86
// forward references
87
 
88
struct timespec;
89
 
90
//-----------------------------------------------------------------------------
91
// Sigval structure
92
 
93
union sigval
94
{
95
    int   sival_int;    // used when application-defined value is an int
96
    void  *sival_ptr;   // used when application-defined value is a pointer
97
};
98
 
99
//-----------------------------------------------------------------------------
100
// Siginfo structure passed to an SA_SIGINFO style handler
101
 
102
typedef struct
103
{
104
    int          si_signo;      // signal number
105
    int          si_code;       // cause of signal
106
    union sigval si_value;      // signal value
107
} siginfo_t;
108
 
109
// Values for si_code
110
# define SI_USER        1
111
# define SI_QUEUE       2
112
# define SI_TIMER       3
113
# define SI_ASYNCIO     4
114
# define SI_MESGQ       5
115
# define SI_EXCEPT      6       // signal is result of an exception delivery
116
 
117
//-----------------------------------------------------------------------------
118
// Basic types
119
 
120
// Integral type that can be accessed atomically - from ISO C 7.7
121
typedef cyg_atomic sig_atomic_t;
122
 
123
// Type of signal handler functions
124
typedef void (*sa_sighandler_t)(int);
125
 
126
// Type of signal handler used if SA_SIGINFO is set in sa_flags
127
typedef void (*sa_siginfoaction_t)(int signo, siginfo_t *info,
128
                                  void *context);
129
 
130
//-----------------------------------------------------------------------------
131
//Signal handlers for use with signal() and sigaction(). We avoid 0
132
//because in an embedded system this may be start of ROM and thus
133
//a possible function pointer for reset.
134
 
135
#define SIG_DFL ((sa_sighandler_t) 1)      // Default action
136
#define SIG_IGN ((sa_sighandler_t) 2)      // Ignore action
137
#define SIG_ERR ((sa_sighandler_t)-1)      // Error return
138
 
139
//-----------------------------------------------------------------------------
140
// Signal values
141
 
142
#define SIGNULL   0    // Reserved signal - do not use (POSIX 3.3.1.1)
143
#define SIGHUP    1    // Hangup on controlling terminal (POSIX)
144
#define SIGINT    2    // Interactive attention (ISO C)
145
#define SIGQUIT   3    // Interactive termination (POSIX)
146
#define SIGILL    4    // Illegal instruction (not reset when caught) (ISO C)
147
#define SIGTRAP   5    // Trace trap (not reset when caught)
148
#define SIGIOT    6    // IOT instruction
149
#define SIGABRT   6    // Abnormal termination - used by abort() (ISO C)
150
#define SIGEMT    7    // EMT instruction
151
#define SIGFPE    8    // Floating Point Exception e.g. div by 0 (ISO C)
152
#define SIGKILL   9    // Kill (cannot be caught or ignored) (POSIX)
153
#define SIGBUS    10   // Bus error (POSIX)
154
#define SIGSEGV   11   // Invalid memory reference (ISO C)
155
#define SIGSYS    12   // Bad argument to system call (used by anything?)
156
#define SIGPIPE   13   // Write on a pipe with no one to read it (POSIX)
157
#define SIGALRM   14   // Alarm timeout (POSIX)
158
#define SIGTERM   15   // Software termination request (ISO C)
159
#define SIGUSR1   16   // Application-defined signal 1 (POSIX)
160
#define SIGUSR2   17   // Application-defined signal 2 (POSIX)
161
 
162
 
163
//-----------------------------------------------------------------------------
164
// Signal sets.
165
// At present we define a single 32 bit integer mask. We may need, at
166
// some future point, to extend this to 64 bits, or a structure
167
// containing an array of masks.
168
 
169
typedef cyg_uint32 sigset_t;
170
 
171
//-----------------------------------------------------------------------------
172
// struct sigaction describes the action to be taken when we get a signal
173
 
174
struct sigaction
175
{
176
    sigset_t               sa_mask;             // Additional signals to be blocked
177
    int                    sa_flags;            // Special flags
178
    union
179
    {
180
        sa_sighandler_t    sa_handler;          // signal handler
181
        sa_siginfoaction_t sa_sigaction;        // Function to call instead of
182
                                                // sa_handler if SA_SIGINFO is
183
                                                // set in sa_flags
184
    } sa_sigactionhandler;
185
#define sa_handler   sa_sigactionhandler.sa_handler
186
#define sa_sigaction sa_sigactionhandler.sa_sigaction
187
};
188
 
189
// sa_flag bits
190
#define SA_NOCLDSTOP 1   // Don't generate SIGCHLD when children stop
191
#define SA_SIGINFO   2   // Use the sa_siginfoaction_t style signal
192
                         // handler, instead of the single argument handler
193
 
194
//-----------------------------------------------------------------------------
195
// Sigevent structure.
196
 
197
struct sigevent
198
{
199
    int                  sigev_notify;
200
    int                  sigev_signo;
201
    union sigval         sigev_value;
202
    void               (*sigev_notify_function) (union sigval);
203
    pthread_attr_t      *sigev_notify_attributes;
204
};
205
 
206
# define SIGEV_NONE     1
207
# define SIGEV_SIGNAL   2
208
# define SIGEV_THREAD   3
209
 
210
//-----------------------------------------------------------------------------
211
// Functions to generate signals
212
 
213
// Deliver sig to a process.
214
// eCos only supports the value 0 for pid.
215
externC int kill (pid_t pid, int sig);
216
 
217
externC int pthread_kill (pthread_t thread, int sig);
218
 
219
//-----------------------------------------------------------------------------
220
// Functions to catch signals
221
 
222
// Install signal handler for sig.
223
externC int sigaction  (int sig, const struct sigaction *act,
224
                        struct sigaction *oact);
225
 
226
// Queue signal to process with value.
227
externC int sigqueue  (pid_t pid, int sig, const union sigval value);
228
 
229
//-----------------------------------------------------------------------------
230
// Functions to deal with current blocked and pending masks
231
 
232
// Set process blocked signal mask
233
externC int sigprocmask  (int how, const sigset_t *set, sigset_t *oset);
234
 
235
// Set calling thread's blocked signal mask
236
externC int pthread_sigmask (int how, const sigset_t *set, sigset_t *oset);
237
 
238
// Get set of pending signals for this process
239
externC int sigpending  (sigset_t *set);
240
 
241
// Values for the how arguments:
242
#define SIG_BLOCK       1
243
#define SIG_UNBLOCK     2
244
#define SIG_SETMASK     3
245
 
246
//-----------------------------------------------------------------------------
247
// Wait for or accept signals
248
 
249
// Block signals in set and wait for a signal
250
externC int sigsuspend  (const sigset_t *set);
251
 
252
// Wait for a signal in set to arrive
253
externC int sigwait  (const sigset_t *set, int *sig);
254
 
255
// Do the same as sigwait() except return a siginfo_t object too.
256
externC int sigwaitinfo  (const sigset_t *set, siginfo_t *info);
257
 
258
// Do the same as sigwaitinfo() but return anyway after timeout.
259
externC int sigtimedwait  (const sigset_t *set, siginfo_t *info,
260
                           const struct timespec *timeout);
261
 
262
//-----------------------------------------------------------------------------
263
// Signal sets
264
 
265
// Clear all signals from set.
266
externC int sigemptyset  (sigset_t *set);
267
 
268
// Set all signals in set.
269
externC int sigfillset  (sigset_t *set);
270
 
271
// Add signo to set.
272
externC int sigaddset  (sigset_t *set, int signo);
273
 
274
// Remove signo from set.
275
externC int sigdelset  (sigset_t *set, int signo);
276
 
277
// Test whether signo is in set
278
externC int sigismember  (const sigset_t *set, int signo);
279
 
280
//-----------------------------------------------------------------------------
281
// alarm, pause and sleep
282
 
283
// Generate SIGALRM after some number of seconds
284
externC unsigned int alarm( unsigned int seconds );
285
 
286
// Wait for a signal to be delivered.
287
externC int pause( void );
288
 
289
// Wait for a signal, or the given number of seconds
290
externC unsigned int sleep( unsigned int seconds );
291
 
292
//-----------------------------------------------------------------------------
293
// signal() - ISO C 7.7.1   //
294
//
295
// Installs a new signal handler for the specified signal, and returns
296
// the old handler
297
//
298
 
299
externC sa_sighandler_t signal(int __sig, sa_sighandler_t __handler);
300
 
301
// raise() - ISO C 7.7.2 //
302
//
303
// Raises the signal, which will cause the current signal handler for
304
// that signal to be called
305
 
306
externC int raise(int __sig);
307
 
308
#endif // ifdef CYGPKG_POSIX_SIGNALS
309
 
310
//-----------------------------------------------------------------------------
311
#endif // ifndef CYGONCE_SIGNAL_H
312
// End of signal.h

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.