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);
26 printf ("Splice error: %s\n", strerror(errno));
27 caml_failwith("Splice system call returned -1");
29 CAMLreturn(Val_int(ret));
32 CAMLprim value stub_tee(value fd_in, value fd_out, value len)
34 CAMLparam3(fd_in, fd_out, len);
36 ret = syscall(TEE_SYSCALL,Int_val(fd_in), Int_val(fd_out), Int_val(len), SPLICE_F_NONBLOCK);
38 printf ("Sendfile error: %s\n", strerror(errno));
39 caml_failwith("Splice system call returned -1");
41 CAMLreturn(Val_int(ret));