Dr Andrew Scott G7VAV

My photo
 
June 2025
Mo Tu We Th Fr Sa Su
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 1 2 3 4 5 6


siginfo.h
001: #ifndef _ASM_GENERIC_SIGINFO_H
002: #define _ASM_GENERIC_SIGINFO_H
003: 
004: 
005: #include <linux/types.h>
006: 
007: typedef union sigval {
008:         int sival_int;
009:         void *sival_ptr;
010: } sigval_t;
011: 
012: /*
013:  * This is the size (including padding) of the part of the
014:  * struct siginfo that is before the union.
015:  */
016: #ifndef __ARCH_SI_PREAMBLE_SIZE
017: #define __ARCH_SI_PREAMBLE_SIZE (3 * sizeof(int))
018: #endif
019: 
020: #define SI_MAX_SIZE     128
021: #ifndef SI_PAD_SIZE
022: #define SI_PAD_SIZE     ((SI_MAX_SIZE - __ARCH_SI_PREAMBLE_SIZE) / sizeof(int))
023: #endif
024: 
025: #ifndef __ARCH_SI_UID_T
026: #define __ARCH_SI_UID_T __kernel_uid32_t
027: #endif
028: 
029: /*
030:  * The default "si_band" type is "long", as specified by POSIX.
031:  * However, some architectures want to override this to "int"
032:  * for historical compatibility reasons, so we allow that.
033:  */
034: #ifndef __ARCH_SI_BAND_T
035: #define __ARCH_SI_BAND_T long
036: #endif
037: 
038: #ifndef HAVE_ARCH_SIGINFO_T
039: 
040: typedef struct siginfo {
041:         int si_signo;
042:         int si_errno;
043:         int si_code;
044: 
045:         union {
046:                 int _pad[SI_PAD_SIZE];
047: 
048:                 /* kill() */
049:                 struct {
050:                         __kernel_pid_t _pid;    /* sender's pid */
051:                         __ARCH_SI_UID_T _uid;   /* sender's uid */
052:                 } _kill;
053: 
054:                 /* POSIX.1b timers */
055:                 struct {
056:                         __kernel_timer_t _tid;  /* timer id */
057:                         int _overrun;           /* overrun count */
058:                         char _pad[sizeof( __ARCH_SI_UID_T) - sizeof(int)];
059:                         sigval_t _sigval;       /* same as below */
060:                         int _sys_private;       /* not to be passed to user */
061:                 } _timer;
062: 
063:                 /* POSIX.1b signals */
064:                 struct {
065:                         __kernel_pid_t _pid;    /* sender's pid */
066:                         __ARCH_SI_UID_T _uid;   /* sender's uid */
067:                         sigval_t _sigval;
068:                 } _rt;
069: 
070:                 /* SIGCHLD */
071:                 struct {
072:                         __kernel_pid_t _pid;    /* which child */
073:                         __ARCH_SI_UID_T _uid;   /* sender's uid */
074:                         int _status;            /* exit code */
075:                         __kernel_clock_t _utime;
076:                         __kernel_clock_t _stime;
077:                 } _sigchld;
078: 
079:                 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
080:                 struct {
081:                         void *_addr; /* faulting insn/memory ref. */
082: #ifdef __ARCH_SI_TRAPNO
083:                         int _trapno;    /* TRAP # which caused the signal */
084: #endif
085:                         short _addr_lsb; /* LSB of the reported address */
086:                 } _sigfault;
087: 
088:                 /* SIGPOLL */
089:                 struct {
090:                         __ARCH_SI_BAND_T _band; /* POLL_IN, POLL_OUT, POLL_MSG */
091:                         int _fd;
092:                 } _sigpoll;
093: 
094:                 /* SIGSYS */
095:                 struct {
096:                         void *_call_addr; /* calling user insn */
097:                         int _syscall;   /* triggering system call number */
098:                         unsigned int _arch;     /* AUDIT_ARCH_* of syscall */
099:                 } _sigsys;
100:         } _sifields;
101: } siginfo_t;
102: 
103: /* If the arch shares siginfo, then it has SIGSYS. */
104: #define __ARCH_SIGSYS
105: #endif
106: 
107: /*
108:  * How these fields are to be accessed.
109:  */
110: #define si_pid          _sifields._kill._pid
111: #define si_uid          _sifields._kill._uid
112: #define si_tid          _sifields._timer._tid
113: #define si_overrun      _sifields._timer._overrun
114: #define si_sys_private  _sifields._timer._sys_private
115: #define si_status       _sifields._sigchld._status
116: #define si_utime        _sifields._sigchld._utime
117: #define si_stime        _sifields._sigchld._stime
118: #define si_value        _sifields._rt._sigval
119: #define si_int          _sifields._rt._sigval.sival_int
120: #define si_ptr          _sifields._rt._sigval.sival_ptr
121: #define si_addr         _sifields._sigfault._addr
122: #ifdef __ARCH_SI_TRAPNO
123: #define si_trapno       _sifields._sigfault._trapno
124: #endif
125: #define si_addr_lsb     _sifields._sigfault._addr_lsb
126: #define si_band         _sifields._sigpoll._band
127: #define si_fd           _sifields._sigpoll._fd
128: #ifdef __ARCH_SIGSYS
129: #define si_call_addr    _sifields._sigsys._call_addr
130: #define si_syscall      _sifields._sigsys._syscall
131: #define si_arch         _sifields._sigsys._arch
132: #endif
133: 
134: #define __SI_KILL       0
135: #define __SI_TIMER      0
136: #define __SI_POLL       0
137: #define __SI_FAULT      0
138: #define __SI_CHLD       0
139: #define __SI_RT         0
140: #define __SI_MESGQ      0
141: #define __SI_SYS        0
142: #define __SI_CODE(T,N)  (N)
143: 
144: /*
145:  * si_code values
146:  * Digital reserves positive values for kernel-generated signals.
147:  */
148: #define SI_USER         0               /* sent by kill, sigsend, raise */
149: #define SI_KERNEL       0x80            /* sent by the kernel from somewhere */
150: #define SI_QUEUE        -1              /* sent by sigqueue */
151: #define SI_TIMER __SI_CODE(__SI_TIMER,-2) /* sent by timer expiration */
152: #define SI_MESGQ __SI_CODE(__SI_MESGQ,-3) /* sent by real time mesq state change */
153: #define SI_ASYNCIO      -4              /* sent by AIO completion */
154: #define SI_SIGIO        -5              /* sent by queued SIGIO */
155: #define SI_TKILL        -6              /* sent by tkill system call */
156: #define SI_DETHREAD     -7              /* sent by execve() killing subsidiary threads */
157: 
158: #define SI_FROMUSER(siptr)      ((siptr)->si_code <= 0)
159: #define SI_FROMKERNEL(siptr)    ((siptr)->si_code > 0)
160: 
161: /*
162:  * SIGILL si_codes
163:  */
164: #define ILL_ILLOPC      (__SI_FAULT|1)  /* illegal opcode */
165: #define ILL_ILLOPN      (__SI_FAULT|2)  /* illegal operand */
166: #define ILL_ILLADR      (__SI_FAULT|3)  /* illegal addressing mode */
167: #define ILL_ILLTRP      (__SI_FAULT|4)  /* illegal trap */
168: #define ILL_PRVOPC      (__SI_FAULT|5)  /* privileged opcode */
169: #define ILL_PRVREG      (__SI_FAULT|6)  /* privileged register */
170: #define ILL_COPROC      (__SI_FAULT|7)  /* coprocessor error */
171: #define ILL_BADSTK      (__SI_FAULT|8)  /* internal stack error */
172: #define NSIGILL         8
173: 
174: /*
175:  * SIGFPE si_codes
176:  */
177: #define FPE_INTDIV      (__SI_FAULT|1)  /* integer divide by zero */
178: #define FPE_INTOVF      (__SI_FAULT|2)  /* integer overflow */
179: #define FPE_FLTDIV      (__SI_FAULT|3)  /* floating point divide by zero */
180: #define FPE_FLTOVF      (__SI_FAULT|4)  /* floating point overflow */
181: #define FPE_FLTUND      (__SI_FAULT|5)  /* floating point underflow */
182: #define FPE_FLTRES      (__SI_FAULT|6)  /* floating point inexact result */
183: #define FPE_FLTINV      (__SI_FAULT|7)  /* floating point invalid operation */
184: #define FPE_FLTSUB      (__SI_FAULT|8)  /* subscript out of range */
185: #define NSIGFPE         8
186: 
187: /*
188:  * SIGSEGV si_codes
189:  */
190: #define SEGV_MAPERR     (__SI_FAULT|1)  /* address not mapped to object */
191: #define SEGV_ACCERR     (__SI_FAULT|2)  /* invalid permissions for mapped object */
192: #define NSIGSEGV        2
193: 
194: /*
195:  * SIGBUS si_codes
196:  */
197: #define BUS_ADRALN      (__SI_FAULT|1)  /* invalid address alignment */
198: #define BUS_ADRERR      (__SI_FAULT|2)  /* non-existent physical address */
199: #define BUS_OBJERR      (__SI_FAULT|3)  /* object specific hardware error */
200: /* hardware memory error consumed on a machine check: action required */
201: #define BUS_MCEERR_AR   (__SI_FAULT|4)
202: /* hardware memory error detected in process but not consumed: action optional*/
203: #define BUS_MCEERR_AO   (__SI_FAULT|5)
204: #define NSIGBUS         5
205: 
206: /*
207:  * SIGTRAP si_codes
208:  */
209: #define TRAP_BRKPT      (__SI_FAULT|1)  /* process breakpoint */
210: #define TRAP_TRACE      (__SI_FAULT|2)  /* process trace trap */
211: #define TRAP_BRANCH     (__SI_FAULT|3)  /* process taken branch trap */
212: #define TRAP_HWBKPT     (__SI_FAULT|4)  /* hardware breakpoint/watchpoint */
213: #define NSIGTRAP        4
214: 
215: /*
216:  * SIGCHLD si_codes
217:  */
218: #define CLD_EXITED      (__SI_CHLD|1)   /* child has exited */
219: #define CLD_KILLED      (__SI_CHLD|2)   /* child was killed */
220: #define CLD_DUMPED      (__SI_CHLD|3)   /* child terminated abnormally */
221: #define CLD_TRAPPED     (__SI_CHLD|4)   /* traced child has trapped */
222: #define CLD_STOPPED     (__SI_CHLD|5)   /* child has stopped */
223: #define CLD_CONTINUED   (__SI_CHLD|6)   /* stopped child has continued */
224: #define NSIGCHLD        6
225: 
226: /*
227:  * SIGPOLL si_codes
228:  */
229: #define POLL_IN         (__SI_POLL|1)   /* data input available */
230: #define POLL_OUT        (__SI_POLL|2)   /* output buffers available */
231: #define POLL_MSG        (__SI_POLL|3)   /* input message available */
232: #define POLL_ERR        (__SI_POLL|4)   /* i/o error */
233: #define POLL_PRI        (__SI_POLL|5)   /* high priority input available */
234: #define POLL_HUP        (__SI_POLL|6)   /* device disconnected */
235: #define NSIGPOLL        6
236: 
237: /*
238:  * SIGSYS si_codes
239:  */
240: #define SYS_SECCOMP             (__SI_SYS|1)    /* seccomp triggered */
241: #define NSIGSYS 1
242: 
243: /*
244:  * sigevent definitions
245:  * 
246:  * It seems likely that SIGEV_THREAD will have to be handled from 
247:  * userspace, libpthread transmuting it to SIGEV_SIGNAL, which the
248:  * thread manager then catches and does the appropriate nonsense.
249:  * However, everything is written out here so as to not get lost.
250:  */
251: #define SIGEV_SIGNAL    0       /* notify via signal */
252: #define SIGEV_NONE      1       /* other notification: meaningless */
253: #define SIGEV_THREAD    2       /* deliver via thread creation */
254: #define SIGEV_THREAD_ID 4       /* deliver to thread */
255: 
256: /*
257:  * This works because the alignment is ok on all current architectures
258:  * but we leave open this being overridden in the future
259:  */
260: #ifndef __ARCH_SIGEV_PREAMBLE_SIZE
261: #define __ARCH_SIGEV_PREAMBLE_SIZE      (sizeof(int) * 2 + sizeof(sigval_t))
262: #endif
263: 
264: #define SIGEV_MAX_SIZE  64
265: #define SIGEV_PAD_SIZE  ((SIGEV_MAX_SIZE - __ARCH_SIGEV_PREAMBLE_SIZE) \
266:                 / sizeof(int))
267: 
268: typedef struct sigevent {
269:         sigval_t sigev_value;
270:         int sigev_signo;
271:         int sigev_notify;
272:         union {
273:                 int _pad[SIGEV_PAD_SIZE];
274:                  int _tid;
275: 
276:                 struct {
277:                         void (*_function)(sigval_t);
278:                         void *_attribute;       /* really pthread_attr_t */
279:                 } _sigev_thread;
280:         } _sigev_un;
281: } sigevent_t;
282: 
283: #define sigev_notify_function   _sigev_un._sigev_thread._function
284: #define sigev_notify_attributes _sigev_un._sigev_thread._attribute
285: #define sigev_notify_thread_id   _sigev_un._tid
286: 
287: 
288: #endif
289: 


for client (none)
© Andrew Scott 2006 - 2025,
All Rights Reserved
http://www.andrew-scott.uk/
Andrew Scott
http://www.andrew-scott.co.uk/