From cd05653ac1212b51dbb22384c85e5871302a8cc9 Mon Sep 17 00:00:00 2001 From: bptato Date: Fri, 1 Nov 2024 23:14:58 +0100 Subject: [PATCH] Fix POSIX signal(3) binding's type signature; remove bsd_signal POSIX signal has an identical definition to ISO C signal: https://pubs.opengroup.org/onlinepubs/9799919799/functions/signal.html ```c void (*signal(int sig, void (*func)(int)))(int); /* more readably restated by glibc as */ typedef void (*sighandler_t)(int); sighandler_t signal(int signum, sighandler_t handler); ``` However, std/posix had omitted the function's return value; this fixes that. To prevent breaking every single line of code ever that touched this binding (including mine...), I've also made it discardable. Additionally, I have noticed that bsd_signal's type signature is wrong - it should have been identical to signal. But bsd_signal was already removed in POSIX 2008, and sigaction is the recommended, portable POSIX signal interface. So I just deleted the bsd_signal binding. --- lib/posix/posix.nim | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/posix/posix.nim b/lib/posix/posix.nim index ca3ca12757d49..7c4c70c9c3a39 100644 --- a/lib/posix/posix.nim +++ b/lib/posix/posix.nim @@ -778,8 +778,6 @@ const proc getrusage*(who: cint, rusage: ptr Rusage): cint {.importc, header: "", discardable.} -proc bsd_signal*(a1: cint, a2: proc (x: pointer) {.noconv.}) {. - importc, header: "".} proc kill*(a1: Pid, a2: cint): cint {.importc, header: "", sideEffect.} proc killpg*(a1: Pid, a2: cint): cint {.importc, header: "", sideEffect.} proc pthread_kill*(a1: Pthread, a2: cint): cint {.importc, header: "".} @@ -801,8 +799,8 @@ proc sighold*(a1: cint): cint {.importc, header: "".} proc sigignore*(a1: cint): cint {.importc, header: "".} proc siginterrupt*(a1, a2: cint): cint {.importc, header: "".} proc sigismember*(a1: var Sigset, a2: cint): cint {.importc, header: "".} -proc signal*(a1: cint, a2: Sighandler) {. - importc, header: "".} +proc signal*(a1: cint, a2: Sighandler): Sighandler {. + importc, discardable, header: "".} proc sigpause*(a1: cint): cint {.importc, header: "".} proc sigpending*(a1: var Sigset): cint {.importc, header: "".} proc sigprocmask*(a1: cint, a2, a3: var Sigset): cint {.