Ruby: io.c File Reference

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
io.c File Reference
`#include "ruby/internal/config.h"`
`#include "internal/scheduler.h"`
`#include <ctype.h>`
`#include <errno.h>`
`#include <stddef.h>`
`#include <sys/types.h>`
`#include <sys/stat.h>`
`#include "ruby/internal/stdbool.h"`
`#include "ccan/list/list.h"`
`#include "dln.h"`
`#include "encindex.h"`
`#include "id.h"`
`#include "internal.h"`
`#include "internal/encoding.h"`
`#include "internal/error.h"`
`#include "internal/inits.h"`
`#include "internal/io.h"`
`#include "internal/numeric.h"`
`#include "internal/object.h"`
`#include "internal/process.h"`
`#include "internal/thread.h"`
`#include "internal/transcode.h"`
`#include "internal/variable.h"`
`#include "ruby/io.h"`
`#include "ruby/thread.h"`
`#include "ruby/util.h"`
`#include "ruby_atomic.h"`
`#include "ruby/ractor.h"`
`#include "vm_core.h"`
`#include "builtin.h"`
`#include "io.rbinc"`

Go to the source code of this file.

## Data Structures
struct | argf
struct | io_internal_read_struct
struct | io_internal_write_struct
struct | binwrite_arg
struct | write_arg
struct | bufread_arg
struct | getline_arg
struct | finish_writeconv_arg
struct | sysopen_struct
struct | pipe_list
struct | select_args
struct | io_encoding_set_args
struct | foreach_arg
struct | seek_arg
struct | copy_stream_struct
struct | wait_for_single_fd
struct | argf_call_arg

## Macros
#define | USE_POLL 0
#define | free(x) xfree(x)
#define | off_t long
#define | NOFILE 64
#define | O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
#define | PIPE_BUF 512 /* is this ok? */
#define | EWOULDBLOCK EAGAIN
#define | IO_RBUF_CAPA_MIN 8192
#define | IO_CBUF_CAPA_MIN (128*1024)
#define | IO_RBUF_CAPA_FOR(fptr) (NEED_READCONV(fptr) ? IO_CBUF_CAPA_MIN : IO_RBUF_CAPA_MIN)
#define | IO_WBUF_CAPA_MIN 8192
#define | argf_of(obj) (*(struct argf *)DATA_PTR(obj))
#define | ARGF argf_of(argf)
#define | GetWriteIO(io) rb_io_get_write_io(io)
#define | READ_DATA_PENDING(fptr) ((fptr)->rbuf.len)
#define | READ_DATA_PENDING_COUNT(fptr) ((fptr)->rbuf.len)
#define | READ_DATA_PENDING_PTR(fptr) ((fptr)->rbuf.ptr+(fptr)->rbuf.off)
#define | READ_DATA_BUFFERED(fptr) READ_DATA_PENDING(fptr)
#define | READ_CHAR_PENDING(fptr) ((fptr)->cbuf.len)
#define | READ_CHAR_PENDING_COUNT(fptr) ((fptr)->cbuf.len)
#define | READ_CHAR_PENDING_PTR(fptr) ((fptr)->cbuf.ptr+(fptr)->cbuf.off)
#define | WAIT_FD_IN_WIN32(fptr)
#define | READ_CHECK(fptr)
#define | FMODE_PREP (1<<16)
#define | FMODE_SIGNAL_ON_EPIPE (1<<17)
#define | fptr_signal_on_epipe(fptr) (((fptr)->mode & FMODE_SIGNAL_ON_EPIPE) != 0)
#define | fptr_set_signal_on_epipe(fptr, flag)
#define | rb_sys_fail_on_write(fptr)
#define | NEED_NEWLINE_DECORATOR_ON_READ(fptr) ((fptr)->mode & FMODE_TEXTMODE)
#define | NEED_NEWLINE_DECORATOR_ON_WRITE(fptr) ((fptr)->mode & FMODE_TEXTMODE)
#define | DEFAULT_TEXTMODE 0
#define | NEED_READCONV(fptr) ((fptr)->encs.enc2 != NULL || NEED_NEWLINE_DECORATOR_ON_READ(fptr))
#define | NEED_WRITECONV(fptr)
#define | SET_BINARY_MODE(fptr) (void)(fptr)
#define | NEED_NEWLINE_DECORATOR_ON_READ_CHECK(fptr) (void)(fptr)
#define | SET_UNIVERSAL_NEWLINE_DECORATOR_IF_ENC2(enc2, ecflags) ((void)(enc2), (void)(ecflags))
#define | SET_BINARY_MODE_WITH_SEEK_CUR(fptr) (void)(fptr)
#define | shutdown(a, b) 0
#define | is_socket(fd, path) 0
#define | io_seek(fptr, ofs, whence) (errno = 0, lseek(flush_before_seek(fptr)->fd, (ofs), (whence)))
#define | io_tell(fptr) lseek(flush_before_seek(fptr)->fd, 0, SEEK_CUR)
#define | SEEK_SET 0
#define | SEEK_CUR 1
#define | SEEK_END 2
#define | S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
#define | do_write_retry(code) ret = code
#define | MODE_BTMODE(a, b, c)
#define | MODE_BTXMODE(a, b, c, d, e, f)
#define | fmode (fptr->mode)
#define | rb_io_fsync rb_f_notimplement
#define | rb_io_sync rb_f_notimplement
#define | rb_io_fdatasync rb_io_fsync
#define | MORE_CHAR_SUSPENDED Qtrue
#define | MORE_CHAR_FINISHED Qnil
#define | MAX_REALLOC_GAP 4096
#define | no_exception_p(opts) !rb_opts_exception_p((opts), TRUE)
#define | rb_io_close_on_exec_p rb_f_notimplement
#define | rb_io_set_close_on_exec rb_f_notimplement
#define | IS_PREP_STDIO(f) ((f)->mode & FMODE_PREP)
#define | PREP_STDIO_NAME(f) (RSTRING_PTR((f)->pathv))
#define | rb_io_fptr_finalize(fptr) rb_io_fptr_finalize_internal(fptr)
#define | KEEPGVL FALSE
#define | SHUT_RD 0
#define | SHUT_WR 1
#define | rb_io_pread rb_f_notimplement
#define | rb_io_pwrite rb_f_notimplement
#define | MODE_BINARY(a, b) (a)
#define | next_argv() argf_next_argv(argf)
#define | ARGF_GENERIC_INPUT_P() (ARGF.current_file == rb_stdin && !RB_TYPE_P(ARGF.current_file, T_FILE))
#define | ARGF_FORWARD(argc, argv)
#define | NEXT_ARGF_FORWARD(argc, argv)
#define | NUM2IOCTLREQ(num) ((int)NUM2LONG(num))
#define | DEFULT_IOCTL_NARG_LEN (256)
#define | rb_io_ioctl rb_f_notimplement
#define | rb_io_fcntl rb_f_notimplement
#define | rb_f_syscall rb_f_notimplement
#define | IOWAIT_SYSCALL "select"
#define | FOREACH_ARGF() while (next_argv())
#define | ARGF_block_call(mid, argc, argv, func, argf)

## Typedefs
typedef struct rb_io_enc_t | convconfig_t
typedef int | ioctl_req_t

## Enumerations
enum | { bom_prefix_len = (int)sizeof(bom_prefix) - 1 }
enum | { utf_prefix_len = (int)sizeof(utf_prefix) - 1 }

## Functions
void | rb_update_max_fd (int fd)
void | rb_maygvl_fd_fix_cloexec (int fd)
void | rb_fd_fix_cloexec (int fd)
int | rb_cloexec_open (const char *pathname, int flags, mode_t mode)
int | rb_cloexec_dup (int oldfd)
int | rb_cloexec_dup2 (int oldfd, int newfd)
int | rb_cloexec_pipe (int descriptors[2])
int | rb_cloexec_fcntl_dupfd (int fd, int minfd)
void | rb_eof_error (void)
VALUE | rb_io_taint_check (VALUE io)
void | rb_io_check_initialized (rb_io_t *fptr)
void | rb_io_check_closed (rb_io_t *fptr)
VALUE | rb_io_get_io (VALUE io)
VALUE | rb_io_check_io (VALUE io)
VALUE | rb_io_get_write_io (VALUE io)
VALUE | rb_io_set_write_io (VALUE io, VALUE w)
void | rb_io_check_char_readable (rb_io_t *fptr)
void | rb_io_check_byte_readable (rb_io_t *fptr)
void | rb_io_check_readable (rb_io_t *fptr)
void | rb_io_check_writable (rb_io_t *fptr)
int | rb_io_read_pending (rb_io_t *fptr)
void | rb_io_read_check (rb_io_t *fptr)
int | rb_gc_for_fd (int err)
VALUE | rb_io_wait (VALUE io, VALUE events, VALUE timeout)
int | rb_io_wait_readable (int f)
int | rb_io_wait_writable (int f)
int | rb_wait_for_single_fd (int fd, int events, struct timeval *timeout)
ssize_t | rb_io_bufwrite (VALUE io, const void *buf, size_t size)
VALUE | rb_io_write (VALUE io, VALUE str)
VALUE | rb_io_addstr (VALUE io, VALUE str)
VALUE | rb_io_flush_raw (VALUE io, int sync)
VALUE | rb_io_flush (VALUE io)
VALUE | rb_io_eof (VALUE io)
void | rb_io_set_nonblock (rb_io_t *fptr)
VALUE | rb_io_gets (VALUE io)
VALUE | rb_io_gets_internal (VALUE io)
VALUE | rb_io_getbyte (VALUE io)
VALUE | rb_io_ungetbyte (VALUE io, VALUE b)
VALUE | rb_io_ungetc (VALUE io, VALUE c)
void | rb_io_fptr_finalize_internal (void *ptr)
int | rb_io_fptr_finalize (rb_io_t *fptr)
size_t | rb_io_memsize (const rb_io_t *fptr)
int | rb_notify_fd_close (int fd, struct list_head *)
VALUE | rb_io_close (VALUE io)
VALUE | rb_io_binmode (VALUE io)
VALUE | rb_io_ascii8bit_binmode (VALUE io)
int | rb_io_modestr_fmode (const char *modestr)
int | rb_io_oflags_fmode (int oflags)
int | rb_io_modestr_oflags (const char *modestr)
int | rb_io_extract_encoding_option (VALUE opt, rb_encoding **enc_p, rb_encoding **enc2_p, int *fmode_p)
void | rb_io_extract_modeenc (VALUE *vmode_p, VALUE *vperm_p, VALUE opthash, int *oflags_p, int *fmode_p, convconfig_t *convconfig_p)
FILE * | rb_fdopen (int fd, const char *modestr)
VALUE | rb_file_open_str (VALUE fname, const char *modestr)
VALUE | rb_file_open (const char *fname, const char *modestr)
void | rb_io_synchronized (rb_io_t *fptr)
void | rb_io_unbuffered (rb_io_t *fptr)
int | rb_pipe (int *pipes)
char * | rb_execarg_commandline (const struct rb_execarg *eargp, VALUE *prog)
VALUE | rb_io_popen (VALUE pname, VALUE pmode, VALUE env, VALUE opt)
VALUE | rb_io_printf (int argc, const VALUE *argv, VALUE out)
VALUE | rb_io_print (int argc, const VALUE *argv, VALUE out)
int | rb_str_end_with_asciichar (VALUE str, int c)
VALUE | rb_io_puts (int argc, const VALUE *argv, VALUE out)
void | rb_p (VALUE obj)
void | rb_write_error2 (const char *mesg, long len)
void | rb_write_error (const char *mesg)
void | rb_write_error_str (VALUE mesg)
int | rb_stderr_tty_p (void)
VALUE | rb_io_fdopen (int fd, int oflags, const char *path)
VALUE | rb_io_prep_stdin (void)
VALUE | rb_io_prep_stdout (void)
VALUE | rb_io_prep_stderr (void)
FILE * | rb_io_stdio_file (rb_io_t *fptr)
rb_io_t * | rb_io_make_open_file (VALUE obj)
VALUE | rb_gets (void)
void | rb_stdio_set_default_encoding (void)
void | ruby_set_inplace_mode (const char *suffix)
VALUE | rb_get_argv (void)
void | rb_readwrite_sys_fail (enum rb_io_wait_readwrite waiting, const char *mesg)
void | rb_readwrite_syserr_fail (enum rb_io_wait_readwrite waiting, int n, const char *mesg)
void | Init_IO (void)

## Variables
VALUE | rb_cIO
VALUE | rb_eEOFError
VALUE | rb_eIOError
VALUE | rb_mWaitReadable
VALUE | rb_mWaitWritable
VALUE | rb_stdin
VALUE | rb_stdout
VALUE | rb_stderr
VALUE | rb_output_fs
VALUE | rb_rs
VALUE | rb_output_rs
VALUE | rb_default_rs
ID | ruby_static_id_signo

## Macro Definition Documentation

## ◆ ARGF

#define ARGF argf_of(argf)

Definition at line 483 of file io.c.

## ◆ ARGF_block_call

#define ARGF_block_call | ( |  | mid,
|  |  | argc,
|  |  | argv,
|  |  | func,
|  |  | argf
| ) |  |

Value:
rb_block_call_kw(ARGF.current_file, mid, argc, argv, \
func, argf, rb_keyword_given_p())
rb_keyword_given_p
int rb_keyword_given_p(void)
Definition: eval.c:948
ARGF
#define ARGF
Definition: io.c:483
rb_block_call_kw
VALUE rb_block_call_kw(VALUE, ID, int, const VALUE *, rb_block_call_func_t, VALUE, int)
Definition: vm_eval.c:1584
argc
int argc
Definition: ruby.c:240
argv
char ** argv
Definition: ruby.c:241
argf
Definition: io.c:221

Definition at line 12646 of file io.c.

## ◆ ARGF_FORWARD

#define ARGF_FORWARD | ( |  | argc,
|  |  | argv
| ) |  |

Value:
do {\
if (ARGF_GENERIC_INPUT_P())\
return argf_forward((argc), (argv), argf);\
} while (0)
ARGF_GENERIC_INPUT_P
#define ARGF_GENERIC_INPUT_P()
Definition: io.c:8782

Definition at line 8784 of file io.c.

## ◆ ARGF_GENERIC_INPUT_P

#define ARGF_GENERIC_INPUT_P | ( |  | ) | (ARGF.current_file == rb_stdin && !RB_TYPE_P(ARGF.current_file, T_FILE))

Definition at line 8782 of file io.c.

## ◆ argf_of

#define argf_of | ( |  | obj | ) | (*(struct argf *)DATA_PTR(obj))

Definition at line 482 of file io.c.

## ◆ DEFAULT_TEXTMODE

#define DEFAULT_TEXTMODE 0

Definition at line 710 of file io.c.

## ◆ DEFULT_IOCTL_NARG_LEN

#define DEFULT_IOCTL_NARG_LEN (256)

Definition at line 9810 of file io.c.

## ◆ do_write_retry

#define do_write_retry | ( |  | code | ) | ret = code

Definition at line 1097 of file io.c.

## ◆ EWOULDBLOCK

#define EWOULDBLOCK EAGAIN

Definition at line 162 of file io.c.

## ◆ fmode

#define fmode (fptr->mode)

## ◆ FMODE_PREP

#define FMODE_PREP (1<<16)

Definition at line 527 of file io.c.

## ◆ FMODE_SIGNAL_ON_EPIPE

#define FMODE_SIGNAL_ON_EPIPE (1<<17)

Definition at line 528 of file io.c.

## ◆ FOREACH_ARGF

#define FOREACH_ARGF | ( |  | ) | while (next_argv())

Definition at line 12633 of file io.c.

## ◆ fptr_set_signal_on_epipe

#define fptr_set_signal_on_epipe | ( |  | fptr,
|  |  | flag
| ) |  |

Value:
((flag) ? \
(fptr)->mode |= FMODE_SIGNAL_ON_EPIPE : \
(fptr)->mode &= ~FMODE_SIGNAL_ON_EPIPE)
FMODE_SIGNAL_ON_EPIPE
#define FMODE_SIGNAL_ON_EPIPE
Definition: io.c:528
mode
const char int mode
Definition: ioapi.h:137

Definition at line 533 of file io.c.

## ◆ fptr_signal_on_epipe

#define fptr_signal_on_epipe | ( |  | fptr | ) | (((fptr)->mode & FMODE_SIGNAL_ON_EPIPE) != 0)

Definition at line 530 of file io.c.

## ◆ free

#define free | ( |  | x | ) | xfree(x)

Definition at line 42 of file io.c.

## ◆ GetWriteIO

#define GetWriteIO | ( |  | io | ) | rb_io_get_write_io(io)

Definition at line 485 of file io.c.

## ◆ IO_CBUF_CAPA_MIN

#define IO_CBUF_CAPA_MIN (128*1024)

Definition at line 171 of file io.c.

## ◆ IO_RBUF_CAPA_FOR

#define IO_RBUF_CAPA_FOR | ( |  | fptr | ) | (NEED_READCONV(fptr) ? IO_CBUF_CAPA_MIN : IO_RBUF_CAPA_MIN)

Definition at line 172 of file io.c.

## ◆ IO_RBUF_CAPA_MIN

#define IO_RBUF_CAPA_MIN 8192

Definition at line 170 of file io.c.

## ◆ io_seek

#define io_seek | ( |  | fptr,
|  |  | ofs,
|  |  | whence
| ) |  | (errno = 0, lseek(flush_before_seek(fptr)->fd, (ofs), (whence)))

Definition at line 918 of file io.c.

## ◆ io_tell

#define io_tell | ( |  | fptr | ) | lseek(flush_before_seek(fptr)->fd, 0, SEEK_CUR)

Definition at line 919 of file io.c.

## ◆ IO_WBUF_CAPA_MIN

#define IO_WBUF_CAPA_MIN 8192

Definition at line 173 of file io.c.

## ◆ IOWAIT_SYSCALL

#define IOWAIT_SYSCALL "select"

Definition at line 11054 of file io.c.

## ◆ IS_PREP_STDIO

#define IS_PREP_STDIO | ( |  | f | ) | ((f)->mode & FMODE_PREP)

Definition at line 4598 of file io.c.

## ◆ is_socket

#define is_socket | ( |  | fd,
|  |  | path
| ) |  | 0

Definition at line 730 of file io.c.

## ◆ KEEPGVL

#define KEEPGVL FALSE

Definition at line 4890 of file io.c.

## ◆ MAX_REALLOC_GAP

#define MAX_REALLOC_GAP 4096

Definition at line 2854 of file io.c.

## ◆ MODE_BINARY

#define MODE_BINARY | ( |  | a,
|  |  | b
| ) |  | (a)

## ◆ MODE_BTMODE

#define MODE_BTMODE | ( |  | a,
|  |  | b,
|  |  | c
| ) |  |

Value:
((fmode & FMODE_BINMODE) ? (b) : \
(fmode & FMODE_TEXTMODE) ? (c) : (a))
FMODE_BINMODE
#define FMODE_BINMODE
Definition: io.h:108
FMODE_TEXTMODE
#define FMODE_TEXTMODE
Definition: io.h:117
fmode
#define fmode

Definition at line 1608 of file io.c.

## ◆ MODE_BTXMODE

#define MODE_BTXMODE | ( |  | a,
|  |  | b,
|  |  | c,
|  |  | d,
|  |  | e,
|  |  | f
| ) |  |

Value:
((fmode & FMODE_EXCL) ? \
MODE_BTMODE(d, e, f) : \
MODE_BTMODE(a, b, c))
FMODE_EXCL
#define FMODE_EXCL
Definition: io.h:115
MODE_BTMODE
#define MODE_BTMODE(a, b, c)
Definition: io.c:1608
f
#define f

Definition at line 1611 of file io.c.

## ◆ MORE_CHAR_FINISHED

#define MORE_CHAR_FINISHED Qnil

Definition at line 2720 of file io.c.

## ◆ MORE_CHAR_SUSPENDED

#define MORE_CHAR_SUSPENDED Qtrue

Definition at line 2719 of file io.c.

## ◆ NEED_NEWLINE_DECORATOR_ON_READ

#define NEED_NEWLINE_DECORATOR_ON_READ | ( |  | fptr | ) | ((fptr)->mode & FMODE_TEXTMODE)

Definition at line 563 of file io.c.

## ◆ NEED_NEWLINE_DECORATOR_ON_READ_CHECK

#define NEED_NEWLINE_DECORATOR_ON_READ_CHECK | ( |  | fptr | ) | (void)(fptr)

Definition at line 718 of file io.c.

## ◆ NEED_NEWLINE_DECORATOR_ON_WRITE

#define NEED_NEWLINE_DECORATOR_ON_WRITE | ( |  | fptr | ) | ((fptr)->mode & FMODE_TEXTMODE)

Definition at line 564 of file io.c.

## ◆ NEED_READCONV

#define NEED_READCONV | ( |  | fptr | ) | ((fptr)->encs.enc2 != NULL || NEED_NEWLINE_DECORATOR_ON_READ(fptr))

Definition at line 711 of file io.c.

## ◆ NEED_WRITECONV

#define NEED_WRITECONV | ( |  | fptr | ) |

Value:
( \
((fptr)->encs.enc != NULL && (fptr)->encs.enc != rb_ascii8bit_encoding()) || \
NEED_NEWLINE_DECORATOR_ON_WRITE(fptr) || \
((fptr)->encs.ecflags & (ECONV_DECORATOR_MASK|ECONV_STATEFUL_DECORATOR_MASK)) || \
0)
rb_ascii8bit_encoding
rb_encoding * rb_ascii8bit_encoding(void)
Definition: encoding.c:1525
ECONV_STATEFUL_DECORATOR_MASK
#define ECONV_STATEFUL_DECORATOR_MASK
Definition: encoding.h:398
ECONV_DECORATOR_MASK
#define ECONV_DECORATOR_MASK
Definition: encoding.h:389
NEED_NEWLINE_DECORATOR_ON_WRITE
#define NEED_NEWLINE_DECORATOR_ON_WRITE(fptr)
Definition: io.c:564
NULL
#define NULL
Definition: regenc.h:69

Definition at line 712 of file io.c.

## ◆ NEXT_ARGF_FORWARD

#define NEXT_ARGF_FORWARD | ( |  | argc,
|  |  | argv
| ) |  |

Value:
do {\
if (!next_argv()) return Qnil;\
ARGF_FORWARD((argc), (argv));\
} while (0)
next_argv
#define next_argv()
Definition: io.c:8781
ARGF_FORWARD
#define ARGF_FORWARD(argc, argv)
Definition: io.c:8784
Qnil
#define Qnil
Definition: special_consts.h:51

Definition at line 8788 of file io.c.

## ◆ next_argv

#define next_argv | ( |  | ) | argf_next_argv(argf)

Definition at line 8781 of file io.c.

## ◆ no_exception_p

#define no_exception_p | ( |  | opts | ) | !rb_opts_exception_p((opts), TRUE)

Definition at line 2963 of file io.c.

## ◆ NOFILE

#define NOFILE 64

Definition at line 92 of file io.c.

## ◆ NUM2IOCTLREQ

#define NUM2IOCTLREQ | ( |  | num | ) | ((int)NUM2LONG(num))

Definition at line 9776 of file io.c.

## ◆ O_ACCMODE

#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)

Definition at line 146 of file io.c.

## ◆ off_t

#define off_t long

Definition at line 78 of file io.c.

## ◆ PIPE_BUF

#define PIPE_BUF 512 /* is this ok? */

Definition at line 157 of file io.c.

## ◆ PREP_STDIO_NAME

#define PREP_STDIO_NAME | ( |  | f | ) | (RSTRING_PTR((f)->pathv))

Definition at line 4599 of file io.c.

## ◆ rb_f_syscall

#define rb_f_syscall rb_f_notimplement

Definition at line 10310 of file io.c.

## ◆ rb_io_close_on_exec_p

#define rb_io_close_on_exec_p rb_f_notimplement

Definition at line 4537 of file io.c.

## ◆ rb_io_fcntl

#define rb_io_fcntl rb_f_notimplement

Definition at line 10179 of file io.c.

## ◆ rb_io_fdatasync

#define rb_io_fdatasync rb_io_fsync

Definition at line 2453 of file io.c.

## ◆ rb_io_fptr_finalize

#define rb_io_fptr_finalize | ( |  | fptr | ) | rb_io_fptr_finalize_internal(fptr)

Definition at line 4872 of file io.c.

## ◆ rb_io_fsync

#define rb_io_fsync rb_f_notimplement

Definition at line 2401 of file io.c.

## ◆ rb_io_ioctl

#define rb_io_ioctl rb_f_notimplement

Definition at line 10085 of file io.c.

## ◆ rb_io_pread

#define rb_io_pread rb_f_notimplement

Definition at line 5385 of file io.c.

## ◆ rb_io_pwrite

#define rb_io_pwrite rb_f_notimplement

Definition at line 5445 of file io.c.

## ◆ rb_io_set_close_on_exec

#define rb_io_set_close_on_exec rb_f_notimplement

Definition at line 4595 of file io.c.

## ◆ rb_io_sync

#define rb_io_sync rb_f_notimplement

Definition at line 2402 of file io.c.

## ◆ rb_sys_fail_on_write

#define rb_sys_fail_on_write | ( |  | fptr | ) |

Value:
do { \
int e = errno; \
raise_on_write(fptr, e, rb_syserr_new_path(e, (fptr)->pathv)); \
} while (0)
rb_syserr_new_path
#define rb_syserr_new_path(err, path)
Definition: error.h:39

Definition at line 557 of file io.c.

## ◆ READ_CHAR_PENDING

#define READ_CHAR_PENDING | ( |  | fptr | ) | ((fptr)->cbuf.len)

Definition at line 492 of file io.c.

## ◆ READ_CHAR_PENDING_COUNT

#define READ_CHAR_PENDING_COUNT | ( |  | fptr | ) | ((fptr)->cbuf.len)

Definition at line 493 of file io.c.

## ◆ READ_CHAR_PENDING_PTR

#define READ_CHAR_PENDING_PTR | ( |  | fptr | ) | ((fptr)->cbuf.ptr+(fptr)->cbuf.off)

Definition at line 494 of file io.c.

## ◆ READ_CHECK

#define READ_CHECK | ( |  | fptr | ) |

Value:
do {\
if (!READ_DATA_PENDING(fptr)) {\
WAIT_FD_IN_WIN32(fptr);\
rb_io_check_closed(fptr);\
}\
} while(0)
READ_DATA_PENDING
#define READ_DATA_PENDING(fptr)
Definition: io.c:487

Definition at line 503 of file io.c.

## ◆ READ_DATA_BUFFERED

#define READ_DATA_BUFFERED | ( |  | fptr | ) | READ_DATA_PENDING(fptr)

Definition at line 490 of file io.c.

## ◆ READ_DATA_PENDING

#define READ_DATA_PENDING | ( |  | fptr | ) | ((fptr)->rbuf.len)

Definition at line 487 of file io.c.

## ◆ READ_DATA_PENDING_COUNT

#define READ_DATA_PENDING_COUNT | ( |  | fptr | ) | ((fptr)->rbuf.len)

Definition at line 488 of file io.c.

## ◆ READ_DATA_PENDING_PTR

#define READ_DATA_PENDING_PTR | ( |  | fptr | ) | ((fptr)->rbuf.ptr+(fptr)->rbuf.off)

Definition at line 489 of file io.c.

## ◆ S_ISREG

#define S_ISREG | ( |  | m | ) | (((m) & S_IFMT) == S_IFREG)

Definition at line 1049 of file io.c.

## ◆ SEEK_CUR

#define SEEK_CUR 1

Definition at line 923 of file io.c.

## ◆ SEEK_END

#define SEEK_END 2

Definition at line 924 of file io.c.

## ◆ SEEK_SET

#define SEEK_SET 0

Definition at line 922 of file io.c.

## ◆ SET_BINARY_MODE

#define SET_BINARY_MODE | ( |  | fptr | ) | (void)(fptr)

Definition at line 717 of file io.c.

## ◆ SET_BINARY_MODE_WITH_SEEK_CUR

#define SET_BINARY_MODE_WITH_SEEK_CUR | ( |  | fptr | ) | (void)(fptr)

Definition at line 720 of file io.c.

## ◆ SET_UNIVERSAL_NEWLINE_DECORATOR_IF_ENC2

#define SET_UNIVERSAL_NEWLINE_DECORATOR_IF_ENC2 | ( |  | enc2,
|  |  | ecflags
| ) |  | ((void)(enc2), (void)(ecflags))

Definition at line 719 of file io.c.

## ◆ SHUT_RD

#define SHUT_RD 0

## ◆ SHUT_WR

#define SHUT_WR 1

## ◆ shutdown

#define shutdown | ( |  | a,
|  |  | b
| ) |  | 0

Definition at line 724 of file io.c.

## ◆ USE_POLL

#define USE_POLL 0

Definition at line 38 of file io.c.

## ◆ WAIT_FD_IN_WIN32

#define WAIT_FD_IN_WIN32 | ( |  | fptr | ) |

Definition at line 500 of file io.c.

## Typedef Documentation

## ◆ convconfig_t

typedef struct rb_io_enc_t convconfig_t

Definition at line 5930 of file io.c.

## ◆ ioctl_req_t

typedef int ioctl_req_t

Definition at line 9775 of file io.c.

## Enumeration Type Documentation

## ◆ anonymous enum

anonymous enum

Enumerator
bom_prefix_len |

Definition at line 5570 of file io.c.

## ◆ anonymous enum

anonymous enum

Enumerator
utf_prefix_len |

Definition at line 5571 of file io.c.

## Function Documentation

## ◆ Init_IO()

void Init_IO | ( | void |  | ) |

Definition at line 13335 of file io.c.

References ARGF, ID2SYM, Init_File(), INT2FIX, INT2NUM, NULL, O_BINARY, Qnil, rb_cFile, rb_cIO, rb_class_new(), rb_class_new_instance(), rb_cObject, rb_default_rs, rb_define_alias(), rb_define_alloc_func(), rb_define_class(), rb_define_class_under(), rb_define_const(), rb_define_global_const(), rb_define_global_function, ruby::backward::cxxanyargs::rb_define_hooked_variable(), rb_define_method, rb_define_module_under(), rb_define_readonly_variable(), rb_define_singleton_method, ruby::backward::cxxanyargs::rb_define_virtual_variable(), rb_eEAGAIN, rb_eEINPROGRESS, rb_eEOFError, rb_eEWOULDBLOCK, rb_eIOError, rb_eStandardError, rb_f_syscall, rb_fstring_lit, rb_gc_register_mark_object(), rb_gvar_ractor_local(), rb_gvar_readonly_setter, rb_id_encoding(), rb_include_module(), rb_io_addstr(), rb_io_close_on_exec_p, rb_io_eof(), rb_io_fcntl, rb_io_fdatasync, rb_io_flush(), rb_io_fsync, rb_io_getbyte(), rb_io_ioctl, rb_io_pread, rb_io_prep_stderr(), rb_io_prep_stdin(), rb_io_prep_stdout(), rb_io_print(), rb_io_printf(), rb_io_puts(), rb_io_pwrite, rb_io_set_close_on_exec, rb_io_sync, rb_io_ungetbyte(), rb_io_ungetc(), rb_mEnumerable, rb_mKernel, rb_mWaitReadable, rb_mWaitWritable, rb_output_fs, rb_output_rs, rb_rs, rb_set_class_path(), rb_stderr, rb_stdin, rb_stdout, rb_str_new2, RUBY_IO_PRIORITY, RUBY_IO_READABLE, RUBY_IO_WRITABLE, SEEK_CUR, SEEK_END, and SEEK_SET.

## ◆ rb_cloexec_dup()

int rb_cloexec_dup | ( | int | oldfd | ) |

Definition at line 346 of file io.c.

References rb_cloexec_fcntl_dupfd().

## ◆ rb_cloexec_dup2()

int rb_cloexec_dup2 | ( | int | oldfd,
|  | int | newfd
| ) |  |

Definition at line 353 of file io.c.

References dup2(), O_CLOEXEC, and rb_maygvl_fd_fix_cloexec().

## ◆ rb_cloexec_fcntl_dupfd()

int rb_cloexec_fcntl_dupfd | ( | int | fd,
|  | int | minfd
| ) |  |

Definition at line 440 of file io.c.

References F_DUPFD, F_DUPFD_CLOEXEC, fcntl(), rb_cloexec_fcntl_dupfd(), and rb_maygvl_fd_fix_cloexec().

Referenced by rb_cloexec_dup(), and rb_cloexec_fcntl_dupfd().

## ◆ rb_cloexec_open()

int rb_cloexec_open | ( | const char * | pathname,
|  | int | flags,
|  | mode_t | mode
| ) |  |

Definition at line 307 of file io.c.

References EWOULDBLOCK, O_CLOEXEC, and rb_maygvl_fd_fix_cloexec().

Referenced by rb_file_load_ok().

## ◆ rb_cloexec_pipe()

int rb_cloexec_pipe | ( | int | descriptors[2] | ) |

Definition at line 406 of file io.c.

References O_CLOEXEC, O_NONBLOCK, and rb_maygvl_fd_fix_cloexec().

Referenced by rb_pipe().

## ◆ rb_eof_error()

void rb_eof_error | ( | void |  | ) |

Definition at line 754 of file io.c.

References rb_eEOFError, and rb_raise().

## ◆ rb_execarg_commandline()

char * rb_execarg_commandline | ( | const struct rb_execarg * | eargp,
|  | VALUE * | prog
| ) |  |

Definition at line 4548 of file process.c.

References argc, argv, rb_execarg::argv_buf, rb_execarg::argv_str, rb_execarg::cmd, rb_execarg::invoke, prog, rb_str_new, RSTRING_LEN, RSTRING_PTR, str, StringValueCStr, and rb_execarg::use_shell.

## ◆ rb_fd_fix_cloexec()

void rb_fd_fix_cloexec | ( | int | fd | ) |

Definition at line 283 of file io.c.

References rb_maygvl_fd_fix_cloexec(), and rb_update_max_fd().

## ◆ rb_fdopen()

FILE * rb_fdopen | ( | int | fd,
|  | const char * | modestr
| ) |  |

Definition at line 6183 of file io.c.

References fdopen, NULL, rb_gc(), rb_gc_for_fd(), rb_syserr_fail(), and rb_warn().

Referenced by rb_io_stdio_file().

## ◆ rb_file_open()

VALUE rb_file_open | ( | const char * | fname,
|  | const char * | modestr
| ) |  |

Definition at line 6389 of file io.c.

References sysopen_struct::fname, rb_cFile, and rb_str_new_cstr.

## ◆ rb_file_open_str()

VALUE rb_file_open_str | ( | VALUE | fname,
|  | const char * | modestr
| ) |  |

Definition at line 6382 of file io.c.

References FilePathValue, sysopen_struct::fname, and rb_cFile.

## ◆ rb_gc_for_fd()

int rb_gc_for_fd | ( | int | err | ) |

Definition at line 1010 of file io.c.

References err, and rb_gc().

Referenced by rb_fdopen(), rb_pipe(), and rsock_socket().

## ◆ rb_get_argv()

VALUE rb_get_argv | ( | void |  | ) |

Definition at line 13082 of file io.c.

References ARGF.

## ◆ rb_gets()

VALUE rb_gets | ( | void |  | ) |

Definition at line 9104 of file io.c.

References ARGF, next_argv, NIL_P, Qnil, rb_default_rs, rb_io_close(), rb_io_gets(), rb_lastline_set(), and rb_rs.

## ◆ rb_io_addstr()

VALUE rb_io_addstr | ( | VALUE | io,
|  | VALUE | str
| ) |  |

Definition at line 1992 of file io.c.

References rb_io_write(), and str.

Referenced by Init_IO().

## ◆ rb_io_ascii8bit_binmode()

VALUE rb_io_ascii8bit_binmode | ( | VALUE | io | ) |

Definition at line 5495 of file io.c.

References GetOpenFile.

Referenced by rsock_init_sock().

## ◆ rb_io_binmode()

VALUE rb_io_binmode | ( | VALUE | io | ) |

Definition at line 5449 of file io.c.

References rb_io_t::fd, FMODE_BINMODE, GetOpenFile, rb_io_t::mode, O_BINARY, rb_econv_binmode(), rb_io_t::readconv, SET_BINARY_MODE_WITH_SEEK_CUR, rb_io_t::writeconv, and rb_io_t::writeconv_pre_ecflags.

## ◆ rb_io_bufwrite()

ssize_t rb_io_bufwrite | ( | VALUE | io,
|  | const void * | buf,
|  | size_t | size
| ) |  |

Definition at line 1698 of file io.c.

References binwrite_arg::fptr, GetOpenFile, and rb_io_check_writable().

## ◆ rb_io_check_byte_readable()

void rb_io_check_byte_readable | ( | rb_io_t * | fptr | ) |

Definition at line 947 of file io.c.

References rb_eIOError, rb_io_check_char_readable(), rb_raise(), and READ_CHAR_PENDING.

Referenced by rb_io_check_readable(), rb_io_getbyte(), and rb_io_ungetbyte().

## ◆ rb_io_check_char_readable()

void rb_io_check_char_readable | ( | rb_io_t * | fptr | ) |

Definition at line 928 of file io.c.

References FMODE_READABLE, GetOpenFile, rb_io_t::mode, rb_eIOError, rb_io_check_closed(), rb_raise(), rb_sys_fail_on_write, rb_io_t::tied_io_for_writing, and rb_io_t::wbuf.

Referenced by rb_io_check_byte_readable(), rb_io_eof(), and rb_io_ungetc().

## ◆ rb_io_check_closed()

void rb_io_check_closed | ( | rb_io_t * | fptr | ) |

Definition at line 775 of file io.c.

References rb_io_t::fd, and rb_io_check_initialized().

Referenced by rb_io_check_char_readable(), rb_io_check_writable(), rb_io_wait(), rsock_s_recvfrom(), and rsock_s_recvfrom_nonblock().

## ◆ rb_io_check_initialized()

void rb_io_check_initialized | ( | rb_io_t * | fptr | ) |

Definition at line 767 of file io.c.

References rb_eIOError, and rb_raise().

Referenced by rb_io_check_closed(), and rb_io_synchronized().

## ◆ rb_io_check_io()

VALUE rb_io_check_io | ( | VALUE | io | ) |

Definition at line 796 of file io.c.

References rb_check_convert_type_with_id(), and T_FILE.

## ◆ rb_io_check_readable()

void rb_io_check_readable | ( | rb_io_t * | fptr | ) |

Definition at line 956 of file io.c.

References rb_io_check_byte_readable().

## ◆ rb_io_check_writable()

void rb_io_check_writable | ( | rb_io_t * | fptr | ) |

Definition at line 980 of file io.c.

References FMODE_WRITABLE, rb_io_t::mode, rb_eIOError, rb_io_check_closed(), rb_raise(), and rb_io_t::rbuf.

Referenced by rb_io_bufwrite().

## ◆ rb_io_close()

VALUE rb_io_close | ( | VALUE | io | ) |

Definition at line 4935 of file io.c.

References Qnil.

Referenced by rb_gets(), and rb_io_make_open_file().

## ◆ rb_io_eof()

VALUE rb_io_eof | ( | VALUE | io | ) |

Definition at line 2298 of file io.c.

References rb_io_t::fd, GetOpenFile, NEED_NEWLINE_DECORATOR_ON_READ, NEED_READCONV, Qfalse, Qtrue, rb_io_check_char_readable(), READ_CHAR_PENDING, READ_CHECK, and READ_DATA_PENDING.

Referenced by Init_IO().

## ◆ rb_io_extract_encoding_option()

int rb_io_extract_encoding_option | ( | VALUE | opt,
|  | rb_encoding ** | enc_p,
|  | rb_encoding ** | enc2_p,
|  | int * | fmode_p
| ) |  |

Definition at line 5862 of file io.c.

References NIL_P, NULL, PRIsVALUE, Qnil, Qundef, rb_check_string_type(), rb_enc_from_encoding(), rb_enc_from_index(), rb_enc_get(), rb_hash_lookup2(), rb_to_encoding(), rb_to_encoding_index(), rb_warn(), ruby_verbose, and StringValueCStr.

Referenced by rb_io_extract_modeenc().

## ◆ rb_io_extract_modeenc()

void rb_io_extract_modeenc | ( | VALUE * | vmode_p,
|  | VALUE * | vperm_p,
|  | VALUE | opthash,
|  | int * | oflags_p,
|  | int * | fmode_p,
|  | convconfig_t * | convconfig_p
| ) |  |

Definition at line 5989 of file io.c.

References DEFAULT_TEXTMODE, ECONV_DEFAULT_NEWLINE_DECORATOR, ECONV_UNIVERSAL_NEWLINE_DECORATOR, fmode, FMODE_BINMODE, FMODE_READABLE, FMODE_WRITABLE, INT2NUM, MODE_BTMODE, NIL_P, NULL, NUM2INT, O_BINARY, Qnil, rb_ascii8bit_encoding(), rb_check_to_integer(), rb_eArgError, rb_econv_prepare_options(), rb_enc_get(), rb_hash_aref(), rb_io_extract_encoding_option(), rb_io_modestr_fmode(), rb_io_oflags_fmode(), rb_raise(), rb_to_int(), SafeStringValue, SET_UNIVERSAL_NEWLINE_DECORATOR_IF_ENC2, strchr(), and StringValueCStr.

## ◆ rb_io_fdopen()

VALUE rb_io_fdopen | ( | int | fd,
|  | int | oflags,
|  | const char * | path
| ) |  |

Definition at line 8183 of file io.c.

References rb_cFile, rb_cIO, and rb_io_oflags_fmode().

## ◆ rb_io_flush()

VALUE rb_io_flush | ( | VALUE | io | ) |

Definition at line 2052 of file io.c.

References rb_io_flush_raw().

Referenced by Init_IO(), and rb_io_getbyte().

## ◆ rb_io_flush_raw()

VALUE rb_io_flush_raw | ( | VALUE | io,
|  | int | sync
| ) |  |

Definition at line 2013 of file io.c.

References FMODE_READABLE, FMODE_WRITABLE, GetOpenFile, GetWriteIO, rb_io_t::mode, rb_funcall(), rb_sys_fail_on_write, and T_FILE.

Referenced by rb_io_flush().

## ◆ rb_io_fptr_finalize()

int rb_io_fptr_finalize | ( | rb_io_t * | fptr | ) |

Definition at line 4862 of file io.c.

References finish_writeconv_arg::fptr, and rb_io_fptr_finalize_internal().

## ◆ rb_io_fptr_finalize_internal()

void rb_io_fptr_finalize_internal | ( | void * | ptr | ) |

Definition at line 4845 of file io.c.

References rb_io_t::fd, finish_writeconv_arg::fptr, free, rb_io_t::pathv, ptr, Qnil, rb_io_t::rbuf, TRUE, rb_io_t::wbuf, and rb_io_t::write_lock.

Referenced by rb_io_fptr_finalize().

## ◆ rb_io_get_io()

VALUE rb_io_get_io | ( | VALUE | io | ) |

Definition at line 790 of file io.c.

References rb_convert_type_with_id(), and T_FILE.

## ◆ rb_io_get_write_io()

VALUE rb_io_get_write_io | ( | VALUE | io | ) |

Definition at line 802 of file io.c.

References rb_io_t::tied_io_for_writing.

## ◆ rb_io_getbyte()

VALUE rb_io_getbyte | ( | VALUE | io | ) |

Definition at line 4331 of file io.c.

References rb_io_t::fd, FMODE_TTY, GetOpenFile, INT2FIX, getline_arg::io, rb_io_t::mode, Qnil, rb_io_check_byte_readable(), rb_io_flush(), rb_ractor_stdout(), rb_io_t::rbuf, READ_CHECK, and T_FILE.

Referenced by Init_IO().

## ◆ rb_io_gets()

VALUE rb_io_gets | ( | VALUE | io | ) |

Definition at line 3738 of file io.c.

References FALSE, getline_arg::io, and rb_default_rs.

Referenced by rb_gets().

## ◆ rb_io_gets_internal()

VALUE rb_io_gets_internal | ( | VALUE | io | ) |

Definition at line 3744 of file io.c.

References FALSE, GetOpenFile, getline_arg::io, and rb_default_rs.

## ◆ rb_io_make_open_file()

rb_io_t * rb_io_make_open_file | ( | VALUE | obj | ) |

Definition at line 8278 of file io.c.

References rb_io_close(), rb_io_fptr_finalize, RFILE, rb_io_t::self, and T_FILE.

## ◆ rb_io_memsize()

size_t rb_io_memsize | ( | const rb_io_t * | fptr | ) |

Definition at line 4875 of file io.c.

References rb_io_t::cbuf, finish_writeconv_arg::fptr, rb_econv_memsize(), rb_io_t::rbuf, rb_io_t::readconv, rb_io_t::wbuf, and rb_io_t::writeconv.

## ◆ rb_io_modestr_fmode()

int rb_io_modestr_fmode | ( | const char * | modestr | ) |

Definition at line 5580 of file io.c.

References error(), fmode, FMODE_APPEND, FMODE_BINMODE, FMODE_CREATE, FMODE_EXCL, FMODE_READABLE, FMODE_READWRITE, FMODE_SETENC_BY_BOM, FMODE_TEXTMODE, FMODE_TRUNC, FMODE_WRITABLE, NULL, Qundef, rb_eArgError, rb_raise(), strchr(), strlen(), and UNREACHABLE_RETURN.

Referenced by rb_io_extract_modeenc(), and rb_io_modestr_oflags().

## ◆ rb_io_modestr_oflags()

int rb_io_modestr_oflags | ( | const char * | modestr | ) |

Definition at line 5713 of file io.c.

References rb_io_modestr_fmode().

## ◆ rb_io_oflags_fmode()

int rb_io_oflags_fmode | ( | int | oflags | ) |

Definition at line 5637 of file io.c.

References fmode, FMODE_APPEND, FMODE_BINMODE, FMODE_CREATE, FMODE_EXCL, FMODE_READABLE, FMODE_READWRITE, FMODE_TRUNC, FMODE_WRITABLE, O_ACCMODE, and O_BINARY.

Referenced by rb_io_extract_modeenc(), and rb_io_fdopen().

## ◆ rb_io_popen()

VALUE rb_io_popen | ( | VALUE | pname,
|  | VALUE | pmode,
|  | VALUE | env,
|  | VALUE | opt
| ) |  |

Definition at line 7040 of file io.c.

References env, FALSE, fmode, len, NIL_P, Qnil, RARRAY_CONST_PTR, RARRAY_LEN, rb_check_array_type(), rb_eArgError, rb_execarg_extract_options(), rb_execarg_new(), rb_execarg_setenv(), RB_GC_GUARD, rb_io_extract_modeenc, rb_raise(), SafeStringValue, and TRUE.

## ◆ rb_io_prep_stderr()

VALUE rb_io_prep_stderr | ( | void |  | ) |

Definition at line 8223 of file io.c.

References FMODE_SYNC, FMODE_WRITABLE, and rb_cIO.

Referenced by Init_IO().

## ◆ rb_io_prep_stdin()

VALUE rb_io_prep_stdin | ( | void |  | ) |

Definition at line 8211 of file io.c.

References FMODE_READABLE, and rb_cIO.

Referenced by Init_IO().

## ◆ rb_io_prep_stdout()

VALUE rb_io_prep_stdout | ( | void |  | ) |

Definition at line 8217 of file io.c.

References FMODE_SIGNAL_ON_EPIPE, FMODE_WRITABLE, and rb_cIO.

Referenced by Init_IO().

## ◆ rb_io_print()

VALUE rb_io_print | ( | int | argc,
|  | const VALUE * | argv,
|  | VALUE | out
| ) |  |

Definition at line 7720 of file io.c.

References argc, argv, NIL_P, out, Qnil, rb_category_warn, rb_io_write(), rb_lastline_get(), rb_output_fs, rb_output_rs, and RB_WARN_CATEGORY_DEPRECATED.

Referenced by Init_IO().

## ◆ rb_io_printf()

VALUE rb_io_printf | ( | int | argc,
|  | const VALUE * | argv,
|  | VALUE | out
| ) |  |

Definition at line 7649 of file io.c.

References argc, argv, out, Qnil, rb_f_sprintf(), and rb_io_write().

Referenced by Init_IO().

## ◆ rb_io_puts()

VALUE rb_io_puts | ( | int | argc,
|  | const VALUE * | argv,
|  | VALUE | out
| ) |  |

Definition at line 7895 of file io.c.

References argc, argv, out, Qnil, rb_default_rs, rb_exec_recursive(), rb_io_write(), rb_obj_as_string(), rb_str_end_with_asciichar(), RSTRING_LEN, and T_STRING.

Referenced by Init_IO(), and rb_f_abort().

## ◆ rb_io_read_check()

void rb_io_read_check | ( | rb_io_t * | fptr | ) |

Definition at line 1001 of file io.c.

References rb_io_t::fd, rb_thread_wait_fd(), and READ_DATA_PENDING.

## ◆ rb_io_read_pending()

int rb_io_read_pending | ( | rb_io_t * | fptr | ) |

Definition at line 992 of file io.c.

References READ_CHAR_PENDING, and READ_DATA_PENDING.

Referenced by rsock_s_recvfrom(), and rsock_s_recvfrom_nonblock().

## ◆ rb_io_set_nonblock()

void rb_io_set_nonblock | ( | rb_io_t * | fptr | ) |

Definition at line 2942 of file io.c.

References rb_io_t::fd, rb_io_t::pathv, and rb_sys_fail_path.

Referenced by rsock_s_accept_nonblock(), and rsock_s_recvfrom_nonblock().

## ◆ rb_io_set_write_io()

VALUE rb_io_set_write_io | ( | VALUE | io,
|  | VALUE | w
| ) |  |

Definition at line 813 of file io.c.

References GetWriteIO, Qnil, RTEST, and rb_io_t::tied_io_for_writing.

## ◆ rb_io_stdio_file()

FILE * rb_io_stdio_file | ( | rb_io_t * | fptr | ) |

Definition at line 8229 of file io.c.

References rb_io_t::fd, rb_io_t::mode, rb_fdopen(), and rb_io_t::stdio_file.

## ◆ rb_io_synchronized()

void rb_io_synchronized | ( | rb_io_t * | fptr | ) |

Definition at line 6486 of file io.c.

References FMODE_SYNC, rb_io_t::mode, and rb_io_check_initialized().

Referenced by rb_io_unbuffered(), and rsock_init_sock().

## ◆ rb_io_taint_check()

VALUE rb_io_taint_check | ( | VALUE | io | ) |

Definition at line 760 of file io.c.

References rb_check_frozen.

## ◆ rb_io_unbuffered()

void rb_io_unbuffered | ( | rb_io_t * | fptr | ) |

Definition at line 6493 of file io.c.

References rb_io_synchronized().

## ◆ rb_io_ungetbyte()

VALUE rb_io_ungetbyte | ( | VALUE | io,
|  | VALUE | b
| ) |  |

Definition at line 4393 of file io.c.

References GetOpenFile, INT2FIX, getline_arg::io, NUM2INT, Qnil, rb_int_modulo(), rb_io_check_byte_readable(), rb_str_new, SafeStringValue, T_BIGNUM, T_FIXNUM, T_NIL, and TYPE.

Referenced by Init_IO().

## ◆ rb_io_ungetc()

VALUE rb_io_ungetc | ( | VALUE | io,
|  | VALUE | c
| ) |  |

Definition at line 4432 of file io.c.

References rb_io_t::cbuf, FIX2UINT, FIXNUM_P, GetOpenFile, int(), getline_arg::io, len, MEMMOVE, NEED_NEWLINE_DECORATOR_ON_READ_CHECK, NEED_READCONV, NUM2UINT, Qnil, rb_eIOError, rb_enc_uint_chr(), rb_io_check_char_readable(), rb_raise(), RSTRING_LEN, RSTRING_PTR, SafeStringValue, SET_BINARY_MODE, and T_BIGNUM.

Referenced by Init_IO().

## ◆ rb_io_wait()

VALUE rb_io_wait | ( | VALUE | io,
|  | VALUE | events,
|  | VALUE | timeout
| ) |  |

Definition at line 1265 of file io.c.

References rb_io_t::fd, NULL, Qfalse, Qnil, RB_INT2NUM, rb_io_check_closed(), RB_IO_POINTER, RB_NUM2INT, rb_scheduler_current(), rb_scheduler_io_wait(), rb_sys_fail(), rb_thread_wait_for_single_fd(), and rb_time_interval().

## ◆ rb_io_wait_readable()

int rb_io_wait_readable | ( | int | f | ) |

Definition at line 1307 of file io.c.

References EWOULDBLOCK, f, FALSE, Qnil, rb_scheduler_current(), rb_scheduler_io_wait_readable(), rb_thread_check_ints(), rb_thread_wait_fd(), RTEST, and TRUE.

Referenced by rsock_s_accept(), and rsock_s_recvfrom().

## ◆ rb_io_wait_writable()

int rb_io_wait_writable | ( | int | f | ) |

Definition at line 1341 of file io.c.

References EWOULDBLOCK, f, FALSE, Qnil, rb_scheduler_current(), rb_scheduler_io_wait_writable(), rb_thread_check_ints(), rb_thread_fd_writable(), RTEST, and TRUE.

Referenced by rsock_bsock_send().

## ◆ rb_io_write()

VALUE rb_io_write | ( | VALUE | io,
|  | VALUE | str
| ) |  |

Definition at line 1953 of file io.c.

References rb_funcallv, and str.

Referenced by rb_io_addstr(), rb_io_print(), rb_io_printf(), rb_io_puts(), rb_parser_printf(), rb_write_error2(), and rb_write_error_str().

## ◆ rb_maygvl_fd_fix_cloexec()

void rb_maygvl_fd_fix_cloexec | ( | int | fd | ) |

Definition at line 260 of file io.c.

References F_GETFD, F_SETFD, fcntl(), FD_CLOEXEC, rb_bug(), and strerror().

Referenced by rb_cloexec_dup2(), rb_cloexec_fcntl_dupfd(), rb_cloexec_open(), rb_cloexec_pipe(), and rb_fd_fix_cloexec().

## ◆ rb_notify_fd_close()

int rb_notify_fd_close | ( | int | fd,
|  | struct list_head * | busy
| ) |  |

Definition at line 2607 of file thread.c.

References err, waiting_fd::fd, rb_threadptr_interrupt(), rb_threadptr_pending_interrupt_enque(), RB_VM_LOCK_ENTER, RB_VM_LOCK_LEAVE, ruby_error_stream_closed, rb_vm_struct::special_exceptions, waiting_fd::th, rb_thread_struct::vm, rb_vm_struct::waiting_fds, and waiting_fd::wfd_node.

Referenced by rb_thread_fd_close().

## ◆ rb_p()

void rb_p | ( | VALUE | obj | ) |

Definition at line 7964 of file io.c.

References rb_inspect(), and rb_obj_as_string().

## ◆ rb_pipe()

int rb_pipe | ( | int * | pipes | ) |

Definition at line 6499 of file io.c.

References rb_cloexec_pipe(), rb_gc_for_fd(), and rb_update_max_fd().

## ◆ rb_readwrite_sys_fail()

void rb_readwrite_sys_fail | ( | enum rb_io_wait_readwrite | waiting,
|  | const char * | mesg
| ) |  |

Definition at line 13116 of file io.c.

References rb_readwrite_syserr_fail().

## ◆ rb_readwrite_syserr_fail()

void rb_readwrite_syserr_fail | ( | enum rb_io_wait_readwrite | waiting,
|  | int | n,
|  | const char * | mesg
| ) |  |

Definition at line 13122 of file io.c.

References EINPROGRESS, EWOULDBLOCK, Qnil, rb_bug(), rb_class_new_instance(), rb_exc_raise(), RB_IO_WAIT_READABLE, RB_IO_WAIT_WRITABLE, rb_mod_syserr_fail_str(), rb_mWaitReadable, rb_mWaitWritable, and rb_str_new2.

Referenced by rb_readwrite_sys_fail(), rsock_s_accept_nonblock(), and rsock_s_recvfrom_nonblock().

## ◆ rb_stderr_tty_p()

int rb_stderr_tty_p | ( | void |  | ) |

Definition at line 8105 of file io.c.

References fileno.

Referenced by rb_error_write().

## ◆ rb_stdio_set_default_encoding()

void rb_stdio_set_default_encoding | ( | void |  | ) |

Definition at line 12002 of file io.c.

References Qnil, rb_stderr, rb_stdin, and rb_stdout.

## ◆ rb_update_max_fd()

void rb_update_max_fd | ( | int | fd | ) |

Definition at line 233 of file io.c.

References ATOMIC_CAS, err, fcntl(), fstat, rb_bug(), and stat.

Referenced by rb_fd_fix_cloexec(), rb_file_load_ok(), rb_pipe(), rsock_init_sock(), rsock_s_accept(), rsock_s_accept_nonblock(), and rsock_socket().

## ◆ rb_wait_for_single_fd()

int rb_wait_for_single_fd | ( | int | fd,
|  | int | events,
|  | struct timeval * | timeout
| ) |  |

Definition at line 1384 of file io.c.

References Qnil, RB_INT2NUM, rb_scheduler_current(), rb_scheduler_io_wait(), rb_scheduler_timeout(), rb_thread_wait_for_single_fd(), and RTEST.

## ◆ rb_write_error()

void rb_write_error | ( | const char * | mesg | ) |

Definition at line 8077 of file io.c.

References rb_write_error2(), and strlen().

## ◆ rb_write_error2()

void rb_write_error2 | ( | const char * | mesg,
|  | long | len
| ) |  |

Definition at line 8058 of file io.c.

References fileno, len, rb_io_write(), rb_ractor_stderr(), rb_str_new, and rb_w32_write_console().

Referenced by rb_write_error().

## ◆ rb_write_error_str()

void rb_write_error_str | ( | VALUE | mesg | ) |

Definition at line 8083 of file io.c.

References fileno, len, RB_GC_GUARD, rb_io_write(), rb_ractor_stderr(), rb_w32_write_console(), RSTRING_LEN, and RSTRING_PTR.

Referenced by rb_syntax_error_append().

## ◆ ruby_set_inplace_mode()

void ruby_set_inplace_mode | ( | const char * | suffix | ) |

Definition at line 13050 of file io.c.

References ARGF, Qfalse, Qnil, rb_str_new, strlen(), and suffix.

## Variable Documentation

## ◆ rb_cIO

VALUE rb_cIO

Definition at line 183 of file io.c.

Referenced by Init_etc(), Init_File(), Init_IO(), Init_nonblock(), Init_ossl_ssl(), Init_stringio(), Init_wait(), InitVM_console(), rb_io_fdopen(), rb_io_prep_stderr(), rb_io_prep_stdin(), rb_io_prep_stdout(), and rsock_init_basicsocket().

## ◆ rb_default_rs

VALUE rb_default_rs

Definition at line 202 of file io.c.

Referenced by Init_IO(), rb_gets(), rb_io_gets(), rb_io_gets_internal(), and rb_io_puts().

## ◆ rb_eEOFError

VALUE rb_eEOFError

Definition at line 184 of file io.c.

Referenced by Init_IO(), and rb_eof_error().

## ◆ rb_eIOError

VALUE rb_eIOError

Definition at line 185 of file io.c.

Referenced by Init_IO(), Init_Thread(), rb_io_check_byte_readable(), rb_io_check_char_readable(), rb_io_check_initialized(), rb_io_check_writable(), rb_io_ungetc(), rsock_s_recvfrom(), and rsock_s_recvfrom_nonblock().

## ◆ rb_mWaitReadable

VALUE rb_mWaitReadable

Definition at line 186 of file io.c.

Referenced by Init_IO(), Init_ossl_ssl(), and rb_readwrite_syserr_fail().

## ◆ rb_mWaitWritable

VALUE rb_mWaitWritable

Definition at line 187 of file io.c.

Referenced by Init_IO(), Init_ossl_ssl(), and rb_readwrite_syserr_fail().

## ◆ rb_output_fs

VALUE rb_output_fs

Definition at line 199 of file io.c.

Referenced by Init_IO(), and rb_io_print().

## ◆ rb_output_rs

VALUE rb_output_rs

Definition at line 201 of file io.c.

Referenced by Init_IO(), and rb_io_print().

## ◆ rb_rs

VALUE rb_rs

Definition at line 200 of file io.c.

Referenced by Init_IO(), and rb_gets().

## ◆ rb_stderr

VALUE rb_stderr

Definition at line 196 of file io.c.

Referenced by Init_IO(), and rb_stdio_set_default_encoding().

## ◆ rb_stdin

VALUE rb_stdin

Definition at line 196 of file io.c.

Referenced by Init_IO(), rb_ractor_stdin(), rb_ractor_stdin_set(), and rb_stdio_set_default_encoding().

## ◆ rb_stdout

VALUE rb_stdout

Definition at line 196 of file io.c.

Referenced by Init_IO(), and rb_stdio_set_default_encoding().

## ◆ ruby_static_id_signo

ID ruby_static_id_signo
| extern

Definition at line 51 of file eval.c.