1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
From: Stephane Glondu <steph@glondu.net>
Date: Sun, 1 Sep 2019 21:15:48 +0200
Subject: Fix compilation with OCaml 4.08.0
---
src/Makefile | 3 ++-
src/libextunix.ml | 12 ++++++------
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/Makefile b/src/Makefile
index d58ecea..a70c43e 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -18,8 +18,9 @@ EXTRAMODINTFCOM = $(EXTRAMOD:%=%.cmi)
INSTALLFILES = $(COMMONMODINTFCOM) $(EXTRAMODINTFSRC) $(EXTRAMODINTFCOM)
+OCAMLTHREADLIB = $(if $(wildcard $(OCAMLSTDLIBPATH)/mutex.mli),$(OCAMLSTDLIBPATH),$(OCAMLSTDLIBPATH)/threads)
-$(COMMONMODINTFSRC): %: $(OCAMLSTDLIBPATH)/%
+$(COMMONMODINTFSRC): %: $(OCAMLTHREADLIB)/%
@if [ ! -L $@ ]; then ln -s $< .; fi
.PHONY: all install clean uninstall sub%
diff --git a/src/libextunix.ml b/src/libextunix.ml
index 4d94df9..2420536 100644
--- a/src/libextunix.ml
+++ b/src/libextunix.ml
@@ -12,12 +12,12 @@ let marshal_write =
| _ -> () in
fun v fd ->
let str = Marshal.to_string v [Marshal.Closures] in
- write_rec fd str 0 (String.length str)
+ write_rec fd (Bytes.of_string str) 0 (String.length str)
(* Atomically read OCaml value from file_descr for both block/nonblock mode *)
let marshal_read fd =
let bsize = Marshal.header_size + 128 in
- let buf = String.create bsize in
+ let buf = Bytes.create bsize in
let rec read_rec fd buf ofs len =
let len' =
try Some (read fd buf ofs len) with
@@ -33,9 +33,9 @@ let marshal_read fd =
let data_size = Marshal.data_size buf 0 in
let total_size = Marshal.header_size + data_size in
let buf =
- if total_size <= String.length buf then buf else
- let ext_buf = String.create total_size in
- String.blit buf 0 ext_buf 0 Marshal.header_size;
+ if total_size <= Bytes.length buf then buf else
+ let ext_buf = Bytes.create total_size in
+ Bytes.blit buf 0 ext_buf 0 Marshal.header_size;
ext_buf in
read_rec fd buf Marshal.header_size data_size;
- Marshal.from_string buf 0
+ Marshal.from_string (Bytes.to_string buf) 0
|