1 /* This module allows data between vsys clients and servers to be copied in kernel -
2 * and some of these copies to be eliminated through page rewrites */
4 #define SPLICE_SYSCALL 313
5 #define TEE_SYSCALL 315
6 #define SPLICE_F_NONBLOCK 0x02
12 #include <sys/syscall.h>
13 #include <caml/mlvalues.h>
14 #include <caml/memory.h>
15 #include <caml/alloc.h>
16 #include <caml/custom.h>
17 #include <caml/fail.h>
18 #include <caml/signals.h>
20 CAMLprim value stub_splice(value fd_in, value fd_out, value len)
22 CAMLparam3(fd_in, fd_out, len);
24 ret = syscall(SPLICE_SYSCALL, Int_val(fd_in), NULL, Int_val(fd_out),NULL, Int_val(len), SPLICE_F_NONBLOCK);
25 if (ret == -1 && errno!=EAGAIN) {
26 caml_failwith("Splice system call returned -1");
28 CAMLreturn(Val_int(ret));
31 CAMLprim value stub_tee(value fd_in, value fd_out, value len)
33 CAMLparam3(fd_in, fd_out, len);
35 ret = syscall(TEE_SYSCALL,Int_val(fd_in), Int_val(fd_out), Int_val(len), SPLICE_F_NONBLOCK);
36 if (ret == -1 && errno!=EAGAIN) {
37 caml_failwith(strerror(errno));
39 CAMLreturn(Val_int(ret));