Skip to content

Commit 483389d

Browse files
bptatoringabout
andauthored
Fix POSIX signal(3) binding's type signature; remove bsd_signal (#24400)
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. Co-authored-by: ringabout <[email protected]>
1 parent cc49bf0 commit 483389d

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

lib/posix/posix.nim

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -783,8 +783,6 @@ const
783783
proc getrusage*(who: cint, rusage: ptr Rusage): cint
784784
{.importc, header: "<sys/resource.h>", discardable.}
785785

786-
proc bsd_signal*(a1: cint, a2: proc (x: pointer) {.noconv.}) {.
787-
importc, header: "<signal.h>".}
788786
proc kill*(a1: Pid, a2: cint): cint {.importc, header: "<signal.h>", sideEffect.}
789787
proc killpg*(a1: Pid, a2: cint): cint {.importc, header: "<signal.h>", sideEffect.}
790788
proc pthread_kill*(a1: Pthread, a2: cint): cint {.importc, header: "<signal.h>".}
@@ -806,8 +804,8 @@ proc sighold*(a1: cint): cint {.importc, header: "<signal.h>".}
806804
proc sigignore*(a1: cint): cint {.importc, header: "<signal.h>".}
807805
proc siginterrupt*(a1, a2: cint): cint {.importc, header: "<signal.h>".}
808806
proc sigismember*(a1: var Sigset, a2: cint): cint {.importc, header: "<signal.h>".}
809-
proc signal*(a1: cint, a2: Sighandler) {.
810-
importc, header: "<signal.h>".}
807+
proc signal*(a1: cint, a2: Sighandler): Sighandler {.
808+
importc, discardable, header: "<signal.h>".}
811809
proc sigpause*(a1: cint): cint {.importc, header: "<signal.h>".}
812810
proc sigpending*(a1: var Sigset): cint {.importc, header: "<signal.h>".}
813811
proc sigprocmask*(a1: cint, a2, a3: var Sigset): cint {.

0 commit comments

Comments
 (0)