Rework libc signal constants (#2724)

* Move libc::SIG* constants to posix.c3

* Add missing libc::SIG* constants for Win32 systems

* Add missing POSIX signals

* Add missing Linux signals

* Add missing BSD signals

* Moved common signals back to libc

---------

Co-authored-by: Christoffer Lerno <christoffer@aegik.com>
This commit is contained in:
Jasper Wilmes
2026-01-15 21:17:50 +01:00
committed by GitHub
parent 7f297a9d27
commit 8a1c02c840
5 changed files with 48 additions and 16 deletions

View File

@@ -57,27 +57,12 @@ alias Fd = CInt;
alias Fpos_t @if(env::WIN32) = long;
alias SignalFunction = fn void(CInt);
const CInt SIGHUP = 1;
// Common signals for all targets
const CInt SIGINT = 2;
const CInt SIGQUIT = 3;
const CInt SIGILL = 4;
const CInt SIGTRAP = 5;
const CInt SIGABRT = 6;
const CInt SIGBUS = BSD_FLAVOR_SIG ? 10 : 7; // Or Mips
const CInt SIGFPE = 8;
const CInt SIGKILL = 9;
const CInt SIGSEGV = 11;
const CInt SIGSYS = BSD_FLAVOR_SIG ? 12 : 31;
const CInt SIGPIPE = 13;
const CInt SIGALRM = 14;
const CInt SIGTERM = 15;
const CInt SIGURG = BSD_FLAVOR_SIG ? 16 : 23;
const CInt SIGSTOP = BSD_FLAVOR_SIG ? 17 : 19;
const CInt SIGTSTP = BSD_FLAVOR_SIG ? 18 : 20;
const CInt SIGCONT = BSD_FLAVOR_SIG ? 19 : 18;
const CInt SIGCHLD = BSD_FLAVOR_SIG ? 20 : 17;
const bool BSD_FLAVOR_SIG @local = env::DARWIN || env::BSD_FAMILY;
alias Time_t = $typefrom(env::WIN32 ? long.typeid : CLong.typeid);
alias Off_t = $typefrom(env::WIN32 ? int.typeid : isz.typeid);

View File

@@ -0,0 +1,8 @@
module libc @if(env::DARWIN ||| env::BSD_FAMILY);
const CInt SIGIOT = 6;
const CInt SIGEMT = 7;
const CInt SIGIO = 23;
const CInt SIGPROF = 27;
const CInt SIGINFO = 29;
const CInt SIGTHR = 32;

View File

@@ -60,3 +60,12 @@ extern fn CInt stat(ZString path, Stat* stat);
extern fn CInt get_nprocs();
extern fn CInt get_nprocs_conf();
// Additional Linux signals
const CInt SIGIOT = 6;
const CInt SIGSTKFLT = 16;
const CInt SIGPROF = 27;
const CInt SIGIO = 29;
const CInt SIGPOLL = 29;
const CInt SIGPWR = 30;
const CInt SIGUNUSED = 31;

View File

@@ -69,6 +69,32 @@ extern fn CInt sigaction(CInt signum, Sigaction *action, Sigaction *oldaction) @
extern fn CInt sigemptyset(Sigset_t* set) @if(!env::NETBSD);
extern fn CInt sigemptyset(Sigset_t* set) @cname("__sigemptyset14") @if(env::NETBSD);
const CInt SIGHUP = 1;
const CInt SIGQUIT = 3;
const CInt SIGTRAP = 5;
const CInt SIGABRT = 6;
const CInt SIGKILL = 9;
const CInt SIGBUS = BSD_FLAVOR_SIG ? 10 : 7; // Or Mips
const CInt SIGSYS = BSD_FLAVOR_SIG ? 12 : 31;
const CInt SIGPIPE = 13;
const CInt SIGALRM = 14;
const CInt SIGURG = BSD_FLAVOR_SIG ? 16 : 23;
const CInt SIGSTOP = BSD_FLAVOR_SIG ? 17 : 19;
const CInt SIGTSTP = BSD_FLAVOR_SIG ? 18 : 20;
const CInt SIGCONT = BSD_FLAVOR_SIG ? 19 : 18;
const CInt SIGCHLD = BSD_FLAVOR_SIG ? 20 : 17;
const CInt SIGTTIN = 21;
const CInt SIGTTOU = 22;
const CInt SIGXCPU = 24;
const CInt SIGXFSZ = 25;
const CInt SIGVTALRM = 26;
const CInt SIGWINCH = 28;
const CInt SIGUSR1 = BSD_FLAVOR_SIG ? 30 : 10;
const CInt SIGUSR2 = BSD_FLAVOR_SIG ? 31 : 12;
const bool BSD_FLAVOR_SIG @local = env::DARWIN || env::BSD_FAMILY;
module libc::termios @if(env::LIBC &&& env::POSIX);
bitstruct Tc_iflags : CUInt

View File

@@ -70,3 +70,7 @@ macro CInt setjmp(JmpBuf* buffer) => _setjmp(buffer, null);
macro Tm* gmtime_r(Time_t* timer, Tm* buf) => _gmtime64_s(buf, timer);
macro isz read(Fd fd, void* buffer, usz buffer_size) => _read(fd, buffer, (CUInt)buffer_size);
macro isz write(Fd fd, void* buffer, usz count) => _write(fd, buffer, (CUInt)count);
const CInt SIGABRT_COMPAT = 6;
const CInt SIGBREAK = 21;
const CInt SIGABRT = 22;