diff options
-rw-r--r-- | lib/posix/posix.nim | 8 | ||||
-rw-r--r-- | lib/posix/posix_linux_amd64.nim | 3 | ||||
-rw-r--r-- | lib/posix/posix_linux_amd64_consts.nim | 3 | ||||
-rw-r--r-- | lib/posix/posix_other_consts.nim | 4 | ||||
-rw-r--r-- | 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 02312a4d5..55d1dd2eb 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: "<signal.h>".} proc sigignore*(a1: cint): cint {.importc, header: "<signal.h>".} proc siginterrupt*(a1, a2: cint): cint {.importc, header: "<signal.h>".} proc sigismember*(a1: var Sigset, a2: cint): cint {.importc, header: "<signal.h>".} -proc signal*(a1: cint, a2: proc (x: cint) {.noconv.}) {. +proc signal*(a1: cint, a2: Sighandler) {. importc, header: "<signal.h>".} proc sigpause*(a1: cint): cint {.importc, header: "<signal.h>".} proc sigpending*(a1: var Sigset): cint {.importc, header: "<signal.h>".} diff --git a/lib/posix/posix_linux_amd64.nim b/lib/posix/posix_linux_amd64.nim index 70f7e710f..c44128b16 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: "<time.h>", final, pure.} = object ## struct timespec diff --git a/lib/posix/posix_linux_amd64_consts.nim b/lib/posix/posix_linux_amd64_consts.nim index 9e2ed32e1..4b693960e 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) # <sys/ipc.h> const IPC_CREAT* = cint(512) diff --git a/lib/posix/posix_other_consts.nim b/lib/posix/posix_other_consts.nim index f2a71d1bd..003414a6a 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: "<signal.h>".}: cint var SS_DISABLE* {.importc: "SS_DISABLE", header: "<signal.h>".}: cint var MINSIGSTKSZ* {.importc: "MINSIGSTKSZ", header: "<signal.h>".}: cint var SIGSTKSZ* {.importc: "SIGSTKSZ", header: "<signal.h>".}: cint +var SIG_HOLD* {.importc: "SIG_HOLD", header: "<signal.h>".}: Sighandler +var SIG_DFL* {.importc: "SIG_DFL", header: "<signal.h>".}: Sighandler +var SIG_ERR* {.importc: "SIG_ERR", header: "<signal.h>".}: Sighandler +var SIG_IGN* {.importc: "SIG_IGN", header: "<signal.h>".}: Sighandler # <sys/ipc.h> var IPC_CREAT* {.importc: "IPC_CREAT", header: "<sys/ipc.h>".}: cint diff --git a/tools/detect/detect.nim b/tools/detect/detect.nim index 3afe8ee67..1b016cef9 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("<aio.h>") @@ -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("<sys/ipc.h>") v("IPC_CREAT") v("IPC_EXCL") |