Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)
|
#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 } |
#define fmode (fptr->mode) |
#define fptr_set_signal_on_epipe | ( | fptr, | |
flag | |||
) |
#define fptr_signal_on_epipe | ( | fptr | ) | (((fptr)->mode & FMODE_SIGNAL_ON_EPIPE) != 0) |
#define GetWriteIO | ( | io | ) | rb_io_get_write_io(io) |
#define IO_RBUF_CAPA_FOR | ( | fptr | ) | (NEED_READCONV(fptr) ? IO_CBUF_CAPA_MIN : IO_RBUF_CAPA_MIN) |
#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 MODE_BINARY | ( | a, | |
b | |||
) | (a) |
#define MODE_BTMODE | ( | a, | |
b, | |||
c | |||
) |
#define MODE_BTXMODE | ( | a, | |
b, | |||
c, | |||
d, | |||
e, | |||
f | |||
) |
#define NEED_NEWLINE_DECORATOR_ON_READ | ( | fptr | ) | ((fptr)->mode & FMODE_TEXTMODE) |
#define NEED_NEWLINE_DECORATOR_ON_READ_CHECK | ( | fptr | ) | (void)(fptr) |
#define NEED_NEWLINE_DECORATOR_ON_WRITE | ( | fptr | ) | ((fptr)->mode & FMODE_TEXTMODE) |
#define NEED_READCONV | ( | fptr | ) | ((fptr)->encs.enc2 != NULL || NEED_NEWLINE_DECORATOR_ON_READ(fptr)) |
#define NEED_WRITECONV | ( | fptr | ) |
#define no_exception_p | ( | opts | ) | !rb_opts_exception_p((opts), TRUE) |
#define PREP_STDIO_NAME | ( | f | ) | (RSTRING_PTR((f)->pathv)) |
#define rb_f_syscall rb_f_notimplement |
#define rb_io_close_on_exec_p rb_f_notimplement |
#define rb_io_fcntl rb_f_notimplement |
#define rb_io_fdatasync rb_io_fsync |
#define rb_io_fptr_finalize | ( | fptr | ) | rb_io_fptr_finalize_internal(fptr) |
#define rb_io_fsync rb_f_notimplement |
#define rb_io_ioctl rb_f_notimplement |
#define rb_io_pread rb_f_notimplement |
#define rb_io_pwrite rb_f_notimplement |
#define rb_io_set_close_on_exec rb_f_notimplement |
#define rb_io_sync rb_f_notimplement |
#define rb_sys_fail_on_write | ( | fptr | ) |
#define READ_CHAR_PENDING_PTR | ( | fptr | ) | ((fptr)->cbuf.ptr+(fptr)->cbuf.off) |
#define READ_CHECK | ( | fptr | ) |
#define READ_DATA_BUFFERED | ( | fptr | ) | READ_DATA_PENDING(fptr) |
#define READ_DATA_PENDING_PTR | ( | fptr | ) | ((fptr)->rbuf.ptr+(fptr)->rbuf.off) |
#define SET_UNIVERSAL_NEWLINE_DECORATOR_IF_ENC2 | ( | enc2, | |
ecflags | |||
) | ((void)(enc2), (void)(ecflags)) |
#define SHUT_RD 0 |
#define SHUT_WR 1 |
typedef struct rb_io_enc_t convconfig_t |
typedef int ioctl_req_t |
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.
Definition at line 346 of file io.c.
References rb_cloexec_fcntl_dupfd().
Definition at line 353 of file io.c.
References dup2(), O_CLOEXEC, and rb_maygvl_fd_fix_cloexec().
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().
Definition at line 307 of file io.c.
References EWOULDBLOCK, O_CLOEXEC, and rb_maygvl_fd_fix_cloexec().
Referenced by rb_file_load_ok().
Definition at line 406 of file io.c.
References O_CLOEXEC, O_NONBLOCK, and rb_maygvl_fd_fix_cloexec().
Referenced by rb_pipe().
void rb_eof_error | ( | void | ) |
Definition at line 754 of file io.c.
References rb_eEOFError, and rb_raise().
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.
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().
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().
Definition at line 6389 of file io.c.
References sysopen_struct::fname, rb_cFile, and rb_str_new_cstr.
Definition at line 6382 of file io.c.
References FilePathValue, sysopen_struct::fname, and rb_cFile.
Definition at line 1010 of file io.c.
Referenced by rb_fdopen(), rb_pipe(), and rsock_socket().
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.
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.
Definition at line 1698 of file io.c.
References binwrite_arg::fptr, GetOpenFile, and rb_io_check_writable().
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().
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().
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().
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().
Definition at line 796 of file io.c.
References rb_check_convert_type_with_id(), and T_FILE.
void rb_io_check_readable | ( | rb_io_t * | fptr | ) |
Definition at line 956 of file io.c.
References rb_io_check_byte_readable().
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().
Definition at line 4935 of file io.c.
References Qnil.
Referenced by rb_gets(), and rb_io_make_open_file().
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().
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().
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.
Definition at line 8183 of file io.c.
References rb_cFile, rb_cIO, and rb_io_oflags_fmode().
Definition at line 2052 of file io.c.
References rb_io_flush_raw().
Referenced by Init_IO(), and rb_io_getbyte().
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().
Definition at line 4862 of file io.c.
References finish_writeconv_arg::fptr, and 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().
Definition at line 790 of file io.c.
References rb_convert_type_with_id(), and T_FILE.
Definition at line 802 of file io.c.
References rb_io_t::tied_io_for_writing.
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().
Definition at line 3738 of file io.c.
References FALSE, getline_arg::io, and rb_default_rs.
Referenced by rb_gets().
Definition at line 3744 of file io.c.
References FALSE, GetOpenFile, getline_arg::io, and rb_default_rs.
Definition at line 8278 of file io.c.
References rb_io_close(), rb_io_fptr_finalize, RFILE, rb_io_t::self, and T_FILE.
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.
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().
Definition at line 5713 of file io.c.
References rb_io_modestr_fmode().
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().
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.
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().
VALUE rb_io_prep_stdin | ( | void | ) |
Definition at line 8211 of file io.c.
References FMODE_READABLE, and rb_cIO.
Referenced by Init_IO().
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().
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().
Definition at line 7649 of file io.c.
References argc, argv, out, Qnil, rb_f_sprintf(), and rb_io_write().
Referenced by Init_IO().
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().
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.
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().
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().
Definition at line 813 of file io.c.
References GetWriteIO, Qnil, RTEST, and rb_io_t::tied_io_for_writing.
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.
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().
Definition at line 760 of file io.c.
References rb_check_frozen.
void rb_io_unbuffered | ( | rb_io_t * | fptr | ) |
Definition at line 6493 of file io.c.
References rb_io_synchronized().
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().
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().
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().
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().
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().
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().
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().
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().
void rb_p | ( | VALUE | obj | ) |
Definition at line 7964 of file io.c.
References rb_inspect(), and rb_obj_as_string().
Definition at line 6499 of file io.c.
References rb_cloexec_pipe(), rb_gc_for_fd(), and rb_update_max_fd().
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().
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().
int rb_stderr_tty_p | ( | void | ) |
void rb_stdio_set_default_encoding | ( | void | ) |
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().
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.
void rb_write_error | ( | const char * | mesg | ) |
Definition at line 8077 of file io.c.
References rb_write_error2(), and strlen().
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().
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().
void ruby_set_inplace_mode | ( | const char * | suffix | ) |
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().
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().
VALUE rb_eEOFError |
Definition at line 184 of file io.c.
Referenced by Init_IO(), and rb_eof_error().
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().
VALUE rb_mWaitReadable |
Definition at line 186 of file io.c.
Referenced by Init_IO(), Init_ossl_ssl(), and rb_readwrite_syserr_fail().
VALUE rb_mWaitWritable |
Definition at line 187 of file io.c.
Referenced by Init_IO(), Init_ossl_ssl(), and rb_readwrite_syserr_fail().
VALUE rb_output_fs |
Definition at line 199 of file io.c.
Referenced by Init_IO(), and rb_io_print().
VALUE rb_output_rs |
Definition at line 201 of file io.c.
Referenced by Init_IO(), and rb_io_print().
VALUE rb_stderr |
Definition at line 196 of file io.c.
Referenced by Init_IO(), and rb_stdio_set_default_encoding().
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().
VALUE rb_stdout |
Definition at line 196 of file io.c.
Referenced by Init_IO(), and rb_stdio_set_default_encoding().