Ruby io_splice 4.4.2 - URL + doc updates
[ruby_io_splice.git] / ext / io_splice / io_splice_ext.c
blobc5387a7cebec0b849602b96ff3980de07e638b72
1 #include "ruby.h"
2 #ifdef HAVE_RUBY_IO_H
3 # include "ruby/io.h"
4 #else
5 # include "rubyio.h"
6 #endif
7 #include <errno.h>
8 #include <fcntl.h>
9 #include <assert.h>
10 #include <sys/uio.h>
11 #include <limits.h>
12 #include <alloca.h>
13 #include <unistd.h>
15 static VALUE sym_EAGAIN;
16 #define WAITALL 0x4000000
18 /* taken from haproxy */
19 #define MAX_AT_ONCE (1 << 30)
21 #ifndef F_LINUX_SPECIFIC_BASE
22 # define F_LINUX_SPECIFIC_BASE 1024
23 #endif
25 #ifndef F_GETPIPE_SZ
26 # define F_SETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 7)
27 # define F_GETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 8)
28 #endif
30 #if ! HAVE_RB_IO_T
31 # define rb_io_t OpenFile
32 #endif
34 #ifdef GetReadFile
35 # define FPTR_TO_FD(fptr) (fileno(GetReadFile(fptr)))
36 #else
37 # if !HAVE_RB_IO_T || (RUBY_VERSION_MAJOR == 1 && RUBY_VERSION_MINOR == 8)
38 # define FPTR_TO_FD(fptr) fileno(fptr->f)
39 # else
40 # define FPTR_TO_FD(fptr) fptr->fd
41 # endif
42 #endif
44 #ifndef SSIZET2NUM
45 # define SSIZET2NUM(x) LONG2NUM(x)
46 #endif
47 #ifndef NUM2SSIZET
48 # define NUM2SSIZET(x) NUM2LONG(x)
49 #endif
50 #ifndef SIZET2NUM
51 # define SIZET2NUM(x) ULONG2NUM(x)
52 #endif
53 #ifndef NUM2SIZET
54 # define NUM2SIZET(x) NUM2ULONG(x)
55 #endif
57 static int my_fileno(VALUE io)
59 rb_io_t *fptr;
61 for (;;) {
62 switch (TYPE(io)) {
63 case T_FIXNUM: return FIX2INT(io);
64 case T_FILE: {
65 GetOpenFile(io, fptr);
66 return FPTR_TO_FD(fptr);
68 default:
69 io = rb_convert_type(io, T_FILE, "IO", "to_io");
70 /* retry */
75 static int check_fileno(VALUE io)
77 int saved_errno = errno;
78 int fd = my_fileno(io);
79 errno = saved_errno;
80 return fd;
83 #if defined(HAVE_RB_THREAD_CALL_WITHOUT_GVL) && defined(HAVE_RUBY_THREAD_H)
84 /* Ruby 2.0+ */
85 # include <ruby/thread.h>
86 # define WITHOUT_GVL(fn,a,ubf,b) \
87 rb_thread_call_without_gvl((fn),(a),(ubf),(b))
88 #elif defined(HAVE_RB_THREAD_BLOCKING_REGION)
89 typedef VALUE (*my_blocking_fn_t)(void*);
90 # define WITHOUT_GVL(fn,a,ubf,b) \
91 rb_thread_blocking_region((my_blocking_fn_t)(fn),(a),(ubf),(b))
93 #else /* Ruby 1.8 */
94 /* partial emulation of the 1.9 rb_thread_blocking_region under 1.8 */
95 # include <rubysig.h>
96 # define RUBY_UBF_IO ((rb_unblock_function_t *)-1)
97 typedef void rb_unblock_function_t(void *);
98 typedef void * rb_blocking_function_t(void *);
99 static void * WITHOUT_GVL(rb_blocking_function_t *func, void *data1,
100 rb_unblock_function_t *ubf, void *data2)
102 void *rv;
104 assert(RUBY_UBF_IO == ubf && "RUBY_UBF_IO required for emulation");
106 TRAP_BEG;
107 rv = func(data1);
108 TRAP_END;
110 return rv;
112 #endif /* ! HAVE_RB_THREAD_BLOCKING_REGION */
114 #ifndef RSTRING_PTR
115 # define RSTRING_PTR(s) (RSTRING(s)->ptr)
116 #endif
117 #ifndef RSTRING_LEN
118 # define RSTRING_LEN(s) (RSTRING(s)->len)
119 #endif
120 #ifndef RARRAY_LEN
121 # define RARRAY_LEN(s) (RARRAY(s)->len)
122 #endif
124 #define io_run(fn,data) WITHOUT_GVL((fn),(data),RUBY_UBF_IO,0)
126 struct splice_args {
127 int fd_in;
128 int fd_out;
129 off_t *off_in;
130 off_t *off_out;
131 size_t len;
132 unsigned flags;
135 static void * nogvl_splice(void *ptr)
137 struct splice_args *a = ptr;
139 if (a->len > MAX_AT_ONCE)
140 a->len = MAX_AT_ONCE;
142 return (void *)splice(a->fd_in, a->off_in, a->fd_out, a->off_out,
143 a->len, a->flags);
146 static ssize_t do_splice(int argc, VALUE *argv, unsigned dflags)
148 off_t i = 0, o = 0;
149 VALUE io_in, off_in, io_out, off_out, len, flags;
150 struct splice_args a;
151 ssize_t bytes;
152 ssize_t total = 0;
153 unsigned waitall;
155 rb_scan_args(argc, argv, "51",
156 &io_in, &off_in, &io_out, &off_out, &len, &flags);
158 a.off_in = NIL_P(off_in) ? NULL : (i = NUM2OFFT(off_in), &i);
159 a.off_out = NIL_P(off_out) ? NULL : (o = NUM2OFFT(off_out), &o);
160 a.len = NUM2SIZET(len);
161 a.flags = NIL_P(flags) ? dflags : NUM2UINT(flags) | dflags;
162 waitall = a.flags & WAITALL;
163 if (waitall)
164 a.flags ^= WAITALL;
166 for (;;) {
167 a.fd_in = check_fileno(io_in);
168 a.fd_out = check_fileno(io_out);
169 bytes = (ssize_t)io_run(nogvl_splice, &a);
170 if (bytes < 0) {
171 if (errno == EINTR)
172 continue;
173 if (waitall && errno == EAGAIN) {
174 rb_io_wait_readable(check_fileno(io_in));
175 errno = EAGAIN;
176 rb_io_wait_writable(check_fileno(io_out));
177 continue;
179 if (total > 0)
180 return total;
181 return bytes;
182 } else if (bytes == 0) {
183 break;
184 } else if (waitall) {
185 total += bytes;
186 if ((a.len -= bytes) == 0)
187 return total;
188 i += bytes;
189 o += bytes;
190 } else {
191 return bytes;
195 return total;
199 * call-seq:
200 * IO.splice(io_in, off_in, io_out, off_out, len) => integer
201 * IO.splice(io_in, off_in, io_out, off_out, len, flags) => integer
203 * Splice +len+ bytes from/to a pipe. Either +io_in+ or +io_out+
204 * MUST be a pipe. +io_in+ and +io_out+ may BOTH be pipes as of
205 * Linux 2.6.31 or later.
207 * +off_in+ and +off_out+ if non-nil may be used to
208 * specify an offset for the non-pipe file descriptor.
210 * +flags+ defaults to zero if unspecified.
211 * +flags+ may be a bitmask of the following flags:
213 * * IO::Splice::F_MOVE
214 * * IO::Splice::F_NONBLOCK
215 * * IO::Splice::F_MORE
217 * Returns the number of bytes spliced.
218 * Raises EOFError when +io_in+ has reached end of file.
219 * Raises Errno::EAGAIN if the IO::Splice::F_NONBLOCK flag is set
220 * and the pipe has no data to read from or space to write to. May
221 * also raise Errno::EAGAIN if the non-pipe descriptor has no data
222 * to read from or space to write to.
224 * As splice never exposes buffers to userspace, it will not take
225 * into account userspace buffering done by Ruby or stdio. It is
226 * also not subject to encoding/decoding filters under Ruby 1.9.
228 * Consider using IO.trysplice if +io_out+ is a pipe or if you are using
229 * non-blocking I/O on both descriptors as it avoids the cost of raising
230 * common Errno::EAGAIN exceptions.
232 * See manpage for full documentation:
233 * http://kernel.org/doc/man-pages/online/pages/man2/splice.2.html
235 static VALUE my_splice(int argc, VALUE *argv, VALUE self)
237 ssize_t n = do_splice(argc, argv, 0);
239 if (n == 0)
240 rb_eof_error();
241 if (n < 0)
242 rb_sys_fail("splice");
243 return SSIZET2NUM(n);
247 * call-seq:
248 * IO.trysplice(io_in, off_in, io_out, off_out, len) => integer
249 * IO.trysplice(io_in, off_in, io_out, off_out, len, flags) => integer
251 * Exactly like IO.splice, except +:EAGAIN+ is returned when either
252 * the read or write end would block instead of raising Errno::EAGAIN.
254 * IO::Splice::F_NONBLOCK is always passed for the pipe descriptor,
255 * but this can still block if the non-pipe descriptor is blocking.
257 * See IO.splice documentation for more details.
259 * This method is recommended whenever +io_out+ is a pipe.
261 static VALUE trysplice(int argc, VALUE *argv, VALUE self)
263 ssize_t n = do_splice(argc, argv, SPLICE_F_NONBLOCK);
265 if (n == 0)
266 return Qnil;
267 if (n < 0) {
268 if (errno == EAGAIN)
269 return sym_EAGAIN;
270 rb_sys_fail("splice");
272 return SSIZET2NUM(n);
275 struct tee_args {
276 int fd_in;
277 int fd_out;
278 size_t len;
279 unsigned flags;
282 /* runs without GVL */
283 static void * nogvl_tee(void *ptr)
285 struct tee_args *a = ptr;
287 if (a->len > MAX_AT_ONCE)
288 a->len = MAX_AT_ONCE;
290 return (void *)tee(a->fd_in, a->fd_out, a->len, a->flags);
293 static ssize_t do_tee(int argc, VALUE *argv, unsigned dflags)
295 VALUE io_in, io_out, len, flags;
296 struct tee_args a;
297 ssize_t bytes;
298 ssize_t total = 0;
299 unsigned waitall;
301 rb_scan_args(argc, argv, "31", &io_in, &io_out, &len, &flags);
302 a.len = (size_t)NUM2SIZET(len);
303 a.flags = NIL_P(flags) ? dflags : NUM2UINT(flags) | dflags;
304 waitall = a.flags & WAITALL;
305 if (waitall)
306 a.flags ^= WAITALL;
308 for (;;) {
309 a.fd_in = check_fileno(io_in);
310 a.fd_out = check_fileno(io_out);
311 bytes = (ssize_t)io_run(nogvl_tee, &a);
312 if (bytes < 0) {
313 if (errno == EINTR)
314 continue;
315 if (waitall && errno == EAGAIN) {
316 rb_io_wait_readable(check_fileno(io_in));
317 errno = EAGAIN;
318 rb_io_wait_writable(check_fileno(io_out));
319 continue;
321 if (total > 0)
322 return total;
323 return bytes;
324 } else if (bytes == 0) {
325 break;
326 } else if (waitall) {
327 total += bytes;
328 if ((a.len -= bytes) == 0)
329 return total;
330 } else {
331 return bytes;
335 return total;
339 * call-seq:
340 * IO.tee(io_in, io_out, len) => integer
341 * IO.tee(io_in, io_out, len, flags) => integer
343 * Copies up to +len+ bytes of data from +io_in+ to +io_out+. +io_in+
344 * and +io_out+ must both refer to pipe descriptors. +io_in+ and +io_out+
345 * may not be endpoints of the same pipe.
347 * +flags+ may be zero (the default) or a combination of:
348 * * IO::Splice::F_NONBLOCK
350 * Other IO::Splice flags are currently unimplemented or have no effect.
352 * Returns the number of bytes duplicated if successful.
353 * Raises EOFError when +io_in+ is closed and emptied.
354 * Raises Errno::EAGAIN when +io_in+ is empty and/or +io_out+ is full
355 * and +flags+ contains IO::Splice::F_NONBLOCK
357 * Consider using IO.trytee if you are using IO::Splice::F_NONBLOCK
358 * as it avoids the cost of raising common Errno::EAGAIN exceptions.
360 * See manpage for full documentation:
361 * http://kernel.org/doc/man-pages/online/pages/man2/tee.2.html
363 static VALUE my_tee(int argc, VALUE *argv, VALUE self)
365 ssize_t n = do_tee(argc, argv, 0);
367 if (n == 0)
368 rb_eof_error();
369 if (n < 0)
370 rb_sys_fail("tee");
372 return SSIZET2NUM(n);
376 * call-seq:
377 * IO.trytee(io_in, io_out, len) => integer
378 * IO.trytee(io_in, io_out, len, flags) => integer
380 * Exactly like IO.tee, except +:EAGAIN+ is returned when either
381 * the read or write end would block instead of raising Errno::EAGAIN.
383 * IO::Splice::F_NONBLOCK is always passed for the pipe descriptor,
384 * but this can still block if the non-pipe descriptor is blocking.
386 * See IO.tee documentation for more details.
388 static VALUE trytee(int argc, VALUE *argv, VALUE self)
390 ssize_t n = do_tee(argc, argv, SPLICE_F_NONBLOCK);
392 if (n == 0)
393 return Qnil;
394 if (n < 0) {
395 if (errno == EAGAIN)
396 return sym_EAGAIN;
397 rb_sys_fail("tee");
400 return SSIZET2NUM(n);
403 struct vmsplice_args {
404 int fd;
405 unsigned flags;
406 struct iovec *iov;
407 unsigned long nr_segs;
410 static void * nogvl_vmsplice(void *ptr)
412 struct vmsplice_args *a = ptr;
414 return (void *)vmsplice(a->fd, a->iov, a->nr_segs, a->flags);
417 /* this can't be a function since we use alloca() */
418 #define ARY2IOVEC(iov,iovcnt,expect,ary) \
419 do { \
420 struct iovec *tmp; \
421 unsigned long i; \
422 iovcnt = (unsigned long)RARRAY_LEN(ary); \
423 if (iovcnt > IOV_MAX) \
424 rb_raise(rb_eArgError, "array is larger than IOV_MAX"); \
425 iov = tmp = alloca(sizeof(struct iovec) * iovcnt); \
426 expect = 0; \
427 for (i = 0; i < iovcnt; tmp++, i++) { \
428 VALUE cur = rb_ary_entry(ary, (long)i); \
429 Check_Type(cur, T_STRING); \
430 tmp->iov_base = RSTRING_PTR(cur); \
431 tmp->iov_len = RSTRING_LEN(cur); \
432 expect += tmp->iov_len; \
434 } while (0)
436 static void advance_vmsplice_args(struct vmsplice_args *a, long n)
438 struct iovec *new_iov = a->iov;
439 unsigned long i;
441 /* skip over iovecs we've already written completely */
442 for (i = 0; i < a->nr_segs; i++, new_iov++) {
443 if (n == 0)
444 break;
446 * partially written iov,
447 * modify and retry with current iovec in
448 * front
450 if (new_iov->iov_len > (size_t)n) {
451 VALUE base = (VALUE)new_iov->iov_base;
453 new_iov->iov_len -= n;
454 new_iov->iov_base = (void *)(base + n);
455 break;
458 n -= new_iov->iov_len;
461 /* setup to retry without the already-written iovecs */
462 a->nr_segs -= i;
463 a->iov = new_iov;
467 * call-seq:
468 * IO.vmsplice(io, string_array) => integer
469 * IO.vmsplice(io, string_array, flags) => integer
470 * IO.vmsplice(io, string) => integer
471 * IO.vmsplice(io, string, flags) => integer
473 * Transfers an array of strings into the pipe descriptor given by io.
474 * +io+ must be the writable end of a pipe.
476 * This may allow the kernel to avoid data copies in some cases.
477 * but is (probably) of limited usefulness in Ruby. If you have
478 * use cases or ideas for making this more useful for Ruby users,
479 * please tell us at ruby-io-splice@yhbt.net!
481 * Also consider the "sendfile" RubyGem or IO.copy_stream in Ruby 1.9
482 * if you want to do zero-copy file transfers to pipes or sockets. As
483 * of Linux 2.6.33, sendfile(2) can copy to any output descriptor,
484 * not just sockets.
486 * See manpage for full documentation:
487 * http://kernel.org/doc/man-pages/online/pages/man2/vmsplice.2.html
489 static VALUE my_vmsplice(int argc, VALUE * argv, VALUE self)
491 ssize_t rv = 0;
492 ssize_t left;
493 struct vmsplice_args a;
494 struct iovec iov;
495 ssize_t n;
497 VALUE io, data, flags;
499 rb_scan_args(argc, argv, "21", &io, &data, &flags);
501 switch (TYPE(data)) {
502 case T_STRING:
503 iov.iov_base = RSTRING_PTR(data);
504 iov.iov_len = (size_t)(left = (ssize_t)RSTRING_LEN(data));
505 a.iov = &iov;
506 a.nr_segs = 1;
507 break;
508 case T_ARRAY:
509 ARY2IOVEC(a.iov, a.nr_segs, left, data);
510 break;
511 default:
512 rb_raise(rb_eTypeError, "wrong argument type %s "
513 "(expected a String or Array of strings)",
514 rb_obj_classname(data));
517 a.flags = NIL_P(flags) ? 0 : NUM2UINT(flags);
519 for (;;) {
520 a.fd = check_fileno(io);
521 n = (ssize_t)io_run(nogvl_vmsplice, &a);
523 if (n < 0) {
524 if (errno == EAGAIN) {
525 if (a.flags & SPLICE_F_NONBLOCK)
526 rb_sys_fail("vmsplice");
527 if (rb_io_wait_writable(check_fileno(io)))
528 continue;
529 /* fall through on error */
532 * unlikely to hit this case, return the
533 * already written bytes, we'll let the next
534 * write (or close) fail instead
536 if (rv > 0)
537 break;
538 if (errno == EINTR)
539 continue;
540 rb_sys_fail("vmsplice");
543 rv += n;
544 left -= n;
545 if (left == 0)
546 break;
547 advance_vmsplice_args(&a, n);
550 return SSIZET2NUM(rv);
554 * call-seq:
555 * reader, writer = IO.pipe
556 * reader.pipe_size => integer
558 * Returns the pipe capacity of the underlying pipe in bytes. The
559 * default capacity is 65536 bytes since Linux 2.6.11, and 4096 bytes
560 * in previous kernels.
562 * Since the pipe is a circular buffer in the same kernel, the size
563 * of the reader is exactly the same as the size of the writer.
565 * This method is only exposed on Linux 2.6.35 or later.
567 static VALUE pipe_size(VALUE self)
569 int size = fcntl(my_fileno(self), F_GETPIPE_SZ);
571 if (size < 0)
572 rb_sys_fail("fcntl(F_GETPIPE_SZ)");
574 return INT2NUM(size);
578 * call-seq:
579 * reader, writer = IO.pipe
580 * reader.pipe_size = integer
582 * Sets and returns the pipe capacity of the underlying pipe in bytes.
584 * This MUST be a power-of-two, or Errno::EINVAL will be raised.
585 * Linux will silently increase this to be equal to the page size
586 * (4096 bytes on most architectures) if the specified value is
587 * less than the size of a page.
589 * For users without CAP_SYS_RESOURCE, this raises Errno::EPERM when
590 * attempting to specify a value greater than the value in
591 * /proc/sys/fs/pipe-max-size.
593 * Since the pipe is a circular buffer in the same kernel, the size
594 * of the reader is exactly the same as the size of the writer.
596 * Raises Errno::EBUSY if the assigned value is less than
597 * the currently filled portion of the pipe.
599 * This method is only exposed on Linux 2.6.35 or later.
601 static VALUE set_pipe_size(VALUE self, VALUE size)
603 int fd = my_fileno(self);
604 int bytes = NUM2INT(size);
605 int rv = fcntl(fd, F_SETPIPE_SZ, bytes);
607 if (rv < 0) {
608 if (errno == ENOMEM) {
609 rb_gc();
610 rv = fcntl(fd, F_SETPIPE_SZ, bytes);
612 if (rv < 0)
613 rb_sys_fail("fcntl(F_SETPIPE_SZ)");
616 return size;
619 static int can_mod_pipe_size(void)
622 * pipe2 appeared in Linux 2.6.27, F_*PIPE_SZ appeared in 2.6.35,
623 * thus not having pipe2 automatically disqualifies us from having
624 * F_*PIPE_SZ support
626 #ifdef HAVE_PIPE2
627 int fds[2];
628 int rc = pipe2(fds, O_CLOEXEC);
630 if (rc == 0) {
631 rc = fcntl(fds[0], F_GETPIPE_SZ);
632 rc = rc < 0 ? 0 : 1;
634 (void)close(fds[0]);
635 (void)close(fds[1]);
636 } else {
638 * weird error, but don't raise during init, this could be
639 * ENOSYS, even..
641 rc = 0;
643 errno = 0;
644 return rc;
645 #else /* ! HAVE_PIPE2 */
646 return 0;
647 #endif /* ! HAVE_PIPE2 */
650 #define NODOC_CONST(klass,name,value) \
651 rb_define_const((klass),(name),(value))
653 void Init_io_splice_ext(void)
655 VALUE mSplice = rb_define_module_under(rb_cIO, "Splice");
657 rb_define_singleton_method(rb_cIO, "splice", my_splice, -1);
658 rb_define_singleton_method(rb_cIO, "trysplice", trysplice, -1);
659 rb_define_singleton_method(rb_cIO, "tee", my_tee, -1);
660 rb_define_singleton_method(rb_cIO, "trytee", trytee, -1);
661 rb_define_singleton_method(rb_cIO, "vmsplice", my_vmsplice, -1);
664 * Attempt to move pages instead of copying. This is only a hint
665 * and support for it was removed in Linux 2.6.21. It will be
666 * re-added for FUSE filesystems only in Linux 2.6.35.
668 rb_define_const(mSplice, "F_MOVE", UINT2NUM(SPLICE_F_MOVE));
669 assert(WAITALL != SPLICE_F_MOVE && "WAITALL == F_MOVE");
672 * Do not block on pipe I/O. This flag only affects the pipe(s)
673 * being spliced from/to and has no effect on the non-pipe
674 * descriptor (which requires non-blocking operation to be set
675 * explicitly).
677 * The non-blocking flag (O_NONBLOCK) on the pipe descriptors
678 * themselves are ignored by this family of functions, and
679 * using this flag is the only way to get non-blocking operation
680 * out of them.
682 * It is highly recommended this flag be set (or IO.trysplice used)
683 * whenever splicing from a socket into a pipe unless there is
684 * another (native) thread or process doing a blocking read on that
685 * pipe. Otherwise it is possible to block a single-threaded process
686 * if the socket buffers are larger than the pipe buffers.
688 rb_define_const(mSplice, "F_NONBLOCK", UINT2NUM(SPLICE_F_NONBLOCK));
689 assert(WAITALL != SPLICE_F_NONBLOCK && "WAITALL == F_NONBLOCK");
692 * Indicate that there may be more data coming into the outbound
693 * descriptor. This can allow the kernel to avoid sending partial
694 * frames from sockets. Currently only used with splice.
696 rb_define_const(mSplice, "F_MORE", UINT2NUM(SPLICE_F_MORE));
697 assert(WAITALL != SPLICE_F_MORE && "WAITALL == F_MORE");
700 * Only usable by vmsplice. This flag probably not useful in the
701 * context of Ruby applications which cannot control alignment.
703 rb_define_const(mSplice, "F_GIFT", UINT2NUM(SPLICE_F_GIFT));
704 assert(WAITALL != SPLICE_F_GIFT && "WAITALL == F_GIFT");
707 * Retry until the requested transfer is complete, this will
708 * cause IO.splice/IO.tee to never return less than the requested
709 * transfer size unless an error occored.
711 * IO.vmsplice always defaults to this behavior.
713 NODOC_CONST(mSplice, "WAITALL", UINT2NUM(WAITALL));
716 * The maximum size of an atomic write to a pipe
717 * POSIX requires this to be at least 512 bytes.
718 * Under Linux, this is 4096 bytes.
720 rb_define_const(mSplice, "PIPE_BUF", UINT2NUM(PIPE_BUF));
723 * The maximum size we're allowed to splice at once. Larger
724 * sizes will be broken up and retried if the WAITALL flag or
725 * IO::Splice.copy_stream is used.
727 rb_define_const(mSplice, "MAX_AT_ONCE", SIZET2NUM(MAX_AT_ONCE));
729 if (can_mod_pipe_size()) {
730 rb_define_method(rb_cIO, "pipe_size", pipe_size, 0);
731 rb_define_method(rb_cIO, "pipe_size=", set_pipe_size, 1);
734 * fcntl() command constant used to return the size of a pipe.
735 * This constant is only defined when running Linux 2.6.35
736 * or later. For convenience, use IO#pipe_size instead.
738 rb_define_const(mSplice, "F_GETPIPE_SZ",
739 UINT2NUM(F_GETPIPE_SZ));
742 * fcntl() command constant used to set the size of a pipe.
743 * This constant is only defined when running Linux 2.6.35
744 * or later. For convenience, use IO#pipe_size= instead.
746 rb_define_const(mSplice, "F_SETPIPE_SZ",
747 UINT2NUM(F_SETPIPE_SZ));
750 sym_EAGAIN = ID2SYM(rb_intern("EAGAIN"));