Linux updates (#14170)
* Add posix_memalign() * Add linux-specific open() flags O_TMPFILE: since Linux 3.11 O_PATH: since Linux 2.6.39 O_NOATIME: since Linux 2.6.8 O_DIRECT: since Linux 2.4.10 * Fix Stat type * Fix POSIX AF_INET* const generation
This commit is contained in:
parent
44f377ff5e
commit
c817e85f4c
4 changed files with 33 additions and 14 deletions
|
|
@ -1043,6 +1043,8 @@ proc mkdtemp*(tmpl: cstring): pointer {.importc, header: "<stdlib.h>", sideEffec
|
||||||
when defined(linux) or defined(bsd):
|
when defined(linux) or defined(bsd):
|
||||||
proc mkostemp*(tmpl: cstring, oflags: cint): cint {.importc, header: "<stdlib.h>", sideEffect.}
|
proc mkostemp*(tmpl: cstring, oflags: cint): cint {.importc, header: "<stdlib.h>", sideEffect.}
|
||||||
|
|
||||||
|
proc posix_memalign*(memptr: pointer, alignment: csize_t, size: csize_t): cint {.importc, header: "<stdlib.h>".}
|
||||||
|
|
||||||
proc utimes*(path: cstring, times: ptr array[2, Timeval]): int {.
|
proc utimes*(path: cstring, times: ptr array[2, Timeval]): int {.
|
||||||
importc: "utimes", header: "<sys/time.h>", sideEffect.}
|
importc: "utimes", header: "<sys/time.h>", sideEffect.}
|
||||||
## Sets file access and modification times.
|
## Sets file access and modification times.
|
||||||
|
|
|
||||||
|
|
@ -34,9 +34,6 @@ type
|
||||||
type
|
type
|
||||||
SocketHandle* = distinct cint # The type used to represent socket descriptors
|
SocketHandle* = distinct cint # The type used to represent socket descriptors
|
||||||
|
|
||||||
# not detected by detect.nim, guarded by #ifdef __USE_UNIX98 in glibc
|
|
||||||
const SIG_HOLD* = cast[Sighandler](2)
|
|
||||||
|
|
||||||
type
|
type
|
||||||
Time* {.importc: "time_t", header: "<time.h>".} = distinct clong
|
Time* {.importc: "time_t", header: "<time.h>".} = distinct clong
|
||||||
|
|
||||||
|
|
@ -228,7 +225,7 @@ type
|
||||||
st_mode*: Mode ## Mode of file (see below).
|
st_mode*: Mode ## Mode of file (see below).
|
||||||
st_uid*: Uid ## User ID of file.
|
st_uid*: Uid ## User ID of file.
|
||||||
st_gid*: Gid ## Group ID of file.
|
st_gid*: Gid ## Group ID of file.
|
||||||
pad0: cint
|
pad0 {.importc: "__pad0".}: cint
|
||||||
st_rdev*: Dev ## Device ID (if file is character or block special).
|
st_rdev*: Dev ## Device ID (if file is character or block special).
|
||||||
st_size*: Off ## For regular files, the file size in bytes.
|
st_size*: Off ## For regular files, the file size in bytes.
|
||||||
## For symbolic links, the length in bytes of the
|
## For symbolic links, the length in bytes of the
|
||||||
|
|
@ -244,8 +241,6 @@ type
|
||||||
st_atim*: Timespec ## Time of last access.
|
st_atim*: Timespec ## Time of last access.
|
||||||
st_mtim*: Timespec ## Time of last data modification.
|
st_mtim*: Timespec ## Time of last data modification.
|
||||||
st_ctim*: Timespec ## Time of last status change.
|
st_ctim*: Timespec ## Time of last status change.
|
||||||
reserved: array[3, clong]
|
|
||||||
|
|
||||||
|
|
||||||
Statvfs* {.importc: "struct statvfs", header: "<sys/statvfs.h>",
|
Statvfs* {.importc: "struct statvfs", header: "<sys/statvfs.h>",
|
||||||
final, pure.} = object ## struct statvfs
|
final, pure.} = object ## struct statvfs
|
||||||
|
|
@ -573,8 +568,6 @@ var
|
||||||
# Regenerate using detect.nim!
|
# Regenerate using detect.nim!
|
||||||
include posix_linux_amd64_consts
|
include posix_linux_amd64_consts
|
||||||
|
|
||||||
const POSIX_SPAWN_USEVFORK* = cint(0x40) # needs _GNU_SOURCE!
|
|
||||||
|
|
||||||
# <sys/wait.h>
|
# <sys/wait.h>
|
||||||
proc WEXITSTATUS*(s: cint): cint = (s and 0xff00) shr 8
|
proc WEXITSTATUS*(s: cint): cint = (s and 0xff00) shr 8
|
||||||
proc WTERMSIG*(s:cint): cint = s and 0x7f
|
proc WTERMSIG*(s:cint): cint = s and 0x7f
|
||||||
|
|
|
||||||
|
|
@ -128,6 +128,10 @@ const O_RDONLY* = cint(0)
|
||||||
const O_RDWR* = cint(2)
|
const O_RDWR* = cint(2)
|
||||||
const O_WRONLY* = cint(1)
|
const O_WRONLY* = cint(1)
|
||||||
const O_CLOEXEC* = cint(524288)
|
const O_CLOEXEC* = cint(524288)
|
||||||
|
const O_DIRECT* = cint(16384)
|
||||||
|
const O_PATH* = cint(2097152)
|
||||||
|
const O_NOATIME* = cint(262144)
|
||||||
|
const O_TMPFILE* = cint(4259840)
|
||||||
const POSIX_FADV_NORMAL* = cint(0)
|
const POSIX_FADV_NORMAL* = cint(0)
|
||||||
const POSIX_FADV_SEQUENTIAL* = cint(2)
|
const POSIX_FADV_SEQUENTIAL* = cint(2)
|
||||||
const POSIX_FADV_RANDOM* = cint(1)
|
const POSIX_FADV_RANDOM* = cint(1)
|
||||||
|
|
@ -174,13 +178,20 @@ const FNM_NOMATCH* = cint(1)
|
||||||
const FNM_PATHNAME* = cint(1)
|
const FNM_PATHNAME* = cint(1)
|
||||||
const FNM_PERIOD* = cint(4)
|
const FNM_PERIOD* = cint(4)
|
||||||
const FNM_NOESCAPE* = cint(2)
|
const FNM_NOESCAPE* = cint(2)
|
||||||
|
const FNM_NOSYS* = cint(-1)
|
||||||
|
|
||||||
# <ftw.h>
|
# <ftw.h>
|
||||||
const FTW_F* = cint(0)
|
const FTW_F* = cint(0)
|
||||||
const FTW_D* = cint(1)
|
const FTW_D* = cint(1)
|
||||||
const FTW_DNR* = cint(2)
|
const FTW_DNR* = cint(2)
|
||||||
|
const FTW_DP* = cint(5)
|
||||||
const FTW_NS* = cint(3)
|
const FTW_NS* = cint(3)
|
||||||
const FTW_SL* = cint(4)
|
const FTW_SL* = cint(4)
|
||||||
|
const FTW_SLN* = cint(6)
|
||||||
|
const FTW_PHYS* = cint(1)
|
||||||
|
const FTW_MOUNT* = cint(2)
|
||||||
|
const FTW_DEPTH* = cint(8)
|
||||||
|
const FTW_CHDIR* = cint(4)
|
||||||
|
|
||||||
# <glob.h>
|
# <glob.h>
|
||||||
const GLOB_APPEND* = cint(32)
|
const GLOB_APPEND* = cint(32)
|
||||||
|
|
@ -402,6 +413,7 @@ const SS_ONSTACK* = cint(1)
|
||||||
const SS_DISABLE* = cint(2)
|
const SS_DISABLE* = cint(2)
|
||||||
const MINSIGSTKSZ* = cint(2048)
|
const MINSIGSTKSZ* = cint(2048)
|
||||||
const SIGSTKSZ* = cint(8192)
|
const SIGSTKSZ* = cint(8192)
|
||||||
|
const SIG_HOLD* = cast[Sighandler](2)
|
||||||
const SIG_DFL* = cast[Sighandler](0)
|
const SIG_DFL* = cast[Sighandler](0)
|
||||||
const SIG_ERR* = cast[Sighandler](-1)
|
const SIG_ERR* = cast[Sighandler](-1)
|
||||||
const SIG_IGN* = cast[Sighandler](1)
|
const SIG_IGN* = cast[Sighandler](1)
|
||||||
|
|
@ -473,7 +485,7 @@ const SOCK_SEQPACKET* = cint(5)
|
||||||
const SOCK_STREAM* = cint(1)
|
const SOCK_STREAM* = cint(1)
|
||||||
const SOCK_CLOEXEC* = cint(524288)
|
const SOCK_CLOEXEC* = cint(524288)
|
||||||
const SOL_SOCKET* = cint(1)
|
const SOL_SOCKET* = cint(1)
|
||||||
const SOMAXCONN* = cint(128)
|
const SOMAXCONN* = cint(4096)
|
||||||
const SO_REUSEPORT* = cint(15)
|
const SO_REUSEPORT* = cint(15)
|
||||||
const MSG_NOSIGNAL* = cint(16384)
|
const MSG_NOSIGNAL* = cint(16384)
|
||||||
const MSG_PEEK* = cint(2)
|
const MSG_PEEK* = cint(2)
|
||||||
|
|
@ -531,6 +543,7 @@ const POSIX_SPAWN_SETSCHEDPARAM* = cint(16)
|
||||||
const POSIX_SPAWN_SETSCHEDULER* = cint(32)
|
const POSIX_SPAWN_SETSCHEDULER* = cint(32)
|
||||||
const POSIX_SPAWN_SETSIGDEF* = cint(4)
|
const POSIX_SPAWN_SETSIGDEF* = cint(4)
|
||||||
const POSIX_SPAWN_SETSIGMASK* = cint(8)
|
const POSIX_SPAWN_SETSIGMASK* = cint(8)
|
||||||
|
const POSIX_SPAWN_USEVFORK* = cint(64)
|
||||||
|
|
||||||
# <stdio.h>
|
# <stdio.h>
|
||||||
const IOFBF* = cint(0)
|
const IOFBF* = cint(0)
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,8 @@ const
|
||||||
|
|
||||||
cfile = """
|
cfile = """
|
||||||
/* Generated by detect.nim */
|
/* Generated by detect.nim */
|
||||||
|
#define _GNU_SOURCE
|
||||||
|
#define _POSIX_C_SOURCE 200809L
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
@ -119,10 +121,14 @@ proc v(name: string, typ = "cint", no_other = false) =
|
||||||
addf(tl,
|
addf(tl,
|
||||||
"#ifdef $3\n fprintf(f, \"const $1* = $2(%ld)\\n\", $3);\n#endif\n",
|
"#ifdef $3\n fprintf(f, \"const $1* = $2(%ld)\\n\", $3);\n#endif\n",
|
||||||
n, t, name)
|
n, t, name)
|
||||||
of "cint", "cshort", "InAddrScalar", "TSa_Family":
|
of "cint", "cshort", "TSa_Family":
|
||||||
addf(tl,
|
addf(tl,
|
||||||
"#ifdef $3\n fprintf(f, \"const $1* = $2(%d)\\n\", $3);\n#endif\n",
|
"#ifdef $3\n fprintf(f, \"const $1* = $2(%d)\\n\", $3);\n#endif\n",
|
||||||
n, t, name)
|
n, t, name)
|
||||||
|
of "InAddrScalar":
|
||||||
|
addf(tl,
|
||||||
|
"#ifdef $3\n fprintf(f, \"const $1* = $2(%u)\\n\", $3);\n#endif\n",
|
||||||
|
n, t, name)
|
||||||
else:
|
else:
|
||||||
addf(tl,
|
addf(tl,
|
||||||
"#ifdef $3\n fprintf(f, \"const $1* = cast[$2](%d)\\n\", $3);\n#endif\n",
|
"#ifdef $3\n fprintf(f, \"const $1* = cast[$2](%d)\\n\", $3);\n#endif\n",
|
||||||
|
|
@ -256,6 +262,10 @@ v("O_RDONLY")
|
||||||
v("O_RDWR")
|
v("O_RDWR")
|
||||||
v("O_WRONLY")
|
v("O_WRONLY")
|
||||||
v("O_CLOEXEC")
|
v("O_CLOEXEC")
|
||||||
|
v("O_DIRECT")
|
||||||
|
v("O_PATH")
|
||||||
|
v("O_NOATIME")
|
||||||
|
v("O_TMPFILE")
|
||||||
v("POSIX_FADV_NORMAL")
|
v("POSIX_FADV_NORMAL")
|
||||||
v("POSIX_FADV_SEQUENTIAL")
|
v("POSIX_FADV_SEQUENTIAL")
|
||||||
v("POSIX_FADV_RANDOM")
|
v("POSIX_FADV_RANDOM")
|
||||||
|
|
@ -433,6 +443,7 @@ header("<netinet/in.h>")
|
||||||
v("IPPROTO_IP")
|
v("IPPROTO_IP")
|
||||||
v("IPPROTO_IPV6")
|
v("IPPROTO_IPV6")
|
||||||
v("IPPROTO_ICMP")
|
v("IPPROTO_ICMP")
|
||||||
|
v("IPPROTO_ICMPV6")
|
||||||
v("IPPROTO_RAW")
|
v("IPPROTO_RAW")
|
||||||
v("IPPROTO_TCP")
|
v("IPPROTO_TCP")
|
||||||
v("IPPROTO_UDP")
|
v("IPPROTO_UDP")
|
||||||
|
|
@ -631,10 +642,10 @@ v("MSG_NOSIGNAL", no_other = true)
|
||||||
v("MSG_PEEK")
|
v("MSG_PEEK")
|
||||||
v("MSG_TRUNC")
|
v("MSG_TRUNC")
|
||||||
v("MSG_WAITALL")
|
v("MSG_WAITALL")
|
||||||
v("AF_INET", "TSa_Family")
|
v("AF_INET")
|
||||||
v("AF_INET6", "TSa_Family")
|
v("AF_INET6")
|
||||||
v("AF_UNIX", "TSa_Family")
|
v("AF_UNIX")
|
||||||
v("AF_UNSPEC", "TSa_Family")
|
v("AF_UNSPEC")
|
||||||
v("SHUT_RD")
|
v("SHUT_RD")
|
||||||
v("SHUT_RDWR")
|
v("SHUT_RDWR")
|
||||||
v("SHUT_WR")
|
v("SHUT_WR")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue