8 #define __NR_splice 313
10 #define __NR_vmsplice 316
11 #elif defined(__x86_64__)
12 #define __NR_splice 275
14 #define __NR_vmsplice 278
15 #elif defined(__powerpc__) || defined(__powerpc64__)
16 #define __NR_splice 283
18 #define __NR_vmsplice 285
19 #elif defined(__ia64__)
20 #define __NR_splice 1297
22 #define __NR_vmsplice 1301
24 #error unsupported arch
32 #define SPLICE_F_MOVE (0x01) /* move pages instead of copying */
33 #define SPLICE_F_NONBLOCK (0x02) /* don't block on the pipe splicing (but */
34 /* we may still block on the fd we splice */
35 /* from/to, of course */
36 #define SPLICE_F_MORE (0x04) /* expect more data */
38 static inline int splice(int fdin, loff_t *off_in, int fdout, loff_t *off_out,
39 size_t len, unsigned long flags)
41 return syscall(__NR_splice, fdin, off_in, fdout, off_out, len, flags);
45 static inline int tee(int fdin, int fdout, size_t len, unsigned int flags)
47 return syscall(__NR_tee, fdin, fdout, len, flags);
50 static inline int vmsplice(int fd, const struct iovec *iov,
51 unsigned long nr_segs, unsigned int flags)
53 return syscall(__NR_vmsplice, fd, iov, nr_segs, flags);
56 #define SPLICE_SIZE (64*1024)
58 #define BUG_ON(c) assert(!(c))
63 (void) (&_x == &_y); \
69 (void) (&_x == &_y); \
72 static inline int error(const char *n)
78 static int __check_pipe(int pfd)
82 if (fstat(pfd, &sb) < 0)
84 if (!S_ISFIFO(sb.st_mode))
90 static inline int check_input_pipe(void)
92 if (!__check_pipe(STDIN_FILENO))
95 fprintf(stderr, "stdin must be a pipe\n");
99 static inline int check_output_pipe(void)
101 if (!__check_pipe(STDOUT_FILENO))
104 fprintf(stderr, "stdout must be a pipe\n");