From 797301ace8f0ce7e3e43eac9d5fbb11c0f6f615a Mon Sep 17 00:00:00 2001 From: Jacek Sieka Date: Tue, 16 May 2017 20:45:10 +0800 Subject: [PATCH] add back SIG_IGN, SIG_DFL and friends to posix.nim (#5820) * add back SIG_IGN, SIG_DFL and friends to posix.nim accidentally wiped by ce86b4ad78aae11f62c50e4f46e8ab2a124356b4 * move deprecated sig_hold after consts include --- lib/posix/posix.nim | 8 +++++++- lib/posix/posix_linux_amd64.nim | 3 +++ lib/posix/posix_linux_amd64_consts.nim | 3 +++ lib/posix/posix_other_consts.nim | 4 ++++ tools/detect/detect.nim | 11 ++++++++++- 5 files changed, 27 insertions(+), 2 deletions(-) diff --git a/lib/posix/posix.nim b/lib/posix/posix.nim index 02312a4d52..55d1dd2ebd 100644 --- a/lib/posix/posix.nim +++ b/lib/posix/posix.nim @@ -79,6 +79,9 @@ const DT_SOCK* = 12 ## UNIX domain socket. DT_WHT* = 14 +# Special types +type Sighandler = proc (a: cint) {.noconv.} + # Platform specific stuff when defined(linux) and defined(amd64): @@ -86,6 +89,9 @@ when defined(linux) and defined(amd64): else: include posix_other +# There used to be this name in posix.nim a long time ago, not sure why! +{.deprecated: [cSIG_HOLD: SIG_HOLD].} + when not defined(macosx): proc st_atime*(s: Stat): Time {.inline.} = ## Second-granularity time of last access @@ -659,7 +665,7 @@ 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: proc (x: cint) {.noconv.}) {. +proc signal*(a1: cint, a2: Sighandler) {. importc, header: "".} proc sigpause*(a1: cint): cint {.importc, header: "".} proc sigpending*(a1: var Sigset): cint {.importc, header: "".} diff --git a/lib/posix/posix_linux_amd64.nim b/lib/posix/posix_linux_amd64.nim index 70f7e710f5..c44128b16c 100644 --- a/lib/posix/posix_linux_amd64.nim +++ b/lib/posix/posix_linux_amd64.nim @@ -36,6 +36,9 @@ type {.deprecated: [TSocketHandle: SocketHandle].} +# not detected by detect.nim, guarded by #ifdef __USE_UNIX98 in glibc +const SIG_HOLD* = cast[SigHandler](2) + type Timespec* {.importc: "struct timespec", header: "", final, pure.} = object ## struct timespec diff --git a/lib/posix/posix_linux_amd64_consts.nim b/lib/posix/posix_linux_amd64_consts.nim index 9e2ed32e1d..4b693960e6 100644 --- a/lib/posix/posix_linux_amd64_consts.nim +++ b/lib/posix/posix_linux_amd64_consts.nim @@ -399,6 +399,9 @@ const SS_ONSTACK* = cint(1) const SS_DISABLE* = cint(2) const MINSIGSTKSZ* = cint(2048) const SIGSTKSZ* = cint(8192) +const SIG_DFL* = cast[Sighandler](0) +const SIG_ERR* = cast[Sighandler](-1) +const SIG_IGN* = cast[Sighandler](1) # const IPC_CREAT* = cint(512) diff --git a/lib/posix/posix_other_consts.nim b/lib/posix/posix_other_consts.nim index f2a71d1bde..003414a6a8 100644 --- a/lib/posix/posix_other_consts.nim +++ b/lib/posix/posix_other_consts.nim @@ -414,6 +414,10 @@ var SS_ONSTACK* {.importc: "SS_ONSTACK", header: "".}: cint var SS_DISABLE* {.importc: "SS_DISABLE", header: "".}: cint var MINSIGSTKSZ* {.importc: "MINSIGSTKSZ", header: "".}: cint var SIGSTKSZ* {.importc: "SIGSTKSZ", header: "".}: cint +var SIG_HOLD* {.importc: "SIG_HOLD", header: "".}: Sighandler +var SIG_DFL* {.importc: "SIG_DFL", header: "".}: Sighandler +var SIG_ERR* {.importc: "SIG_ERR", header: "".}: Sighandler +var SIG_IGN* {.importc: "SIG_IGN", header: "".}: Sighandler # var IPC_CREAT* {.importc: "IPC_CREAT", header: "".}: cint diff --git a/tools/detect/detect.nim b/tools/detect/detect.nim index 3afe8ee671..1b016cef9c 100644 --- a/tools/detect/detect.nim +++ b/tools/detect/detect.nim @@ -119,10 +119,14 @@ proc v(name: string, typ = "cint", no_other = false) = addf(tl, "#ifdef $3\n fprintf(f, \"const $1* = $2(%ld)\\n\", $3);\n#endif\n", n, t, name) - else: + of "cint", "cshort", "InAddrScalar", "TSa_Family": addf(tl, "#ifdef $3\n fprintf(f, \"const $1* = $2(%d)\\n\", $3);\n#endif\n", n, t, name) + else: + addf(tl, + "#ifdef $3\n fprintf(f, \"const $1* = cast[$2](%d)\\n\", $3);\n#endif\n", + n, t, name) header("") @@ -544,6 +548,11 @@ v("SS_DISABLE") v("MINSIGSTKSZ") v("SIGSTKSZ") +v("SIG_HOLD", "Sighandler") +v("SIG_DFL", "Sighandler") +v("SIG_ERR", "Sighandler") +v("SIG_IGN", "Sighandler") + header("") v("IPC_CREAT") v("IPC_EXCL")