Changeset d3ce33fa in mainline for uspace/lib/posix/signal.h


Ignore:
Timestamp:
2011-07-05T19:01:18Z (13 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d9eaa43
Parents:
4f86fa3
Message:

signal.h: Add some functions and implementations

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/posix/signal.h

    r4f86fa3 rd3ce33fa  
    3939#include "sys/types.h"
    4040
    41 /* HelenOS doesn't have signals, so calls to functions of this header
    42  * are just replaced with their respective failure return value.
    43  *
    44  * Other macros and constants are here just to satisfy the symbol resolver
    45  * and have no practical value whatsoever, until HelenOS implements some
    46  * equivalent of signals. Maybe something neat based on IPC will be devised
    47  * in the future?
    48  */
     41extern void __posix_default_signal_handler(int signo);
     42extern void __posix_hold_signal_handler(int signo);
     43extern void __posix_ignore_signal_handler(int signo);
    4944
    5045#undef SIG_DFL
    51 #define SIG_DFL ((void (*)(int)) 0)
     46#define SIG_DFL ((void (*)(int)) __posix_default_signal_handler)
    5247#undef SIG_ERR
    53 #define SIG_ERR ((void (*)(int)) 0)
     48#define SIG_ERR ((void (*)(int)) NULL)
    5449#undef SIG_HOLD
    55 #define SIG_HOLD ((void (*)(int)) 0)
     50#define SIG_HOLD ((void (*)(int)) __posix_hold_signal_handler)
    5651#undef SIG_IGN
    57 #define SIG_IGN ((void (*)(int)) 0)
     52#define SIG_IGN ((void (*)(int)) __posix_ignore_signal_handler)
    5853
    5954typedef int posix_sig_atomic_t;
    60 typedef int posix_sigset_t;
     55typedef uint32_t posix_sigset_t;
    6156typedef struct posix_mcontext {
    6257        // FIXME: should not be empty to avoid compiler warnings (-pedantic)
     
    116111/* Values of posix_sigevent::sigev_notify */
    117112#undef SIGEV_NONE
     113#undef SIGEV_SIGNAL
     114#undef SIGEV_THREAD
    118115#define SIGEV_NONE 0
    119 #undef SIGEV_SIGNAL
    120116#define SIGEV_SIGNAL 0
    121 #undef SIGEV_THREAD
    122117#define SIGEV_THREAD 0
    123118
    124119#undef SIGRT_MIN
     120#undef SIGRT_MAX
    125121#define SIGRT_MIN 0
    126 #undef SIGRT_MAX
    127122#define SIGRT_MAX 0
    128123
    129124#undef SIG_BLOCK
     125#undef SIG_UNBLOCK
     126#undef SIG_SETMASK
    130127#define SIG_BLOCK 0
    131 #undef SIG_UNBLOCK
    132 #define SIG_UNBLOCK 0
    133 #undef SIG_SETMASK
    134 #define SIG_SETMASK 0
     128#define SIG_UNBLOCK 1
     129#define SIG_SETMASK 2
    135130
    136131#undef SA_NOCLDSTOP
    137 #define SA_NOCLDSTOP 0
    138132#undef SA_ONSTACK
    139 #define SA_ONSTACK 0
    140133#undef SA_RESETHAND
    141 #define SA_RESETHAND 0
    142134#undef SA_RESTART
    143 #define SA_RESTART 0
    144135#undef SA_SIGINFO
    145 #define SA_SIGINFO 0
    146136#undef SA_NOCLDWAIT
    147 #define SA_NOCLDWAIT 0
    148137#undef SA_NODEFER
    149 #define SA_NODEFER 0
     138#define SA_NOCLDSTOP (1 << 0)
     139#define SA_ONSTACK (1 << 1)
     140#define SA_RESETHAND (1 << 2)
     141#define SA_RESTART (1 << 3)
     142#define SA_SIGINFO (1 << 4)
     143#define SA_NOCLDWAIT (1 << 5)
     144#define SA_NODEFER (1 << 6)
    150145
    151146#undef SS_ONSTACK
     147#undef SS_DISABLE
    152148#define SS_ONSTACK 0
    153 #undef SS_DISABLE
    154149#define SS_DISABLE 0
    155150
    156151#undef MINSIGSTKSZ
     152#undef SIGSTKSZ
    157153#define MINSIGSTKSZ 0
    158 #undef SIGSTKSZ
    159154#define SIGSTKSZ 0
    160155
    161156/* full POSIX set */
    162157enum {
     158        /* Termination Signals */
    163159        SIGABRT,
     160        SIGQUIT,
     161        SIGINT,
     162        SIGTERM,
     163       
     164        /* Child Signal */
     165        SIGCHLD,
     166       
     167        /* User signals */
     168        SIGUSR1,
     169        SIGUSR2,
     170
     171        /* Timer */
    164172        SIGALRM,
     173        SIGVTALRM,
     174        SIGPROF, /* obsolete */
     175
     176        _TOP_CATCHABLE_SIGNAL = SIGPROF,
     177
     178        /* Process Scheduler Interaction - not supported */
     179        SIGSTOP,
     180        SIGCONT,
     181
     182        /* Process Termination - can't be caught */
     183        SIGKILL,
     184
     185        _TOP_SENDABLE_SIGNAL = SIGKILL,
     186
     187        /* Hardware Exceptions - can't be caught or sent */
     188        SIGFPE,
    165189        SIGBUS,
    166         SIGCHLD,
    167         SIGCONT,
    168         SIGFPE,
     190        SIGILL,
     191        SIGSEGV,
     192
     193        /* Other Exceptions - not supported */
     194        SIGSYS,
     195        SIGXCPU,
     196        SIGXFSZ,
     197
     198        /* Debugging - not supported */
     199        SIGTRAP,
     200
     201        /* Communication Signals - not supported */
    169202        SIGHUP,
    170         SIGILL,
    171         SIGINT,
    172         SIGKILL,
    173203        SIGPIPE,
    174         SIGQUIT,
    175         SIGSEGV,
    176         SIGSTOP,
    177         SIGTERM,
     204        SIGPOLL, /* obsolete */
     205        SIGURG,
     206
     207        /* Terminal Signals - not supported */
    178208        SIGTSTP,
    179209        SIGTTIN,
    180210        SIGTTOU,
    181         SIGUSR1,
    182         SIGUSR2,
    183         SIGPOLL,
    184         SIGPROF,
    185         SIGSYS,
    186         SIGTRAP,
    187         SIGURG,
    188         SIGVTALRM,
    189         SIGXCPU,
    190         SIGXFSZ
    191 };
     211       
     212        _TOP_SIGNAL = SIGTTOU
     213};
     214
     215/* Values for sigaction field si_code. */
     216
     217enum {
     218        SI_USER,
     219        SI_QUEUE,
     220        SI_TIMER,
     221        SI_ASYNCIO,
     222        SI_MESGQ,
     223        ILL_ILLOPC,
     224        ILL_ILLOPN,
     225        ILL_ILLADR,
     226        ILL_ILLTRP,
     227        ILL_PRVOPC,
     228        ILL_PRVREG,
     229        ILL_COPROC,
     230        ILL_BADSTK,
     231        FPE_INTDIV,
     232        FPE_INTOVF,
     233        FPE_FLTDIV,
     234        FPE_FLTOVF,
     235        FPE_FLTUND,
     236        FPE_FLTRES,
     237        FPE_FLTINV,
     238        FPE_FLTSUB,
     239        SEGV_MAPERR,
     240        SEGV_ACCERR,
     241        BUS_ADRALN,
     242        BUS_ADRERR,
     243        BUS_OBJERR,
     244        TRAP_BRKPT,
     245        TRAP_TRACE,
     246        CLD_EXITED,
     247        CLD_KILLED,
     248        CLD_DUMPED,
     249        CLD_TRAPPED,
     250        CLD_STOPPED,
     251        CLD_CONTINUED,
     252        POLL_IN,
     253        POLL_OUT,
     254        POLL_MSG,
     255        POLL_ERR,
     256        POLL_PRI,
     257        POLL_HUP
     258};
     259
     260extern int posix_sigaction(int sig, const struct posix_sigaction *restrict act,
     261    struct posix_sigaction *restrict oact);
    192262
    193263extern void (*posix_signal(int sig, void (*func)(int)))(int);
    194264extern int posix_raise(int sig);
    195265extern int posix_kill(posix_pid_t pid, int sig);
    196 
     266extern int posix_killpg(posix_pid_t pid, int sig);
     267
     268extern void posix_psiginfo(const posix_siginfo_t *pinfo, const char *message);
     269extern void posix_psignal(int signum, const char *message);
     270
     271extern int posix_sigemptyset(posix_sigset_t *set);
     272extern int posix_sigfillset(posix_sigset_t *set);
    197273extern int posix_sigaddset(posix_sigset_t *set, int signo);
    198 extern int posix_sigemptyset(posix_sigset_t *set);
     274extern int posix_sigdelset(posix_sigset_t *set, int signo);
     275extern int posix_sigismember(const posix_sigset_t *set, int signo);
     276
     277extern int posix_thread_sigmask(int how, const posix_sigset_t *restrict set,
     278    posix_sigset_t *restrict oset);
    199279extern int posix_sigprocmask(int how, const posix_sigset_t *restrict set,
    200280    posix_sigset_t *restrict oset);
     
    214294        #define raise posix_raise
    215295        #define kill posix_kill
     296        #define killpg posix_killpg
     297
     298        #define psiginfo posix_psiginfo
     299        #define psignal posix_psignal
     300
     301        #define sigemptyset posix_sigemptyset
     302        #define sigfillset posix_sigfillset
    216303        #define sigaddset posix_sigaddset
    217         #define sigemptyset posix_sigemptyset
     304        #define sigdelset posix_sigdelset
     305        #define sigismember posix_sigismember
     306
     307        #define pthread_sigmask posix_thread_sigmask
    218308        #define sigprocmask posix_sigprocmask
    219309#endif
Note: See TracChangeset for help on using the changeset viewer.