Skip to content

Commit b741881

Browse files
authored
Merge pull request #615 from talex5/lintcstubs
Generate prototypes for C stubs from ml files
2 parents 3fde20c + 137399a commit b741881

File tree

10 files changed

+96
-0
lines changed

10 files changed

+96
-0
lines changed

lib_eio/unix/dune

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,16 @@
66
(include_dirs include)
77
(names fork_action stubs))
88
(libraries eio unix threads mtime.clock.os))
9+
10+
(rule
11+
(enabled_if %{bin-available:lintcstubs_arity_cmt})
12+
(action
13+
(with-stdout-to
14+
primitives.h.new
15+
(run %{bin:lintcstubs_arity_cmt} %{dep:.eio_unix.objs/byte/eio_unix__Fd.cmt} %{dep:.eio_unix.objs/byte/eio_unix__Fork_action.cmt}))))
16+
17+
(rule
18+
(enabled_if %{bin-available:lintcstubs_arity_cmt})
19+
(alias runtest)
20+
(action
21+
(diff primitives.h primitives.h.new)))

lib_eio/unix/fork_action.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* release it.
55
*/
66

7+
#include "primitives.h"
8+
79
#include <stdlib.h>
810
#include <unistd.h>
911
#include <fcntl.h>

lib_eio/unix/primitives.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/* AUTOGENERATED FILE, DO NOT EDIT */
2+
#define CAML_NAME_SPACE
3+
#define _GNU_SOURCE
4+
#include <caml/mlvalues.h>
5+
CAMLprim value eio_unix_make_string_array(value);
6+
CAMLprim value eio_unix_fork_execve(value);
7+
CAMLprim value eio_unix_fork_chdir(value);
8+
CAMLprim value eio_unix_fork_fchdir(value);
9+
CAMLprim value eio_unix_fork_dups(value);
10+
CAMLprim value eio_unix_is_blocking(value);

lib_eio/unix/stubs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#include "primitives.h"
2+
13
#include <unistd.h>
24
#include <fcntl.h>
35

lib_eio_linux/dune

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,28 @@
1212
(include_dirs ../lib_eio/unix/include)
1313
(names eio_stubs))
1414
(libraries eio eio.utils eio.unix uring logs fmt))
15+
16+
(rule
17+
(enabled_if
18+
(and
19+
%{bin-available:lintcstubs_arity_cmt}
20+
(or (= %{system} "linux") ; Historically, just Linux-x86
21+
(= %{system} "linux_eabihf") ; Historically, Linux-arm32
22+
(= %{system} "linux_elf") ; Historically, Linux-x86_32
23+
(= %{system} "elf")))) ; Historically, Linux-ppc64
24+
(action
25+
(with-stdout-to
26+
primitives.h.new
27+
(run %{bin:lintcstubs_arity_cmt} %{dep:.eio_linux.objs/byte/eio_linux__Low_level.cmt} %{dep:.eio_linux.objs/byte/eio_linux__Sched.cmt}))))
28+
29+
(rule
30+
(enabled_if
31+
(and
32+
%{bin-available:lintcstubs_arity_cmt}
33+
(or (= %{system} "linux") ; Historically, just Linux-x86
34+
(= %{system} "linux_eabihf") ; Historically, Linux-arm32
35+
(= %{system} "linux_elf") ; Historically, Linux-x86_32
36+
(= %{system} "elf")))) ; Historically, Linux-ppc64
37+
(alias runtest)
38+
(action
39+
(diff primitives.h primitives.h.new)))

lib_eio_linux/eio_stubs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
// We need caml_convert_signal_number
2020
#define CAML_INTERNALS
2121

22+
#include "primitives.h"
23+
2224
#include <caml/mlvalues.h>
2325
#include <caml/memory.h>
2426
#include <caml/alloc.h>

lib_eio_linux/primitives.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* AUTOGENERATED FILE, DO NOT EDIT */
2+
#define CAML_NAME_SPACE
3+
#define _GNU_SOURCE
4+
#include <caml/mlvalues.h>
5+
CAMLprim value caml_eio_eventfd(value);
6+
CAMLprim value caml_eio_mkdirat(value, value, value);
7+
CAMLprim value caml_eio_renameat(value, value, value, value);
8+
CAMLprim value caml_eio_getrandom(value, value, value);
9+
CAMLprim value caml_eio_getdents(value);
10+
CAMLprim value caml_eio_clone3(value, value);
11+
CAMLprim value caml_eio_pidfd_send_signal(value, value);

lib_eio_posix/dune

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,16 @@
1313
(targets config.ml)
1414
(enabled_if (= %{os_type} "Unix"))
1515
(action (run ./include/discover.exe)))
16+
17+
(rule
18+
(enabled_if (and (= %{os_type} "Unix") %{bin-available:lintcstubs_arity_cmt}))
19+
(action
20+
(with-stdout-to
21+
primitives.h.new
22+
(run %{bin:lintcstubs_arity_cmt} %{dep:.eio_posix.objs/byte/eio_posix__Low_level.cmt}))))
23+
24+
(rule
25+
(enabled_if (and (= %{os_type} "Unix") %{bin-available:lintcstubs_arity_cmt}))
26+
(alias runtest)
27+
(action
28+
(diff primitives.h primitives.h.new)))

lib_eio_posix/eio_posix_stubs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#include "primitives.h"
2+
13
#define _FILE_OFFSET_BITS 64
24

35
#include <sys/types.h>

lib_eio_posix/primitives.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/* AUTOGENERATED FILE, DO NOT EDIT */
2+
#define CAML_NAME_SPACE
3+
#define _GNU_SOURCE
4+
#include <caml/mlvalues.h>
5+
CAMLprim value caml_eio_posix_send_msg(value, value, value, value, value);
6+
CAMLprim value caml_eio_posix_recv_msg(value, value, value);
7+
CAMLprim value caml_eio_posix_getrandom(value, value, value);
8+
CAMLprim value caml_eio_posix_readv(value, value);
9+
CAMLprim value caml_eio_posix_writev(value, value);
10+
CAMLprim value caml_eio_posix_preadv(value, value, value);
11+
CAMLprim value caml_eio_posix_pwritev(value, value, value);
12+
CAMLprim value caml_eio_posix_openat(value, value, value, value);
13+
CAMLprim value caml_eio_posix_mkdirat(value, value, value);
14+
CAMLprim value caml_eio_posix_unlinkat(value, value, value);
15+
CAMLprim value caml_eio_posix_renameat(value, value, value, value);
16+
CAMLprim value caml_eio_posix_spawn(value, value);

0 commit comments

Comments
 (0)