Ruby 3.5.0dev (2025-04-24 revision bbd5d3348b519035a5d2cdf777e7c8d5c143055c)
io.h
1#ifndef INTERNAL_IO_H /*-*-C-*-vi:se ft=c:*/
2#define INTERNAL_IO_H
11#include "ruby/ruby.h" /* for VALUE */
12
13#define HAVE_RB_IO_T
14struct rb_io;
15
16#include "ruby/io.h" /* for rb_io_t */
17
18#define IO_WITHOUT_GVL(func, arg) rb_nogvl(func, arg, RUBY_UBF_IO, 0, RB_NOGVL_OFFLOAD_SAFE)
19#define IO_WITHOUT_GVL_INT(func, arg) (int)(VALUE)IO_WITHOUT_GVL(func, arg)
20
22struct rb_io {
23
25 VALUE self;
26
29
31 int fd;
32
34 enum rb_io_mode mode;
35
37 rb_pid_t pid;
38
40 int lineno;
41
44
46 void (*finalize)(struct rb_io*,int);
47
50
56
63
64 struct rb_io_encoding encs;
68
74
77
85
88
94
100
109
114};
115
116/* io.c */
117void ruby_set_inplace_mode(const char *);
118void rb_stdio_set_default_encoding(void);
119VALUE rb_io_flush_raw(VALUE, int);
120size_t rb_io_memsize(const rb_io_t *);
121int rb_stderr_tty_p(void);
122VALUE rb_io_popen(VALUE pname, VALUE pmode, VALUE env, VALUE opt);
123
124VALUE rb_io_prep_stdin(void);
125VALUE rb_io_prep_stdout(void);
126VALUE rb_io_prep_stderr(void);
127
128int rb_io_fptr_finalize(struct rb_io *fptr);
129
130RUBY_SYMBOL_EXPORT_BEGIN
131/* io.c (export) */
132void rb_maygvl_fd_fix_cloexec(int fd);
133int rb_gc_for_fd(int err);
134void rb_write_error_str(VALUE mesg);
135
136VALUE rb_io_blocking_region_wait(struct rb_io *io, rb_blocking_function_t *function, void *argument, enum rb_io_event events);
137VALUE rb_io_blocking_region(struct rb_io *io, rb_blocking_function_t *function, void *argument);
138RUBY_SYMBOL_EXPORT_END
139
140#endif /* INTERNAL_IO_H */
rb_io_event
Type of events that an IO can wait.
Definition io.h:81
int rb_io_fptr_finalize(rb_io_t *fptr)
Destroys the given IO.
Definition io.c:5679
Decomposed encoding flags (e.g.
Definition io.h:119
IO buffers.
Definition io.h:94
Ruby's IO, metadata and buffers.
Definition io.h:280
rb_io_buffer_t wbuf
Write buffer.
Definition io.h:315
enum rb_io_mode mode
mode flags: FMODE_XXXs
Definition io.h:295
void(* finalize)(struct rb_io *, int)
finalize proc
Definition io.h:311
rb_econv_t * readconv
Encoding converter used when reading from this IO.
Definition io.h:337
rb_econv_t * writeconv
Encoding converter used when writing to this IO.
Definition io.h:348
struct rb_io_encoding encs
Decomposed encoding flags.
Definition io.h:333
VALUE self
The IO's Ruby level counterpart.
Definition io.h:283
VALUE write_lock
This is a Ruby level mutex.
Definition io.h:385
VALUE timeout
The timeout associated with this IO when performing blocking operations.
Definition io.h:391
FILE * stdio_file
stdio ptr for read/write, if available.
Definition io.h:287
VALUE writeconv_pre_ecopts
Value of ::rb_io_t::rb_io_enc_t::ecopts stored right before initialising rb_io_t::writeconv.
Definition io.h:375
VALUE tied_io_for_writing
Duplex IO object, if set.
Definition io.h:330
int writeconv_initialized
Whether rb_io_t::writeconv is already set up.
Definition io.h:361
int fd
file descriptor.
Definition io.h:291
rb_io_buffer_t rbuf
(Byte) read buffer.
Definition io.h:322
int lineno
number of lines read
Definition io.h:303
VALUE writeconv_asciicompat
This is, when set, an instance of rb_cString which holds the "common" encoding.
Definition io.h:357
rb_io_buffer_t cbuf
rb_io_ungetc() destination.
Definition io.h:344
rb_pid_t pid
child's pid (for pipes)
Definition io.h:299
int writeconv_pre_ecflags
Value of ::rb_io_t::rb_io_enc_t::ecflags stored right before initialising rb_io_t::writeconv.
Definition io.h:368
VALUE pathv
pathname for file
Definition io.h:307
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40