[Pkg-ocaml-maint-commits] [ocaml-extunix] 02/11: New upstream version 0.1.4

Stéphane Glondu glondu at moszumanska.debian.org
Mon Jul 17 16:37:44 UTC 2017


This is an automated email from the git hooks/post-receive script.

glondu pushed a commit to branch master
in repository ocaml-extunix.

commit 31b04b77d17a4f43a599d650ca3429eb1dec5054
Author: Stephane Glondu <steph at glondu.net>
Date:   Mon Jul 17 18:20:06 2017 +0200

    New upstream version 0.1.4
---
 .travis.yml               |  13 ++++
 CHANGES.txt               |   5 ++
 README.md                 |  13 ++--
 _oasis                    |   6 +-
 _tags                     |   5 +-
 appveyor.yml              |  13 ++++
 myocamlbuild.ml           | 178 +++++++++++++++++++++++++++++++++++++++++++---
 opam                      |  47 ++++++++++++
 setup.ml                  |  81 +++++++++++++--------
 src/META                  |   4 +-
 src/common.c              |   7 ++
 src/discover.ml           |  18 +++--
 src/extUnix.mlpp          |  65 ++++++++++++-----
 src/libextunix_stubs.clib |   3 +-
 src/mktemp.c              |  73 +++++++++++++++++++
 src/sendmsg.c             |  14 ++--
 src/sockopt.c             |  26 +++++--
 src/stdlib.c              |  69 ------------------
 src/time.c                |   2 +-
 19 files changed, 482 insertions(+), 160 deletions(-)

diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..ded0286
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,13 @@
+language: c
+sudo: required
+install: wget https://raw.githubusercontent.com/ocaml/ocaml-ci-scripts/master/.travis-opam.sh
+script: bash -ex .travis-opam.sh
+env:
+  - OCAML_VERSION=4.00
+  - OCAML_VERSION=4.01
+  - OCAML_VERSION=4.02
+  - OCAML_VERSION=4.03
+  - OCAML_VERSION=4.04
+os:
+  - linux
+  - osx
diff --git a/CHANGES.txt b/CHANGES.txt
index 01be969..59ad34d 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,3 +1,8 @@
+0.1.4 - 11 Nov 2016
++ SO_REUSEPORT
+* fix sendmsg bug
+* fix build on mingw
+
 0.1.3 - 24 Nov 2015
 * New bindings :
   * fchmodat
diff --git a/README.md b/README.md
index e0f0434..6dbcd79 100644
--- a/README.md
+++ b/README.md
@@ -2,6 +2,9 @@
 ExtUnix OCaml library
 =====================
 
+[![Build Status](https://travis-ci.org/ygrek/extunix.svg?branch=master)](https://travis-ci.org/ygrek/extunix)
+[![Build status](https://ci.appveyor.com/api/projects/status/66fpgc2qol5fu30g?svg=true)](https://ci.appveyor.com/project/ygrek/extunix/branch/master)
+
 A collection of thin bindings to various low-level system API.
 
 Our motto: "Be to Unix, what extlib is to stdlib"
@@ -70,7 +73,7 @@ For OCaml programming style, we follow Unix module:
 * Be MT friendly by default - i.e. release runtime lock for blocking
   operations, (FIXME) optionally provide ST variants
 
-Portability: 
+Portability:
 * No shell scripting for build and install (think windows :) )
 * Write portable C code (use compiler options to catch compatibility issues),
   NB: msvc doesn't support C99.
@@ -127,11 +130,11 @@ Checklist for release
 ---------------------
 
 * Review `git log` and update CHANGES.txt
-* Update version in _oasis and `oasis setup`
+* Update version in _oasis and do `oasis setup`
 * Commit
 * `make release`
-* Upload (forge and oasis-db) and update download links on web page
-* Commit
+* Upload tarball and update download links on web page
+* Update opam
 
 Development
 -----------
@@ -139,7 +142,7 @@ Development
 Many people contribute to extunix. Please submit your patches and/or feature requests
 to project bugtracker at
 
-  https://forge.ocamlcore.org/tracker/?group_id=175
+	https://github.com/ygrek/extunix/issues
 
 Current maintainer is reachable at :
 
diff --git a/_oasis b/_oasis
index 9c38653..38f4c95 100644
--- a/_oasis
+++ b/_oasis
@@ -1,6 +1,6 @@
 OASISFormat:  0.4
 Name:         extunix
-Version:      0.1.3
+Version:      0.1.4
 License:      LGPL-2.1 with OCaml linking exception
 Authors:      ygrek, Sylvain Le Gall, Stéphane Glondu, Kaustuv Chaudhuri, Joshua Smith, Niki Yoshiuchi, Gerd Stolpmann, Goswin von Brederlow, Andre Nathan, Zhenya Lykhovyd, Mehdi Dogguy, Roman Vorobets, Pierre Chambart, Dmitry Grebeniuk, François Bobot
 Copyrights:
@@ -43,13 +43,13 @@ Library extunix
   Path: src/
   Modules: ExtUnix, ExtUnixAll, ExtUnixSpecific, ExtUnixConfig
   if flag(strict) && ccomp_type(cc)
-    CCOpt: -std=c89 -pedantic -Wno-long-long -Wextra
+    CCOpt: -pedantic -Wno-long-long -Wextra
   CSources: config.h,
             eventfd.c, dirfd.c, fsync.c, statvfs.c, atfile.c,
             ioctl_siocgifconf.c, uname.c, fadvise.c, fallocate.c,
             tty_ioctl.c, unistd.c, stdlib.c, signalfd.c, ptrace.c,
             resource.c, mman.c, time.c, pts.c, execinfo.c, malloc.c,
-            endian.c, read_cred.c, fexecve.c, sendmsg.c,
+            endian.c, read_cred.c, fexecve.c, sendmsg.c, mktemp.c,
             memalign.c, endianba.c, pread_pwrite_ba.c, bigarray.c,
             splice.c, sysconf.c, common.c, common.h, sockopt.c, poll.c,
             sysinfo.c, mount.c, unshare.c
diff --git a/_tags b/_tags
index cc48b9d..45dee13 100644
--- a/_tags
+++ b/_tags
@@ -1,5 +1,5 @@
 # OASIS_START
-# DO NOT EDIT (digest: 957cfd9ae0923eb98d90af8c7e21f978)
+# DO NOT EDIT (digest: 6ba9d8b907ae1a6fd99654eed5689cfd)
 # Ignore VCS directories, you can use the same kind of rule outside
 # OASIS_START/STOP if you want to exclude directories that contains
 # useless stuff for the build process
@@ -41,6 +41,7 @@ true: annot, bin_annot
 "src/read_cred.c": oasis_library_extunix_ccopt
 "src/fexecve.c": oasis_library_extunix_ccopt
 "src/sendmsg.c": oasis_library_extunix_ccopt
+"src/mktemp.c": oasis_library_extunix_ccopt
 "src/memalign.c": oasis_library_extunix_ccopt
 "src/endianba.c": oasis_library_extunix_ccopt
 "src/pread_pwrite_ba.c": oasis_library_extunix_ccopt
@@ -104,6 +105,8 @@ true: annot, bin_annot
 "src/fexecve.c": pkg_unix
 "src/sendmsg.c": pkg_bigarray
 "src/sendmsg.c": pkg_unix
+"src/mktemp.c": pkg_bigarray
+"src/mktemp.c": pkg_unix
 "src/memalign.c": pkg_bigarray
 "src/memalign.c": pkg_unix
 "src/endianba.c": pkg_bigarray
diff --git a/appveyor.yml b/appveyor.yml
new file mode 100644
index 0000000..e684aae
--- /dev/null
+++ b/appveyor.yml
@@ -0,0 +1,13 @@
+platform:
+  - x86
+
+environment:
+  CYG_ROOT: "C:\\cygwin"
+  CYG_BASH: "%CYG_ROOT%\\bin\\bash -lc"
+
+install:
+  - appveyor DownloadFile https://raw.githubusercontent.com/ocaml/ocaml-ci-scripts/master/appveyor-opam.sh
+  - "%CYG_ROOT%\\setup-x86.exe -qnNdO -R %CYG_ROOT% -s http://cygwin.mirror.constant.com -l C:/cygwin/var/cache/setup -P rsync -P patch -P diffutils -P make -P unzip -P git -P m4 -P perl -P mingw64-x86_64-gcc-core"
+
+build_script:
+  - "%CYG_BASH% '${APPVEYOR_BUILD_FOLDER}/appveyor-opam.sh'"
diff --git a/myocamlbuild.ml b/myocamlbuild.ml
index b7415bf..2b96ec2 100644
--- a/myocamlbuild.ml
+++ b/myocamlbuild.ml
@@ -1,5 +1,5 @@
 (* OASIS_START *)
-(* DO NOT EDIT (digest: f0e05c6a2cb9b0a3d7737c452238402f) *)
+(* DO NOT EDIT (digest: 309d863cf72490520c06c9d01f3fd26e) *)
 module OASISGettext = struct
 (* # 22 "src/oasis/OASISGettext.ml" *)
 
@@ -29,6 +29,166 @@ module OASISGettext = struct
 
 end
 
+module OASISString = struct
+(* # 22 "src/oasis/OASISString.ml" *)
+
+
+  (** Various string utilities.
+
+      Mostly inspired by extlib and batteries ExtString and BatString libraries.
+
+      @author Sylvain Le Gall
+    *)
+
+
+  let nsplitf str f =
+    if str = "" then
+      []
+    else
+      let buf = Buffer.create 13 in
+      let lst = ref [] in
+      let push () =
+        lst := Buffer.contents buf :: !lst;
+        Buffer.clear buf
+      in
+      let str_len = String.length str in
+        for i = 0 to str_len - 1 do
+          if f str.[i] then
+            push ()
+          else
+            Buffer.add_char buf str.[i]
+        done;
+        push ();
+        List.rev !lst
+
+
+  (** [nsplit c s] Split the string [s] at char [c]. It doesn't include the
+      separator.
+    *)
+  let nsplit str c =
+    nsplitf str ((=) c)
+
+
+  let find ~what ?(offset=0) str =
+    let what_idx = ref 0 in
+    let str_idx = ref offset in
+      while !str_idx < String.length str &&
+            !what_idx < String.length what do
+        if str.[!str_idx] = what.[!what_idx] then
+          incr what_idx
+        else
+          what_idx := 0;
+        incr str_idx
+      done;
+      if !what_idx <> String.length what then
+        raise Not_found
+      else
+        !str_idx - !what_idx
+
+
+  let sub_start str len =
+    let str_len = String.length str in
+    if len >= str_len then
+      ""
+    else
+      String.sub str len (str_len - len)
+
+
+  let sub_end ?(offset=0) str len =
+    let str_len = String.length str in
+    if len >= str_len then
+      ""
+    else
+      String.sub str 0 (str_len - len)
+
+
+  let starts_with ~what ?(offset=0) str =
+    let what_idx = ref 0 in
+    let str_idx = ref offset in
+    let ok = ref true in
+      while !ok &&
+            !str_idx < String.length str &&
+            !what_idx < String.length what do
+        if str.[!str_idx] = what.[!what_idx] then
+          incr what_idx
+        else
+          ok := false;
+        incr str_idx
+      done;
+      if !what_idx = String.length what then
+        true
+      else
+        false
+
+
+  let strip_starts_with ~what str =
+    if starts_with ~what str then
+      sub_start str (String.length what)
+    else
+      raise Not_found
+
+
+  let ends_with ~what ?(offset=0) str =
+    let what_idx = ref ((String.length what) - 1) in
+    let str_idx = ref ((String.length str) - 1) in
+    let ok = ref true in
+      while !ok &&
+            offset <= !str_idx &&
+            0 <= !what_idx do
+        if str.[!str_idx] = what.[!what_idx] then
+          decr what_idx
+        else
+          ok := false;
+        decr str_idx
+      done;
+      if !what_idx = -1 then
+        true
+      else
+        false
+
+
+  let strip_ends_with ~what str =
+    if ends_with ~what str then
+      sub_end str (String.length what)
+    else
+      raise Not_found
+
+
+  let replace_chars f s =
+    let buf = Buffer.create (String.length s) in
+    String.iter (fun c -> Buffer.add_char buf (f c)) s;
+    Buffer.contents buf
+
+  let lowercase_ascii =
+    replace_chars
+      (fun c ->
+         if (c >= 'A' && c <= 'Z') then
+           Char.chr (Char.code c + 32)
+         else
+           c)
+
+  let uncapitalize_ascii s =
+    if s <> "" then
+      (lowercase_ascii (String.sub s 0 1)) ^ (String.sub s 1 ((String.length s) - 1))
+    else
+      s
+
+  let uppercase_ascii =
+    replace_chars
+      (fun c ->
+         if (c >= 'a' && c <= 'z') then
+           Char.chr (Char.code c - 32)
+         else
+           c)
+
+  let capitalize_ascii s =
+    if s <> "" then
+      (uppercase_ascii (String.sub s 0 1)) ^ (String.sub s 1 ((String.length s) - 1))
+    else
+      s
+
+end
+
 module OASISExpr = struct
 (* # 22 "src/oasis/OASISExpr.ml" *)
 
@@ -129,7 +289,7 @@ module OASISExpr = struct
 end
 
 
-# 132 "myocamlbuild.ml"
+# 292 "myocamlbuild.ml"
 module BaseEnvLight = struct
 (* # 22 "src/base/BaseEnvLight.ml" *)
 
@@ -234,7 +394,7 @@ module BaseEnvLight = struct
 end
 
 
-# 237 "myocamlbuild.ml"
+# 397 "myocamlbuild.ml"
 module MyOCamlbuildFindlib = struct
 (* # 22 "src/plugins/ocamlbuild/MyOCamlbuildFindlib.ml" *)
 
@@ -516,7 +676,7 @@ module MyOCamlbuildBase = struct
                  | nm, [], intf_modules ->
                      ocaml_lib nm;
                      let cmis =
-                       List.map (fun m -> (String.uncapitalize m) ^ ".cmi")
+                       List.map (fun m -> (OASISString.uncapitalize_ascii m) ^ ".cmi")
                                 intf_modules in
                      dep ["ocaml"; "link"; "library"; "file:"^nm^".cma"] cmis
                  | nm, dir :: tl, intf_modules ->
@@ -529,7 +689,7 @@ module MyOCamlbuildBase = struct
                             ["compile"; "infer_interface"; "doc"])
                        tl;
                      let cmis =
-                       List.map (fun m -> dir^"/"^(String.uncapitalize m)^".cmi")
+                       List.map (fun m -> dir^"/"^(OASISString.uncapitalize_ascii m)^".cmi")
                                 intf_modules in
                      dep ["ocaml"; "link"; "library"; "file:"^dir^"/"^nm^".cma"]
                          cmis)
@@ -603,7 +763,7 @@ module MyOCamlbuildBase = struct
 end
 
 
-# 606 "myocamlbuild.ml"
+# 766 "myocamlbuild.ml"
 open Ocamlbuild_plugin;;
 let package_default =
   {
@@ -620,8 +780,6 @@ let package_default =
                  S
                    [
                       A "-ccopt";
-                      A "-std=c89";
-                      A "-ccopt";
                       A "-pedantic";
                       A "-ccopt";
                       A "-Wno-long-long";
@@ -638,7 +796,7 @@ let conf = {MyOCamlbuildFindlib.no_automatic_syntax = false}
 
 let dispatch_default = MyOCamlbuildBase.dispatch_default conf package_default;;
 
-# 642 "myocamlbuild.ml"
+# 800 "myocamlbuild.ml"
 (* OASIS_STOP *)
 
 let gen gen_all prod =
@@ -658,6 +816,6 @@ let gen gen_all prod =
 gen true "src/extUnixAll.ml";;
 gen false "src/extUnixSpecific.ml";;
 
-flag ["compile"; "ocaml"; "my_warnings"] (S[A "-w"; A"+A-e-3-44-48"]);;
+flag ["compile"; "ocaml"; "my_warnings"] (S[A "-w"; A"+A-e-3-44-48-50"]);;
 
 Ocamlbuild_plugin.dispatch dispatch_default;;
diff --git a/opam b/opam
new file mode 100644
index 0000000..88a4234
--- /dev/null
+++ b/opam
@@ -0,0 +1,47 @@
+opam-version: "1.2"
+maintainer: "ygrek at autistici.org"
+homepage: "http://extunix.forge.ocamlcore.org/"
+dev-repo: "git://github.com/ygrek/extunix.git"
+bug-reports: "https://github.com/ygrek/extunix/issues"
+doc: "http://extunix.forge.ocamlcore.org/api/index.html"
+license: "LGPL-2.1 with OCaml linking exception"
+authors: [ "ygrek"
+           "Sylvain Le Gall"
+           "Stéphane Glondu"
+           "Kaustuv Chaudhuri"
+           "Joshua Smith"
+           "Niki Yoshiuchi"
+           "Gerd Stolpmann"
+           "Goswin von Brederlow"
+           "Andre Nathan"
+           "Zhenya Lykhovyd"
+           "Mehdi Dogguy"
+           "Roman Vorobets"
+           "Pierre Chambart"
+           "Dmitry Grebeniuk"
+           "François Bobot" ]
+build: [
+  ["ocaml" "setup.ml" "-configure" "--%{ounit:enable}%-tests" "--prefix" prefix] {ocaml-version >= "4.02.0"}
+  ["ocaml" "setup.ml" "-configure" "--prefix" prefix] {ocaml-version < "4.02.0"}
+  ["ocaml" "setup.ml" "-build"]
+]
+install: [
+  ["ocaml" "setup.ml" "-install"]
+]
+build-doc: [
+  ["ocaml" "setup.ml" "-doc"]
+]
+build-test: [
+  ["ocaml" "setup.ml" "-test"]
+]
+remove: [
+  ["ocamlfind" "remove" "extunix"]
+]
+depends: [
+  "ocamlfind" {build}
+  "camlp4" {build}
+  "ounit" {test & >= "1.0.3"}
+  "base-bigarray"
+  "base-unix"
+  "ocamlbuild" {build}
+]
diff --git a/setup.ml b/setup.ml
index 082f63f..df9c0bd 100644
--- a/setup.ml
+++ b/setup.ml
@@ -1,9 +1,9 @@
 (* setup.ml generated for the first time by OASIS v0.2.0~alpha1 *)
 
 (* OASIS_START *)
-(* DO NOT EDIT (digest: fb964b88aabc914f4cd05f402ca6329c) *)
+(* DO NOT EDIT (digest: 2aa790b36d6039aeac8966f86f42ec63) *)
 (*
-   Regenerated by OASIS v0.4.5
+   Regenerated by OASIS v0.4.6
    Visit http://oasis.forge.ocamlcore.org for more information and
    documentation about functions used in this file.
 *)
@@ -246,6 +246,33 @@ module OASISString = struct
     String.iter (fun c -> Buffer.add_char buf (f c)) s;
     Buffer.contents buf
 
+  let lowercase_ascii =
+    replace_chars
+      (fun c ->
+         if (c >= 'A' && c <= 'Z') then
+           Char.chr (Char.code c + 32)
+         else
+           c)
+
+  let uncapitalize_ascii s =
+    if s <> "" then
+      (lowercase_ascii (String.sub s 0 1)) ^ (String.sub s 1 ((String.length s) - 1))
+    else
+      s
+
+  let uppercase_ascii =
+    replace_chars
+      (fun c ->
+         if (c >= 'a' && c <= 'z') then
+           Char.chr (Char.code c - 32)
+         else
+           c)
+
+  let capitalize_ascii s =
+    if s <> "" then
+      (uppercase_ascii (String.sub s 0 1)) ^ (String.sub s 1 ((String.length s) - 1))
+    else
+      s
 
 end
 
@@ -315,19 +342,15 @@ module OASISUtils = struct
 
 
   let compare_csl s1 s2 =
-    String.compare (String.lowercase s1) (String.lowercase s2)
+    String.compare (OASISString.lowercase_ascii s1) (OASISString.lowercase_ascii s2)
 
 
   module HashStringCsl =
     Hashtbl.Make
       (struct
          type t = string
-
-         let equal s1 s2 =
-             (String.lowercase s1) = (String.lowercase s2)
-
-         let hash s =
-           Hashtbl.hash (String.lowercase s)
+         let equal s1 s2 = (compare_csl s1 s2) = 0
+         let hash s = Hashtbl.hash (OASISString.lowercase_ascii s)
        end)
 
   module SetStringCsl =
@@ -365,7 +388,7 @@ module OASISUtils = struct
           else
             buf
         in
-          String.lowercase buf
+          OASISString.lowercase_ascii buf
       end
 
 
@@ -471,7 +494,7 @@ module PropList = struct
         order     = Queue.create ();
         name_norm =
           (if case_insensitive then
-             String.lowercase
+             OASISString.lowercase_ascii
            else
              fun s -> s);
       }
@@ -1822,13 +1845,13 @@ module OASISUnixPath = struct
   let capitalize_file f =
     let dir = dirname f in
     let base = basename f in
-    concat dir (String.capitalize base)
+    concat dir (OASISString.capitalize_ascii base)
 
 
   let uncapitalize_file f =
     let dir = dirname f in
     let base = basename f in
-    concat dir (String.uncapitalize base)
+    concat dir (OASISString.uncapitalize_ascii base)
 
 
 end
@@ -2890,7 +2913,7 @@ module OASISFileUtil = struct
 end
 
 
-# 2893 "setup.ml"
+# 2916 "setup.ml"
 module BaseEnvLight = struct
 (* # 22 "src/base/BaseEnvLight.ml" *)
 
@@ -2995,7 +3018,7 @@ module BaseEnvLight = struct
 end
 
 
-# 2998 "setup.ml"
+# 3021 "setup.ml"
 module BaseContext = struct
 (* # 22 "src/base/BaseContext.ml" *)
 
@@ -5406,7 +5429,7 @@ module BaseSetup = struct
 end
 
 
-# 5409 "setup.ml"
+# 5432 "setup.ml"
 module InternalConfigurePlugin = struct
 (* # 22 "src/plugins/internal/InternalConfigurePlugin.ml" *)
 
@@ -5845,8 +5868,8 @@ module InternalInstallPlugin = struct
     let make_fnames modul sufx =
       List.fold_right
         begin fun sufx accu ->
-          (String.capitalize modul ^ sufx) ::
-          (String.uncapitalize modul ^ sufx) ::
+          (OASISString.capitalize_ascii modul ^ sufx) ::
+          (OASISString.uncapitalize_ascii modul ^ sufx) ::
           accu
         end
         sufx
@@ -6270,7 +6293,7 @@ module InternalInstallPlugin = struct
 end
 
 
-# 6273 "setup.ml"
+# 6296 "setup.ml"
 module OCamlbuildCommon = struct
 (* # 22 "src/plugins/ocamlbuild/OCamlbuildCommon.ml" *)
 
@@ -6648,7 +6671,7 @@ module OCamlbuildDocPlugin = struct
 end
 
 
-# 6651 "setup.ml"
+# 6674 "setup.ml"
 module CustomPlugin = struct
 (* # 22 "src/plugins/custom/CustomPlugin.ml" *)
 
@@ -6796,7 +6819,7 @@ module CustomPlugin = struct
 end
 
 
-# 6799 "setup.ml"
+# 6822 "setup.ml"
 open OASISTypes;;
 
 let setup_t =
@@ -6861,7 +6884,7 @@ let setup_t =
           alpha_features = [];
           beta_features = [];
           name = "extunix";
-          version = "0.1.3";
+          version = "0.1.4";
           license =
             OASISLicense.DEP5License
               (OASISLicense.DEP5Unit
@@ -7032,6 +7055,7 @@ let setup_t =
                            "read_cred.c";
                            "fexecve.c";
                            "sendmsg.c";
+                           "mktemp.c";
                            "memalign.c";
                            "endianba.c";
                            "pread_pwrite_ba.c";
@@ -7053,12 +7077,7 @@ let setup_t =
                            (OASISExpr.EAnd
                               (OASISExpr.EFlag "strict",
                                 OASISExpr.ETest ("ccomp_type", "cc")),
-                             [
-                                "-std=c89";
-                                "-pedantic";
-                                "-Wno-long-long";
-                                "-Wextra"
-                             ])
+                             ["-pedantic"; "-Wno-long-long"; "-Wextra"])
                         ];
                       bs_cclib = [(OASISExpr.EBool true, [])];
                       bs_dlllib = [(OASISExpr.EBool true, [])];
@@ -7274,8 +7293,8 @@ let setup_t =
           plugin_data = []
        };
      oasis_fn = Some "_oasis";
-     oasis_version = "0.4.5";
-     oasis_digest = Some "d\224\186}\182CdEL<\156H\131*#\156";
+     oasis_version = "0.4.6";
+     oasis_digest = Some "\159^\232\224!\202 u\016\145\218T\185n\241\t";
      oasis_exec = None;
      oasis_setup_args = [];
      setup_update = false
@@ -7283,6 +7302,6 @@ let setup_t =
 
 let setup () = BaseSetup.setup setup_t;;
 
-# 7287 "setup.ml"
+# 7306 "setup.ml"
 (* OASIS_STOP *)
 let () = setup ();;
diff --git a/src/META b/src/META
index b7198a5..b88ddcb 100644
--- a/src/META
+++ b/src/META
@@ -1,6 +1,6 @@
 # OASIS_START
-# DO NOT EDIT (digest: d2df78e63c11b2d3caeee272e1a8e0c7)
-version = "0.1.3"
+# DO NOT EDIT (digest: 4c8b859a5f06b31a8f58fd53a6fb515f)
+version = "0.1.4"
 description = "Extended functions for OCaml Unix module"
 requires = "unix bigarray"
 archive(byte) = "extunix.cma"
diff --git a/src/common.c b/src/common.c
index 0264e7a..c346a3c 100644
--- a/src/common.c
+++ b/src/common.c
@@ -5,8 +5,15 @@
 /* otherlibs/unix/open.c */
 
 #ifndef O_NONBLOCK
+#ifdef __MINGW32__
+#define O_NONBLOCK 0 /* no O_NONBLOCK on mingw */
+#else
 #define O_NONBLOCK O_NDELAY
 #endif
+#endif
+#ifndef O_NOCTTY
+#define O_NOCTTY 0
+#endif
 #ifndef O_DSYNC
 #define O_DSYNC 0
 #endif
diff --git a/src/discover.ml b/src/discover.ml
index d4a525c..e6910a9 100644
--- a/src/discover.ml
+++ b/src/discover.ml
@@ -42,6 +42,7 @@ let config_defines = [
   "_POSIX_C_SOURCE 200809L";
   "_XOPEN_SOURCE 700";
   "_BSD_SOURCE";
+  "_DEFAULT_SOURCE";
   "_DARWIN_C_SOURCE";
   "_LARGEFILE64_SOURCE";
   "WIN32_LEAN_AND_MEAN";
@@ -285,15 +286,17 @@ let features =
     "EXECINFO", L[ I"execinfo.h"; S"backtrace"; S"backtrace_symbols"; ];
     "SETENV", L[ I"stdlib.h"; S"setenv"; S"unsetenv"; ];
     "CLEARENV", L[ I"stdlib.h"; S"clearenv"; ];
-    "MKDTEMP", L[ I"stdlib.h"; S"mkdtemp"; ];
+    "MKDTEMP", L[ I"stdlib.h"; I"unistd.h"; S"mkdtemp"; ];
     "TIMEGM", L[ I"time.h"; S"timegm"; ];
     "MALLOC_INFO", L[ I"malloc.h"; S"malloc_info"; ];
     "MALLOC_STATS", L[ I"malloc.h"; S"malloc_stats"; ];
     "MEMALIGN", L[ I "stdlib.h"; S"posix_memalign"; ];
-    "ENDIAN", L[ I "endian.h";
-		 D"htobe16"; D"htole16"; D"be16toh"; D"le16toh";
-		 D"htobe32"; D"htole32"; D"be32toh"; D"le32toh";
-		 D"htobe64"; D"htole64"; D"be64toh"; D"le64toh"; ];
+    "ENDIAN", L[
+      I "endian.h";
+      D"htobe16"; D"htole16"; D"be16toh"; D"le16toh";
+      D"htobe32"; D"htole32"; D"be32toh"; D"le32toh";
+      D"htobe64"; D"htole64"; D"be64toh"; D"le64toh";
+    ];
     "READ_CREDENTIALS", L[ I"sys/types.h"; I"sys/socket.h"; D"SO_PEERCRED"; ];
     "FEXECVE", L[ I "unistd.h"; S"fexecve"; ];
     "SENDMSG", ANY[
@@ -304,8 +307,8 @@ let features =
     "PWRITE", L[ I "unistd.h"; S"pwrite"; ];
     "READ", L[ I "unistd.h"; S"read"; ];
     "WRITE", L[ I "unistd.h"; S"write"; ];
-    "MKSTEMPS", L[ I "stdlib.h"; S"mkstemps"; ];
-    "MKOSTEMPS", L[ I "stdlib.h"; S"mkostemps"; ];
+    "MKSTEMPS", L[ I "stdlib.h"; I "unistd.h"; S"mkstemps"; ];
+    "MKOSTEMPS", L[ I "stdlib.h"; I "unistd.h"; S"mkostemps"; ];
     "SETRESUID", L[ I"sys/types.h"; I"unistd.h"; S"setresuid"; S"setresgid" ];
     "SYSCONF", L[
       I "unistd.h";
@@ -323,6 +326,7 @@ let features =
     "TCP_KEEPCNT", L[I"netinet/in.h"; I"netinet/tcp.h";V"TCP_KEEPCNT"];
     "TCP_KEEPIDLE", L[I"netinet/in.h"; I"netinet/tcp.h";V"TCP_KEEPIDLE"];
     "TCP_KEEPINTVL", L[I"netinet/in.h"; I"netinet/tcp.h";V"TCP_KEEPINTVL"];
+    "SO_REUSEPORT", L[I"sys/socket.h"; V"SO_REUSEPORT"];
     "POLL", L[ I "poll.h"; S "poll"; D "POLLIN"; D "POLLOUT"; Z "POLLRDHUP" ];
     "SYSINFO", L[ I"sys/sysinfo.h"; S"sysinfo"; F ("sysinfo","mem_unit")];
     "MCHECK", L[ I"mcheck.h"; S"mtrace"; S"muntrace" ];
diff --git a/src/extUnix.mlpp b/src/extUnix.mlpp
index ae74e74..9152b63 100644
--- a/src/extUnix.mlpp
+++ b/src/extUnix.mlpp
@@ -4,8 +4,8 @@ These functions are thin wrappers for underlying system API, consult
 the corresponding man pages and/or system documentation for details.
 *)
 
-(** [Not_available "func"] may be raised by [ExtUnix.All.func]
-    if the wrapped C function is not available on this platform.
+(** [Not_available "symbol"] may be raised by [ExtUnix.All.func]
+    if the wrapped C function or constant is not available on this platform.
 
     [ExtUnix.Specific] includes only functions available on the current
     platform and will not raise [Not_available].
@@ -792,7 +792,7 @@ type sysinfo = {
   mem_unit : int;   (** Memory unit size in bytes *)
 }
 
-(** @retrun overall system statistics *)
+(** @return overall system statistics *)
 external sysinfo : unit -> sysinfo = "caml_extunix_sysinfo"
 
 (** @return seconds since boot *)
@@ -810,6 +810,22 @@ END
 
 HAVE SOCKOPT
 
+type socket_int_option_ =
+| TCP_KEEPCNT_
+| TCP_KEEPIDLE_
+| TCP_KEEPINTVL_
+| SO_REUSEPORT_
+
+let string_of_socket_int_option_ = function
+| TCP_KEEPCNT_ -> "TCP_KEEPCNT"
+| TCP_KEEPIDLE_ -> "TCP_KEEPIDLE"
+| TCP_KEEPINTVL_ -> "TCP_KEEPINTVL"
+| SO_REUSEPORT_ -> "SO_REUSEPORT"
+
+external setsockopt_int : Unix.file_descr -> socket_int_option_ -> int -> unit = "caml_extunix_setsockopt_int"
+external getsockopt_int : Unix.file_descr -> socket_int_option_ -> int = "caml_extunix_getsockopt_int"
+external have_sockopt_int : socket_int_option_ -> bool = "caml_extunix_have_sockopt"
+
 (** Extra socket options with integer value not covered in {!Unix} module.
   NB Not all options available on all platforms, use {!have_sockopt} to check at runtime
   (even when function is defined in [Specific] module)
@@ -820,25 +836,38 @@ type socket_int_option =
                    keepalive probes, if the socket option SO_KEEPALIVE has been set on this socket *)
 | TCP_KEEPINTVL (** The time (in seconds) between individual keepalive probes *)
 
-(** raise [Not_available] if option is not supported, see {!have_sockopt} *)
-external setsockopt_int : Unix.file_descr -> socket_int_option -> int -> unit = "caml_extunix_setsockopt_int"
-external getsockopt_int : Unix.file_descr -> socket_int_option -> int = "caml_extunix_getsockopt_int"
+type socket_bool_option =
+| SO_REUSEPORT (** Permits multiple AF_INET or AF_INET6 sockets to be bound to an identical socket address. *)
+
+let make_socket_int_option = function
+| TCP_KEEPCNT -> TCP_KEEPCNT_
+| TCP_KEEPIDLE -> TCP_KEEPIDLE_
+| TCP_KEEPINTVL -> TCP_KEEPINTVL_
+
+let make_socket_bool_option = function
+| SO_REUSEPORT -> SO_REUSEPORT_
+
+let have_sockopt_bool x = have_sockopt_int (make_socket_bool_option x)
+let have_sockopt_int x = have_sockopt_int (make_socket_int_option x)
+
+(** obsolete, compatibility *)
+let have_sockopt = have_sockopt_int
 
-external have_sockopt : socket_int_option -> bool = "caml_extunix_have_sockopt"
+let setsockopt_int sock opt v = try setsockopt_int sock opt v with Not_found -> raise (Not_available ("setsockopt " ^ string_of_socket_int_option_ opt))
+let getsockopt_int sock opt = try getsockopt_int sock opt with Not_found -> raise (Not_available ("getsockopt " ^ string_of_socket_int_option_ opt))
+
+(** Set a boolean-valued option in the given socket *)
+let setsockopt sock opt v = setsockopt_int sock (make_socket_bool_option opt) (if v then 1 else 0)
+
+(** Get the current value for the boolean-valued option in the given socket *)
+let getsockopt sock opt = 0 <> getsockopt_int sock (make_socket_bool_option opt)
 
 (** Set an integer-valued option in the given socket *)
-let setsockopt_int sock opt v =
-  try
-    setsockopt_int sock opt v
-  with
-    Not_found -> raise (Not_available "setsockopt_int")
+let setsockopt_int sock opt v = setsockopt_int sock (make_socket_int_option opt) v
 
 (** Get the current value for the integer-valued option in the given socket *)
-let getsockopt_int sock opt =
-  try
-    getsockopt_int sock opt
-  with
-    Not_found -> raise (Not_available "getsockopt_int")
+let getsockopt_int sock opt = getsockopt_int sock (make_socket_int_option opt)
+
 
 END
 
@@ -880,7 +909,7 @@ end = struct
 
 type t = int
 external poll_constants : unit -> (int*int*int*int*int*int*int) = "caml_extunix_poll_constants"
-let (pollin,pollpri,pollout,pollerr,pollhup,pollnval,pollrdhup) = poll_constants ()
+let (pollin,pollpri,pollout,pollerr,pollhup,pollnval,pollrdhup) = try poll_constants () with Not_available _ -> (0,0,0,0,0,0,0)
 let none = 0
 
 let is_set xs x = xs land x = x
diff --git a/src/libextunix_stubs.clib b/src/libextunix_stubs.clib
index e5b2e93..1d69ded 100644
--- a/src/libextunix_stubs.clib
+++ b/src/libextunix_stubs.clib
@@ -1,5 +1,5 @@
 # OASIS_START
-# DO NOT EDIT (digest: fc1c3ad8ae85c37d2cd9583f1c6ef64c)
+# DO NOT EDIT (digest: 9ea9c31e8eb66b0e02125ef2b1be7dbb)
 eventfd.o
 dirfd.o
 fsync.o
@@ -24,6 +24,7 @@ endian.o
 read_cred.o
 fexecve.o
 sendmsg.o
+mktemp.o
 memalign.o
 endianba.o
 pread_pwrite_ba.o
diff --git a/src/mktemp.c b/src/mktemp.c
new file mode 100644
index 0000000..aa922cc
--- /dev/null
+++ b/src/mktemp.c
@@ -0,0 +1,73 @@
+#define EXTUNIX_WANT_MKDTEMP
+#define EXTUNIX_WANT_MKSTEMPS
+#define EXTUNIX_WANT_MKOSTEMPS
+
+#include "config.h"
+
+#if defined(EXTUNIX_HAVE_MKDTEMP)
+
+CAMLprim value caml_extunix_mkdtemp(value v_path)
+{
+  CAMLparam1(v_path);
+  char* path = strdup(String_val(v_path));
+  char *ret;
+  caml_enter_blocking_section();
+  ret = mkdtemp(path);
+  caml_leave_blocking_section();
+  if (NULL == ret)
+  {
+    free(path);
+    uerror("mkdtemp", v_path);
+  }
+  v_path = caml_copy_string(ret);
+  free(path);
+  CAMLreturn(v_path);
+}
+
+#endif
+
+#if defined(EXTUNIX_HAVE_MKSTEMPS)
+
+CAMLprim value caml_extunix_internal_mkstemps(value v_template, value v_suffixlen)
+{
+  CAMLparam2(v_template, v_suffixlen);
+  char *template = String_val(v_template);
+  int suffixlen = Int_val(v_suffixlen);
+  int ret;
+
+  ret = mkstemps(template, suffixlen);
+  if (ret == -1)
+  {
+    uerror("mkstemps", v_template);
+  }
+  CAMLreturn(Val_int(ret));
+}
+
+#endif
+
+#if defined(EXTUNIX_HAVE_MKOSTEMPS)
+
+/* FIXME: also in atfile.c, move to common file */
+#include <fcntl.h>
+
+#ifndef O_CLOEXEC
+# define O_CLOEXEC 0
+#endif
+
+CAMLprim value caml_extunix_internal_mkostemps(value v_template, value v_suffixlen, value v_flags)
+{
+  CAMLparam3(v_template, v_suffixlen, v_flags);
+  char *template = String_val(v_template);
+  int flags = extunix_open_flags(v_flags) | O_CLOEXEC;
+  int suffixlen = Int_val(v_suffixlen);
+  int ret;
+
+  ret = mkostemps(template, suffixlen, flags);
+  if (ret == -1)
+  {
+    uerror("mkostemps", v_template);
+  }
+  CAMLreturn(Val_int(ret));
+}
+
+#endif
diff --git a/src/sendmsg.c b/src/sendmsg.c
index f29cad0..619d32c 100644
--- a/src/sendmsg.c
+++ b/src/sendmsg.c
@@ -24,15 +24,19 @@ CAMLprim value caml_extunix_sendmsg(value fd_val, value sendfd_val, value data_v
   ssize_t ret;
   char *buf;
 
+#if defined(CMSG_SPACE)
+  union {
+    struct cmsghdr cmsg; /* for alignment */
+    char control[CMSG_SPACE(sizeof(int))]; /* sizeof sendfd */
+  } control_un;
+#endif
+
   memset(&msg, 0, sizeof msg);
 
-  if (sendfd_val != Val_none) {
+  if (sendfd_val != Val_none)
+  {
     int sendfd = Int_val(Some_val(sendfd_val));
 #if defined(CMSG_SPACE)
-    union {
-      struct cmsghdr cmsg; /* for alignment */
-      char control[CMSG_SPACE(sizeof sendfd)];
-    } control_un;
     struct cmsghdr *cmsgp;
 
     msg.msg_control = control_un.control;
diff --git a/src/sockopt.c b/src/sockopt.c
index db5e510..b52c79c 100644
--- a/src/sockopt.c
+++ b/src/sockopt.c
@@ -18,8 +18,20 @@
 #define TCP_KEEPINTVL (-1)
 #endif
 
-static int tcp_options[] = {
-  TCP_KEEPCNT, TCP_KEEPIDLE, TCP_KEEPINTVL,
+#ifndef SO_REUSEPORT
+#define SO_REUSEPORT (-1)
+#endif
+
+struct option {
+  int opt;
+  int level;
+};
+
+static struct option tcp_options[] = {
+  { TCP_KEEPCNT, IPPROTO_TCP },
+  { TCP_KEEPIDLE, IPPROTO_TCP },
+  { TCP_KEEPINTVL, IPPROTO_TCP },
+  { SO_REUSEPORT, SOL_SOCKET },
 };
 
 CAMLprim value caml_extunix_have_sockopt(value k)
@@ -29,7 +41,7 @@ CAMLprim value caml_extunix_have_sockopt(value k)
     caml_invalid_argument("have_sockopt");
   }
 
-  return Val_bool(tcp_options[Int_val(k)] != -1);
+  return Val_bool(tcp_options[Int_val(k)].opt != -1);
 }
 
 CAMLprim value caml_extunix_setsockopt_int(value fd, value k, value v)
@@ -42,13 +54,13 @@ CAMLprim value caml_extunix_setsockopt_int(value fd, value k, value v)
     caml_invalid_argument("setsockopt_int");
   }
 
-  if (tcp_options[Int_val(k)] == -1)
+  if (tcp_options[Int_val(k)].opt == -1)
   {
     caml_raise_not_found();
     assert(0);
   }
 
-  if (0 != setsockopt(Int_val(fd), IPPROTO_TCP, tcp_options[Int_val(k)], &optval, optlen))
+  if (0 != setsockopt(Int_val(fd), tcp_options[Int_val(k)].level, tcp_options[Int_val(k)].opt, &optval, optlen))
   {
     uerror("setsockopt_int", Nothing);
   }
@@ -66,13 +78,13 @@ CAMLprim value caml_extunix_getsockopt_int(value fd, value k)
     caml_invalid_argument("getsockopt_int");
   }
 
-  if (tcp_options[Int_val(k)] == -1)
+  if (tcp_options[Int_val(k)].opt == -1)
   {
     caml_raise_not_found();
     assert(0);
   }
 
-  if (0 != getsockopt(Int_val(fd), IPPROTO_TCP, tcp_options[Int_val(k)], &optval, &optlen))
+  if (0 != getsockopt(Int_val(fd), tcp_options[Int_val(k)].level, tcp_options[Int_val(k)].opt, &optval, &optlen))
   {
     uerror("getsockopt_int", Nothing);
   }
diff --git a/src/stdlib.c b/src/stdlib.c
index 7c4e6c4..7e7a023 100644
--- a/src/stdlib.c
+++ b/src/stdlib.c
@@ -95,72 +95,3 @@ CAMLprim value caml_extunix_clearenv(value v_unit)
 }
 
 #endif
-
-#if defined(EXTUNIX_HAVE_MKDTEMP)
-
-CAMLprim value caml_extunix_mkdtemp(value v_path)
-{
-  CAMLparam1(v_path);
-  char* path = strdup(String_val(v_path));
-  char *ret;
-  caml_enter_blocking_section();
-  ret = mkdtemp(path);
-  caml_leave_blocking_section();
-  if (NULL == ret)
-  {
-    free(path);
-    uerror("mkdtemp", v_path);
-  }
-  v_path = caml_copy_string(ret);
-  free(path);
-  CAMLreturn(v_path);
-}
-
-#endif
-
-#if defined(EXTUNIX_HAVE_MKSTEMPS)
-
-CAMLprim value caml_extunix_internal_mkstemps(value v_template, value v_suffixlen)
-{
-  CAMLparam2(v_template, v_suffixlen);
-  char *template = String_val(v_template);
-  int suffixlen = Int_val(v_suffixlen);
-  int ret;
-  
-  ret = mkstemps(template, suffixlen);
-  if (ret == -1)
-  {
-    uerror("mkstemps", v_template);
-  }
-  CAMLreturn(Val_int(ret));
-}
-
-#endif
-
-#if defined(EXTUNIX_HAVE_MKOSTEMPS)
-
-/* FIXME: also in atfile.c, move to common file */
-#include <fcntl.h>
-
-#ifndef O_CLOEXEC
-# define O_CLOEXEC 0
-#endif
-
-CAMLprim value caml_extunix_internal_mkostemps(value v_template, value v_suffixlen, value v_flags)
-{
-  CAMLparam3(v_template, v_suffixlen, v_flags);
-  char *template = String_val(v_template);
-  int flags = extunix_open_flags(v_flags) | O_CLOEXEC;
-  int suffixlen = Int_val(v_suffixlen);
-  int ret;
-  
-  ret = mkostemps(template, suffixlen, flags);
-  if (ret == -1)
-  {
-    uerror("mkostemps", v_template);
-  }
-  CAMLreturn(Val_int(ret));
-}
-
-#endif
-
diff --git a/src/time.c b/src/time.c
index b8439f0..0898d07 100644
--- a/src/time.c
+++ b/src/time.c
@@ -86,7 +86,7 @@ CAMLprim value caml_extunix_tzname(value v_isdst)
 
 #endif
 
-#if defined(EXTUNIX_WANT_TIMEZONE)
+#if defined(EXTUNIX_HAVE_TIMEZONE)
 
 CAMLprim value caml_extunix_timezone(value v_unit)
 {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ocaml-maint/packages/ocaml-extunix.git



More information about the Pkg-ocaml-maint-commits mailing list