summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--lib/posix/posix.nim2
-rw-r--r--lib/posix/posix_linux_amd64.nim9
-rw-r--r--lib/posix/posix_linux_amd64_consts.nim15
-rw-r--r--tools/detect/detect.nim21
4 files changed, 33 insertions, 14 deletions
diff --git a/lib/posix/posix.nim b/lib/posix/posix.nim
index 3e423c64b..96203b736 100644
--- a/lib/posix/posix.nim
+++ b/lib/posix/posix.nim
@@ -1043,6 +1043,8 @@ proc mkdtemp*(tmpl: cstring): pointer {.importc, header: "<stdlib.h>", sideEffec
 when defined(linux) or defined(bsd):
   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 {.
   importc: "utimes", header: "<sys/time.h>", sideEffect.}
   ## Sets file access and modification times.
diff --git a/lib/posix/posix_linux_amd64.nim b/lib/posix/posix_linux_amd64.nim
index bb82d9e5e..7f6a589f0 100644
--- a/lib/posix/posix_linux_amd64.nim
+++ b/lib/posix/posix_linux_amd64.nim
@@ -34,9 +34,6 @@ type
 type
   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
   Time* {.importc: "time_t", header: "<time.h>".} = distinct clong
 
@@ -228,7 +225,7 @@ type
     st_mode*: Mode        ## Mode of file (see below).
     st_uid*: Uid          ## User 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_size*: Off         ## For regular files, the file size in bytes.
                            ## For symbolic links, the length in bytes of the
@@ -244,8 +241,6 @@ type
     st_atim*: Timespec   ## Time of last access.
     st_mtim*: Timespec   ## Time of last data modification.
     st_ctim*: Timespec   ## Time of last status change.
-    reserved: array[3, clong]
-
 
   Statvfs* {.importc: "struct statvfs", header: "<sys/statvfs.h>",
               final, pure.} = object ## struct statvfs
@@ -573,8 +568,6 @@ var
 # Regenerate using detect.nim!
 include posix_linux_amd64_consts
 
-const POSIX_SPAWN_USEVFORK* = cint(0x40)  # needs _GNU_SOURCE!
-
 # <sys/wait.h>
 proc WEXITSTATUS*(s: cint): cint =  (s and 0xff00) shr 8
 proc WTERMSIG*(s:cint): cint = s and 0x7f
diff --git a/lib/posix/posix_linux_amd64_consts.nim b/lib/posix/posix_linux_amd64_consts.nim
index 84296eb9b..f3230f71d 100644
--- a/lib/posix/posix_linux_amd64_consts.nim
+++ b/lib/posix/posix_linux_amd64_consts.nim
@@ -128,6 +128,10 @@ const O_RDONLY* = cint(0)
 const O_RDWR* = cint(2)
 const O_WRONLY* = cint(1)
 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_SEQUENTIAL* = cint(2)
 const POSIX_FADV_RANDOM* = cint(1)
@@ -174,13 +178,20 @@ const FNM_NOMATCH* = cint(1)
 const FNM_PATHNAME* = cint(1)
 const FNM_PERIOD* = cint(4)
 const FNM_NOESCAPE* = cint(2)
+const FNM_NOSYS* = cint(-1)
 
 # <ftw.h>
 const FTW_F* = cint(0)
 const FTW_D* = cint(1)
 const FTW_DNR* = cint(2)
+const FTW_DP* = cint(5)
 const FTW_NS* = cint(3)
 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>
 const GLOB_APPEND* = cint(32)
@@ -402,6 +413,7 @@ const SS_ONSTACK* = cint(1)
 const SS_DISABLE* = cint(2)
 const MINSIGSTKSZ* = cint(2048)
 const SIGSTKSZ* = cint(8192)
+const SIG_HOLD* = cast[Sighandler](2)
 const SIG_DFL* = cast[Sighandler](0)
 const SIG_ERR* = 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_CLOEXEC* = cint(524288)
 const SOL_SOCKET* = cint(1)
-const SOMAXCONN* = cint(128)
+const SOMAXCONN* = cint(4096)
 const SO_REUSEPORT* = cint(15)
 const MSG_NOSIGNAL* = cint(16384)
 const MSG_PEEK* = cint(2)
@@ -531,6 +543,7 @@ const POSIX_SPAWN_SETSCHEDPARAM* = cint(16)
 const POSIX_SPAWN_SETSCHEDULER* = cint(32)
 const POSIX_SPAWN_SETSIGDEF* = cint(4)
 const POSIX_SPAWN_SETSIGMASK* = cint(8)
+const POSIX_SPAWN_USEVFORK* = cint(64)
 
 # <stdio.h>
 const IOFBF* = cint(0)
diff --git a/tools/detect/detect.nim b/tools/detect/detect.nim
index 0a19a7951..720e24975 100644
--- a/tools/detect/detect.nim
+++ b/tools/detect/detect.nim
@@ -20,6 +20,8 @@ const
 
   cfile = """
 /* Generated by detect.nim */
+#define _GNU_SOURCE
+#define _POSIX_C_SOURCE 200809L
 
 #include <stdlib.h>
 #include <stdio.h>
@@ -119,10 +121,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)
-  of "cint", "cshort", "InAddrScalar", "TSa_Family":
+  of "cint", "cshort", "TSa_Family":
     addf(tl,
       "#ifdef $3\n  fprintf(f, \"const $1* = $2(%d)\\n\", $3);\n#endif\n",
       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:
     addf(tl,
       "#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_WRONLY")
 v("O_CLOEXEC")
+v("O_DIRECT")
+v("O_PATH")
+v("O_NOATIME")
+v("O_TMPFILE")
 v("POSIX_FADV_NORMAL")
 v("POSIX_FADV_SEQUENTIAL")
 v("POSIX_FADV_RANDOM")
@@ -433,6 +443,7 @@ header("<netinet/in.h>")
 v("IPPROTO_IP")
 v("IPPROTO_IPV6")
 v("IPPROTO_ICMP")
+v("IPPROTO_ICMPV6")
 v("IPPROTO_RAW")
 v("IPPROTO_TCP")
 v("IPPROTO_UDP")
@@ -631,10 +642,10 @@ v("MSG_NOSIGNAL", no_other = true)
 v("MSG_PEEK")
 v("MSG_TRUNC")
 v("MSG_WAITALL")
-v("AF_INET", "TSa_Family")
-v("AF_INET6", "TSa_Family")
-v("AF_UNIX", "TSa_Family")
-v("AF_UNSPEC", "TSa_Family")
+v("AF_INET")
+v("AF_INET6")
+v("AF_UNIX")
+v("AF_UNSPEC")
 v("SHUT_RD")
 v("SHUT_RDWR")
 v("SHUT_WR")