mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Forward declare <signal.h> API.
This commit is contained in:
parent
29df8b3092
commit
615bf32c60
2 changed files with 166 additions and 12 deletions
|
@ -1,6 +1,6 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012.
|
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013.
|
||||||
|
|
||||||
This file is part of the Sortix C Library.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
|
@ -22,29 +22,179 @@
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
/* TODO: This does not fully implement POSIX 2008-1 yet! */
|
#ifndef INCLUDE_SIGNAL_H
|
||||||
|
#define INCLUDE_SIGNAL_H
|
||||||
#ifndef _SIGNAL_H
|
|
||||||
#define _SIGNAL_H 1
|
|
||||||
|
|
||||||
#include <features.h>
|
#include <features.h>
|
||||||
#include <sortix/signal.h>
|
#include <sortix/signal.h>
|
||||||
#include <sortix/sigset.h>
|
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
@include(pid_t.h);
|
@include(uid_t.h)
|
||||||
|
@include(pid_t.h)
|
||||||
|
@include(size_t.h)
|
||||||
|
/* TODO: POSIX says this header declares struct timespec, but not time_t... */
|
||||||
|
@include(time_t.h)
|
||||||
|
/* TODO: pthread_t */
|
||||||
|
/* TODO: pthread_attr_t */
|
||||||
|
|
||||||
|
__END_DECLS
|
||||||
|
|
||||||
|
#include <sortix/sigset.h>
|
||||||
|
#include <sortix/timespec.h>
|
||||||
|
|
||||||
|
__BEGIN_DECLS
|
||||||
|
|
||||||
|
/* TODO: Should this be volatile? It isn't on Linux. */
|
||||||
typedef int sig_atomic_t;
|
typedef int sig_atomic_t;
|
||||||
|
|
||||||
typedef void (*sighandler_t)(int);
|
typedef void (*sighandler_t)(int);
|
||||||
|
|
||||||
void SIG_DFL(int signum);
|
void SIG_DFL(int);
|
||||||
void SIG_IGN(int signum);
|
void SIG_IGN(int);
|
||||||
void SIG_ERR(int signum);
|
void SIG_ERR(int);
|
||||||
|
|
||||||
sighandler_t signal(int signum, sighandler_t handler);
|
#define SIG_DFL SIG_DFL
|
||||||
int kill(pid_t pid, int sig);
|
#define SIG_IGN SIG_IGN
|
||||||
|
#define SIG_ERR SIG_ERR
|
||||||
|
/* TODO: POSIX specifies a obsolecent SIG_HOLD here. */
|
||||||
|
|
||||||
|
union sigval
|
||||||
|
{
|
||||||
|
int sival_int;
|
||||||
|
void* sival_ptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct sigevent
|
||||||
|
{
|
||||||
|
int sigev_notify;
|
||||||
|
int sigev_signo;
|
||||||
|
union sigval sigev_value;
|
||||||
|
void (*sigev_notify_function)(union sigval);
|
||||||
|
/*pthread_attr_t* sigev_notify_attributes;*/
|
||||||
|
};
|
||||||
|
|
||||||
|
#define SIGEV_NONE 0
|
||||||
|
#define SIGEV_SIGNAL 1
|
||||||
|
#define SIGEV_THREAD 2
|
||||||
|
|
||||||
|
/* TODO: SIGRTMIN */
|
||||||
|
/* TODO: SIGRTMAX */
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int si_signo;
|
||||||
|
int si_code;
|
||||||
|
int si_errno;
|
||||||
|
pid_t si_pid;
|
||||||
|
uid_t si_uid;
|
||||||
|
void* si_addr;
|
||||||
|
int si_status;
|
||||||
|
union sigval si_value;
|
||||||
|
} siginfo_t;
|
||||||
|
|
||||||
|
#define ILL_ILLOPC 1
|
||||||
|
#define ILL_ILLOPN 2
|
||||||
|
#define ILL_ILLADR 3
|
||||||
|
#define ILL_ILLTRP 4
|
||||||
|
#define ILL_PRVOPC 5
|
||||||
|
#define ILL_PRVREG 6
|
||||||
|
#define ILL_COPROC 7
|
||||||
|
#define ILL_BADSTK 8
|
||||||
|
#define FPE_INTDIV 9
|
||||||
|
#define FPE_INTOVF 10
|
||||||
|
#define FPE_FLTDIV 11
|
||||||
|
#define FPE_FLTOVF 12
|
||||||
|
#define FPE_FLTUND 13
|
||||||
|
#define FPE_FLTRES 14
|
||||||
|
#define FPE_FLTINV 15
|
||||||
|
#define FPE_FLTSUB 16
|
||||||
|
#define SEGV_MAPERR 17
|
||||||
|
#define SEGV_ACCERR 18
|
||||||
|
#define BUS_ADRALN 19
|
||||||
|
#define BUS_ADRERR 20
|
||||||
|
#define BUS_OBJERR 21
|
||||||
|
#define TRAP_BRKPT 22
|
||||||
|
#define TRAP_TRACE 23
|
||||||
|
#define CLD_EXITED 24
|
||||||
|
#define CLD_KILLED 25
|
||||||
|
#define CLD_DUMPED 26
|
||||||
|
#define CLD_TRAPPED 27
|
||||||
|
#define CLD_STOPPED 29
|
||||||
|
#define CLD_CONTINUED 30
|
||||||
|
#define SI_USER 31
|
||||||
|
#define SI_QUEUE 32
|
||||||
|
#define SI_TIMER 33
|
||||||
|
#define SI_ASYNCIO 34
|
||||||
|
#define SI_MSGQ 35
|
||||||
|
|
||||||
|
struct sigaction
|
||||||
|
{
|
||||||
|
void (*sa_handler)(int);
|
||||||
|
void (*sa_sigaction)(int, siginfo_t*, void*);
|
||||||
|
sigset_t sa_mask;
|
||||||
|
int sa_flags;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define SA_NOCLDSTOP (1<<0)
|
||||||
|
#define SA_ONSTACK (1<<1)
|
||||||
|
#define SA_RESETHAND (1<<2)
|
||||||
|
#define SA_RESTART (1<<3)
|
||||||
|
#define SA_SIGINFO (1<<4)
|
||||||
|
#define SA_NOCLDWAIT (1<<5)
|
||||||
|
#define SA_NODEFER (1<<6)
|
||||||
|
#define SS_ONSTACK (1<<7)
|
||||||
|
#define SS_DISABLE (1<<8)
|
||||||
|
/* TODO: MINSIGSTKSZ */
|
||||||
|
/* TODO: SIGSTKSZ */
|
||||||
|
|
||||||
|
/* TODO: mcontext_t */
|
||||||
|
typedef int mcontext_t;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
void* ss_sp;
|
||||||
|
size_t ss_size;
|
||||||
|
int ss_flags;
|
||||||
|
} stack_t;
|
||||||
|
|
||||||
|
typedef struct __ucontext ucontext_t;
|
||||||
|
struct __ucontext
|
||||||
|
{
|
||||||
|
ucontext_t* uc_link;
|
||||||
|
sigset_t uc_sigmask;
|
||||||
|
stack_t uc_stack;
|
||||||
|
mcontext_t uc_mcontext;
|
||||||
|
};
|
||||||
|
|
||||||
|
int kill(pid_t, int);
|
||||||
|
int killpg(pid_t, int);
|
||||||
|
void psiginfo(const siginfo_t*, const char*);
|
||||||
|
void psignal(int, const char*);
|
||||||
|
int pthread_sigmask(int, const sigset_t* __restrict, sigset_t* __restrict);
|
||||||
int raise(int sig);
|
int raise(int sig);
|
||||||
|
int sigaction(int, const struct sigaction* __restrict, struct sigaction* __restrict);
|
||||||
|
int sigaddset(sigset_t*, int);
|
||||||
|
int sigaltstack(const stack_t* __restrict, stack_t* __restrict);
|
||||||
|
int sigdelset(sigset_t*, int);
|
||||||
|
int sigemptyset(sigset_t*);
|
||||||
|
int sigfillset(sigset_t*);
|
||||||
|
/* TODO: sighold (obsolescent XSI). */
|
||||||
|
/* TODO: sigignore (obsolescent XSI). */
|
||||||
|
/* TODO: siginterrupt (obsolescent XSI). */
|
||||||
|
int sigismember(const sigset_t*, int);
|
||||||
|
sighandler_t signal(int, sighandler_t);
|
||||||
|
/* TODO: sigpause (obsolescent XSI). */
|
||||||
|
int sigpending(sigset_t*);
|
||||||
|
int sigprocmask(int, const sigset_t* __restrict, sigset_t* __restrict);
|
||||||
|
int sigqueue(pid_t, int, const union sigval);
|
||||||
|
/* TODO: sigrelse (obsolescent XSI). */
|
||||||
|
/* TODO: sigset (obsolescent XSI). */
|
||||||
|
int sigsuspend(const sigset_t*);
|
||||||
|
int sigtimedwait(const sigset_t* __restrict, siginfo_t* __restrict,
|
||||||
|
const struct timespec* __restrict);
|
||||||
|
int sigwait(const sigset_t* __restrict, int* __restrict);
|
||||||
|
int sigwaitinfo(const sigset_t* __restrict, siginfo_t* vrestrict);
|
||||||
|
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,10 @@ __BEGIN_DECLS
|
||||||
#define SIG_PRIO_KILL 4
|
#define SIG_PRIO_KILL 4
|
||||||
#define SIG_NUM_LEVELS 5
|
#define SIG_NUM_LEVELS 5
|
||||||
|
|
||||||
|
#define SIG_BLOCK 0
|
||||||
|
#define SIG_UNBLOCK 1
|
||||||
|
#define SIG_SETMASK 2
|
||||||
|
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue