Skip to content

Commit

Permalink
Support OCaml 5 new Unix primitive names
Browse files Browse the repository at this point in the history
  • Loading branch information
dra27 authored and MisterDA committed Jun 16, 2022
1 parent f32e668 commit a61b53b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions discover/discover.ml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ let config_includes = [
"caml/alloc.h";
"caml/custom.h";
"caml/bigarray.h";
"caml/version.h";
]

let build_code args =
Expand Down
10 changes: 8 additions & 2 deletions src/atfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
#if defined(EXTUNIX_HAVE_ATFILE)

/* otherlibs/unix/cst2constr.h */
#if OCAML_VERSION_MAJOR >= 5
extern value caml_unix_cst_to_constr(int n, int * tbl, int size, int deflt);
#else
extern value cst_to_constr(int n, int * tbl, int size, int deflt);
#define caml_unix_cst_to_constr cst_to_constr
#endif

static int file_kind_table[] = {
S_IFREG, S_IFDIR, S_IFCHR, S_IFBLK, S_IFLNK, S_IFIFO, S_IFSOCK
Expand Down Expand Up @@ -43,8 +48,9 @@ static value stat_aux(/*int use_64,*/ struct stat *buf)
v = caml_alloc_small(12, 0);
Field (v, 0) = Val_int (buf->st_dev);
Field (v, 1) = Val_int (buf->st_ino);
Field (v, 2) = cst_to_constr(buf->st_mode & S_IFMT, file_kind_table,
sizeof(file_kind_table) / sizeof(int), 0);
Field (v, 2) =
caml_unix_cst_to_constr(buf->st_mode & S_IFMT, file_kind_table,
sizeof(file_kind_table) / sizeof(int), 0);
Field (v, 3) = Val_int (buf->st_mode & 07777);
Field (v, 4) = Val_int (buf->st_nlink);
Field (v, 5) = Val_int (buf->st_uid);
Expand Down

0 comments on commit a61b53b

Please sign in to comment.