-
Notifications
You must be signed in to change notification settings - Fork 0
/
PipeMagic.xs
80 lines (68 loc) · 1.37 KB
/
PipeMagic.xs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "ppport.h"
#include <fcntl.h>
#include <errno.h>
#ifdef __linux__
#include <sys/sendfile.h>
#endif
#include "const-c.inc"
typedef PerlIO * OutputStream;
typedef PerlIO * InputStream;
MODULE = Linux::PipeMagic PACKAGE = Linux::PipeMagic
PROTOTYPES: ENABLE
INCLUDE: const-xs.inc
ssize_t
systee(io_in, io_out, len, flags)
InputStream io_in
OutputStream io_out
ssize_t len
int flags
PREINIT:
int fd_in = PerlIO_fileno(io_in);
int fd_out = PerlIO_fileno(io_out);
CODE:
#ifdef __linux__
RETVAL = tee(fd_in, fd_out, len, flags);
#else
errno = ENOSYS;
RETVAL = -1;
#endif
OUTPUT:
RETVAL
ssize_t
syssplice(io_in, io_out, len, flags)
InputStream io_in
OutputStream io_out
ssize_t len
int flags
PREINIT:
int fd_in = PerlIO_fileno(io_in);
int fd_out = PerlIO_fileno(io_out);
CODE:
#ifdef __linux__
RETVAL = splice(fd_in, NULL, fd_out, NULL, len, flags);
#else
errno = ENOSYS;
RETVAL = -1;
#endif
OUTPUT:
RETVAL
ssize_t
syssendfile(io_out, io_in, len)
InputStream io_in
OutputStream io_out
ssize_t len
PREINIT:
int fd_in = PerlIO_fileno(io_in);
int fd_out = PerlIO_fileno(io_out);
CODE:
#ifdef __linux__
RETVAL = sendfile(fd_out, fd_in, NULL, len);
#else
errno = ENOSYS;
RETVAL = -1;
#endif
OUTPUT:
RETVAL