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