"Fossies" - the Fresh Open Source Software Archive

Member "usr/include/cygwin/signal.h" (19 Aug 2019, 12970 Bytes) of package /windows/misc/cygwin-20190819-x86_64.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /* signal.h
    2 
    3   This file is part of Cygwin.
    4 
    5   This software is a copyrighted work licensed under the terms of the
    6   Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
    7   details. */
    8 
    9 #ifndef _CYGWIN_SIGNAL_H
   10 #define _CYGWIN_SIGNAL_H
   11 
   12 #include <bits/wordsize.h>
   13 
   14 #ifdef __cplusplus
   15 extern "C" {
   16 #endif
   17 
   18 /*
   19   Define a struct __mcontext, which should be identical in layout to the Win32
   20   API type CONTEXT with the addition of oldmask and cr2 fields at the end.
   21 */
   22 #ifdef __x86_64__
   23 
   24 struct _uc_fpxreg {
   25   __uint16_t significand[4];
   26   __uint16_t exponent;
   27   __uint16_t padding[3];
   28 };
   29 
   30 struct _uc_xmmreg {
   31   __uint32_t element[4];
   32 };
   33 
   34 struct _fpstate
   35 {
   36   __uint16_t cwd;
   37   __uint16_t swd;
   38   __uint16_t ftw;
   39   __uint16_t fop;
   40   __uint64_t rip;
   41   __uint64_t rdp;
   42   __uint32_t mxcsr;
   43   __uint32_t mxcr_mask;
   44   struct _uc_fpxreg st[8];
   45   struct _uc_xmmreg xmm[16];
   46   __uint32_t padding[24];
   47 };
   48 
   49 struct __attribute__ ((__aligned__ (16))) __mcontext
   50 {
   51   __uint64_t p1home;
   52   __uint64_t p2home;
   53   __uint64_t p3home;
   54   __uint64_t p4home;
   55   __uint64_t p5home;
   56   __uint64_t p6home;
   57   __uint32_t ctxflags;
   58   __uint32_t mxcsr;
   59   __uint16_t cs;
   60   __uint16_t ds;
   61   __uint16_t es;
   62   __uint16_t fs;
   63   __uint16_t gs;
   64   __uint16_t ss;
   65   __uint32_t eflags;
   66   __uint64_t dr0;
   67   __uint64_t dr1;
   68   __uint64_t dr2;
   69   __uint64_t dr3;
   70   __uint64_t dr6;
   71   __uint64_t dr7;
   72   __uint64_t rax;
   73   __uint64_t rcx;
   74   __uint64_t rdx;
   75   __uint64_t rbx;
   76   __uint64_t rsp;
   77   __uint64_t rbp;
   78   __uint64_t rsi;
   79   __uint64_t rdi;
   80   __uint64_t r8;
   81   __uint64_t r9;
   82   __uint64_t r10;
   83   __uint64_t r11;
   84   __uint64_t r12;
   85   __uint64_t r13;
   86   __uint64_t r14;
   87   __uint64_t r15;
   88   __uint64_t rip;
   89   struct _fpstate fpregs;
   90   __uint64_t vregs[52];
   91   __uint64_t vcx;
   92   __uint64_t dbc;
   93   __uint64_t btr;
   94   __uint64_t bfr;
   95   __uint64_t etr;
   96   __uint64_t efr;
   97   __uint64_t oldmask;
   98   __uint64_t cr2;
   99 };
  100 
  101 #else /* !x86_64 */
  102 
  103 struct _uc_fpreg
  104 {
  105   __uint16_t significand[4];
  106   __uint16_t exponent;
  107 };
  108 
  109 struct _fpstate
  110 {
  111   __uint32_t cw;
  112   __uint32_t sw;
  113   __uint32_t tag;
  114   __uint32_t ipoff;
  115   __uint32_t cssel;
  116   __uint32_t dataoff;
  117   __uint32_t datasel;
  118   struct _uc_fpreg _st[8];
  119   __uint32_t nxst;
  120 };
  121 
  122 struct __mcontext
  123 {
  124   __uint32_t ctxflags;
  125   __uint32_t dr0;
  126   __uint32_t dr1;
  127   __uint32_t dr2;
  128   __uint32_t dr3;
  129   __uint32_t dr6;
  130   __uint32_t dr7;
  131   struct _fpstate fpstate;
  132   __uint32_t gs;
  133   __uint32_t fs;
  134   __uint32_t es;
  135   __uint32_t ds;
  136   __uint32_t edi;
  137   __uint32_t esi;
  138   __uint32_t ebx;
  139   __uint32_t edx;
  140   __uint32_t ecx;
  141   __uint32_t eax;
  142   __uint32_t ebp;
  143   __uint32_t eip;
  144   __uint32_t cs;
  145   __uint32_t eflags;
  146   __uint32_t esp;
  147   __uint32_t ss;
  148   __uint32_t reserved[128];
  149   __uint32_t oldmask;
  150   __uint32_t cr2;
  151 };
  152 
  153 #endif /* !x86_64 */
  154 
  155 /* Needed for GDB.  It only compiles in the context copy code if this macro is
  156    defined.  This is not sizeof(CONTEXT) due to historical accidents. */
  157 #ifdef __x86_64__
  158 #define __COPY_CONTEXT_SIZE 816
  159 #else
  160 #define __COPY_CONTEXT_SIZE 204
  161 #endif
  162 
  163 typedef union sigval
  164 {
  165   int sival_int;            /* integer signal value */
  166   void  *sival_ptr;         /* pointer signal value */
  167 } sigval_t;
  168 
  169 typedef struct sigevent
  170 {
  171   sigval_t sigev_value;         /* signal value */
  172   int sigev_signo;          /* signal number */
  173   int sigev_notify;         /* notification type */
  174   void (*sigev_notify_function) (sigval_t); /* notification function */
  175   pthread_attr_t *sigev_notify_attributes; /* notification attributes */
  176 } sigevent_t;
  177 
  178 #if __POSIX_VISIBLE >= 199309
  179 
  180 #pragma pack(push,4)
  181 
  182 struct _sigcommune
  183 {
  184   __uint32_t _si_code;
  185   void *_si_read_handle;
  186   void *_si_write_handle;
  187   void *_si_process_handle;
  188   __extension__ union
  189   {
  190     struct {
  191       int      _si_fd;
  192       uint32_t _si_flags;
  193     };
  194     int64_t _si_pipe_unique_id;
  195     char *_si_str;
  196   };
  197 };
  198 
  199 #define __SI_PAD_SIZE 32
  200 #ifdef __INSIDE_CYGWIN__
  201 # ifndef max
  202 #   define max(a,b) (((a) > (b)) ? (a) : (b))
  203 # endif /*max*/
  204 # define __uint32_size(__x) (max(sizeof (__x) / sizeof (uint32_t), 1))
  205 
  206 /* This padding represents the elements of the last struct in siginfo_t,
  207    aligning the elements to the end to avoid conflicts with other struct
  208    members. */
  209 # define __SI_CYG_PAD (__SI_PAD_SIZE - __uint32_size (void *))
  210 #endif /*__INSIDE_CYGWIN__*/
  211 
  212 typedef struct
  213 {
  214   int si_signo;             /* signal number */
  215   int si_code;              /* signal code */
  216   pid_t si_pid;             /* sender's pid */
  217   uid_t si_uid;             /* sender's uid */
  218   int si_errno;             /* errno associated with signal */
  219 
  220   __extension__ union
  221   {
  222     __uint32_t __pad[__SI_PAD_SIZE];    /* plan for future growth */
  223     struct _sigcommune _si_commune; /* cygwin ipc */
  224     __extension__ struct
  225     {
  226       __extension__ union
  227       {
  228     sigval_t si_sigval;     /* signal value */
  229     sigval_t si_value;      /* signal value */
  230       };
  231       __extension__ struct
  232       {
  233     timer_t si_tid;         /* timer id */
  234     unsigned int si_overrun;    /* overrun count */
  235       };
  236     };
  237     /* SIGCHLD */
  238     __extension__ struct
  239     {
  240       int si_status;            /* exit code */
  241       clock_t si_utime;         /* user time */
  242       clock_t si_stime;         /* system time */
  243     };
  244 
  245     void *si_addr;          /* faulting address for core dumping
  246                        signals */
  247     /* Cygwin internal fields */
  248 #ifdef __INSIDE_CYGWIN__
  249     __extension__ struct 
  250     {
  251       __uint32_t __pad2[__SI_CYG_PAD];  /* Locate at end of struct */
  252       void *si_cyg;         /* pointer to block containing
  253                        cygwin-special info */
  254     };
  255 #endif /*__INSIDE_CYGWIN__*/
  256   };
  257 } siginfo_t;
  258 
  259 #pragma pack(pop)
  260 
  261 #endif /* __POSIX_VISIBLE >= 199309 */
  262 
  263 enum
  264 {
  265   SI_USER = 0,              /* sent by kill, raise, pthread_kill */
  266   SI_ASYNCIO = 2,           /* sent by AIO completion (currently
  267                        unimplemented) */
  268   SI_MESGQ,             /* sent by real time mesq state change
  269                        (currently unimplemented) */
  270   SI_TIMER,             /* sent by timer expiration */
  271   SI_QUEUE,             /* sent by sigqueue */
  272   SI_KERNEL,                /* sent by system */
  273 
  274   ILL_ILLOPC = 7,           /* illegal opcode */
  275   ILL_ILLOPN,               /* illegal operand */
  276   ILL_ILLADR,               /* illegal addressing mode */
  277   ILL_ILLTRP,               /* illegal trap*/
  278   ILL_PRVOPC,               /* privileged opcode */
  279   ILL_PRVREG,               /* privileged register */
  280   ILL_COPROC,               /* coprocessor error */
  281   ILL_BADSTK,               /* internal stack error */
  282 
  283   FPE_INTDIV = 15,          /* integer divide by zero */
  284   FPE_INTOVF,               /* integer overflow */
  285   FPE_FLTDIV,               /* floating point divide by zero */
  286   FPE_FLTOVF,               /* floating point overflow */
  287   FPE_FLTUND,               /* floating point underflow */
  288   FPE_FLTRES,               /* floating point inexact result */
  289   FPE_FLTINV,               /* floating point invalid operation */
  290   FPE_FLTSUB,               /* subscript out of range */
  291 
  292   SEGV_MAPERR = 23,         /* address not mapped to object */
  293   SEGV_ACCERR,              /* invalid permissions for mapped object */
  294 
  295   BUS_ADRALN = 25,          /* invalid address alignment.  */
  296   BUS_ADRERR,               /* non-existant physical address.  */
  297   BUS_OBJERR,               /* object specific hardware error.  */
  298 
  299   CLD_EXITED = 28,          /* child has exited */
  300   CLD_KILLED,               /* child was killed */
  301   CLD_DUMPED,               /* child terminated abnormally */
  302   CLD_TRAPPED,              /* traced child has trapped */
  303   CLD_STOPPED,              /* child has stopped */
  304   CLD_CONTINUED             /* stopped child has continued */
  305 };
  306 
  307 #define SI_USER SI_USER
  308 #define SI_ASYNCIO SI_ASYNCIO
  309 #define SI_MESGQ SI_MESGQ
  310 #define SI_TIMER SI_TIMER
  311 #define SI_QUEUE SI_QUEUE
  312 #define SI_KERNEL SI_KERNEL
  313 #define ILL_ILLOPC ILL_ILLOPC
  314 #define ILL_ILLOPN ILL_ILLOPN
  315 #define ILL_ILLADR ILL_ILLADR
  316 #define ILL_ILLTRP ILL_ILLTRP
  317 #define ILL_PRVOPC ILL_PRVOPC
  318 #define ILL_PRVREG ILL_PRVREG
  319 #define ILL_COPROC ILL_COPROC
  320 #define ILL_BADSTK ILL_BADSTK
  321 #define FPE_INTDIV FPE_INTDIV
  322 #define FPE_INTOVF FPE_INTOVF
  323 #define FPE_FLTDIV FPE_FLTDIV
  324 #define FPE_FLTOVF FPE_FLTOVF
  325 #define FPE_FLTUND FPE_FLTUND
  326 #define FPE_FLTRES FPE_FLTRES
  327 #define FPE_FLTINV FPE_FLTINV
  328 #define FPE_FLTSUB FPE_FLTSUB
  329 #define SEGV_MAPERR SEGV_MAPERR
  330 #define SEGV_ACCERR SEGV_ACCERR
  331 #define BUS_ADRALN BUS_ADRALN
  332 #define BUS_ADRERR BUS_ADRERR
  333 #define BUS_OBJERR BUS_OBJERR
  334 #define CLD_EXITED CLD_EXITED
  335 #define CLD_KILLED CLD_KILLED
  336 #define CLD_DUMPED CLD_DUMPED
  337 #define CLD_TRAPPED CLD_TRAPPED
  338 #define CLD_STOPPED CLD_STOPPED
  339 #define CLD_CONTINUED CLD_CONTINUED
  340 
  341 enum
  342 {
  343   SIGEV_SIGNAL = 0,         /* a queued signal, with an application
  344                        defined value, is generated when the
  345                        event of interest occurs */
  346   SIGEV_NONE,               /* no asynchronous notification is
  347                        delivered when the event of interest
  348                        occurs */
  349   SIGEV_THREAD              /* a notification function is called to
  350                        perform notification */
  351 };
  352 
  353 #define SIGEV_SIGNAL SIGEV_SIGNAL
  354 #define SIGEV_NONE   SIGEV_NONE
  355 #define SIGEV_THREAD SIGEV_THREAD
  356 
  357 typedef void (*_sig_func_ptr)(int);
  358 
  359 #if __POSIX_VISIBLE
  360 
  361 struct sigaction
  362 {
  363   __extension__ union
  364   {
  365     _sig_func_ptr sa_handler;       /* SIG_DFL, SIG_IGN, or pointer to a function */
  366 #if __POSIX_VISIBLE >= 199309
  367     void  (*sa_sigaction) ( int, siginfo_t *, void * );
  368 #endif
  369   };
  370   sigset_t sa_mask;
  371   int sa_flags;
  372 };
  373 
  374 #define SA_NOCLDSTOP 1          /* Do not generate SIGCHLD when children
  375                        stop */
  376 #define SA_SIGINFO   2          /* Invoke the signal catching function
  377                        with three arguments instead of one
  378                      */
  379 #define SA_RESTART   0x10000000     /* Restart syscall on signal return */
  380 #define SA_ONSTACK   0x20000000     /* Call signal handler on alternate
  381                        signal stack provided by
  382                        sigaltstack(2). */
  383 #define SA_NODEFER   0x40000000     /* Don't automatically block the signal
  384                        when its handler is being executed  */
  385 #define SA_RESETHAND 0x80000000     /* Reset to SIG_DFL on entry to handler */
  386 #define SA_ONESHOT   SA_RESETHAND   /* Historical linux name */
  387 #define SA_NOMASK    SA_NODEFER     /* Historical linux name */
  388 
  389 /* Used internally by cygwin.  Included here to group everything in one place.
  390    Do not use.  */
  391 #define _SA_INTERNAL_MASK 0xf000    /* bits in this range are internal */
  392 
  393 #endif /* __POSIX_VISIBLE */
  394 
  395 #if __BSD_VISIBLE || __XSI_VISIBLE >= 4 || __POSIX_VISIBLE >= 200809
  396 
  397 #undef  MINSIGSTKSZ
  398 #define MINSIGSTKSZ  8192
  399 #undef  SIGSTKSZ
  400 #define SIGSTKSZ    32768
  401 
  402 #endif /* __BSD_VISIBLE || __XSI_VISIBLE >= 4 || __POSIX_VISIBLE >= 200809 */
  403 
  404 #define SIGHUP  1   /* hangup */
  405 #define SIGINT  2   /* interrupt */
  406 #define SIGQUIT 3   /* quit */
  407 #define SIGILL  4   /* illegal instruction (not reset when caught) */
  408 #define SIGTRAP 5   /* trace trap (not reset when caught) */
  409 #define SIGABRT 6   /* used by abort */
  410 #define SIGIOT  SIGABRT /* synonym for SIGABRT on most systems */
  411 #define SIGEMT  7   /* EMT instruction */
  412 #define SIGFPE  8   /* floating point exception */
  413 #define SIGKILL 9   /* kill (cannot be caught or ignored) */
  414 #define SIGBUS  10  /* bus error */
  415 #define SIGSEGV 11  /* segmentation violation */
  416 #define SIGSYS  12  /* bad argument to system call */
  417 #define SIGPIPE 13  /* write on a pipe with no one to read it */
  418 #define SIGALRM 14  /* alarm clock */
  419 #define SIGTERM 15  /* software termination signal from kill */
  420 #define SIGURG  16  /* urgent condition on IO channel */
  421 #define SIGSTOP 17  /* sendable stop signal not from tty */
  422 #define SIGTSTP 18  /* stop signal from tty */
  423 #define SIGCONT 19  /* continue a stopped process */
  424 #define SIGCHLD 20  /* to parent on child stop or exit */
  425 #define SIGCLD  20  /* System V name for SIGCHLD */
  426 #define SIGTTIN 21  /* to readers pgrp upon background tty read */
  427 #define SIGTTOU 22  /* like TTIN for output if (tp->t_local&LTOSTOP) */
  428 #define SIGIO   23  /* input/output possible signal */
  429 #define SIGPOLL SIGIO   /* System V name for SIGIO */
  430 #define SIGXCPU 24  /* exceeded CPU time limit */
  431 #define SIGXFSZ 25  /* exceeded file size limit */
  432 #define SIGVTALRM 26    /* virtual time alarm */
  433 #define SIGPROF 27  /* profiling time alarm */
  434 #define SIGWINCH 28 /* window changed */
  435 #define SIGLOST 29  /* resource lost (eg, record-lock lost) */
  436 #define SIGPWR  SIGLOST /* power failure */
  437 #define SIGUSR1 30  /* user defined signal 1 */
  438 #define SIGUSR2 31  /* user defined signal 2 */
  439 
  440 #if __WORDSIZE == 64
  441 #define NSIG    65      /* signal 0 implied */
  442 #else
  443 #define NSIG    33      /* signal 0 implied */
  444 #endif
  445 
  446 /* Real-Time signals per SUSv3.  RT_SIGMAX is defined as 8 in limits.h */
  447 #define SIGRTMIN 32
  448 #define SIGRTMAX (NSIG - 1)
  449 
  450 #define SIG_HOLD ((_sig_func_ptr)2) /* Signal in signal mask */
  451 
  452 #if __POSIX_VISIBLE >= 200809
  453 void psiginfo (const siginfo_t *, const char *);
  454 #endif
  455 #if __POSIX_VISIBLE
  456 int sigwait (const sigset_t *, int *);
  457 #endif
  458 #if __POSIX_VISIBLE >= 199309
  459 int sigwaitinfo (const sigset_t *, siginfo_t *);
  460 #endif
  461 #if __XSI_VISIBLE >= 4
  462 int sighold (int);
  463 int sigignore (int);
  464 int sigrelse (int);
  465 _sig_func_ptr sigset (int, _sig_func_ptr);
  466 #endif
  467 
  468 #if __POSIX_VISIBLE >= 199309
  469 int sigqueue(pid_t, int, const union sigval);
  470 #endif
  471 #if __BSD_VISIBLE || __XSI_VISIBLE >= 4 || __POSIX_VISIBLE >= 200809
  472 int siginterrupt (int, int);
  473 #endif
  474 #ifdef __INSIDE_CYGWIN__
  475 extern const char *sys_sigabbrev[];
  476 extern const char *sys_siglist[];
  477 #elif __BSD_VISIBLE
  478 extern const char __declspec(dllimport) *sys_sigabbrev[];
  479 extern const char __declspec(dllimport) *sys_siglist[];
  480 #endif
  481 
  482 #ifdef __cplusplus
  483 }
  484 #endif
  485 #endif /*_CYGWIN_SIGNAL_H*/