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