Ruby 3.5.0dev (2025-01-10 revision 5fab31b15e32622c4b71d1d347a41937e9f9c212)
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 int 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);
122void rb_io_fptr_finalize_internal(void *ptr);
123#ifdef rb_io_fptr_finalize
124# undef rb_io_fptr_finalize
125#endif
126#define rb_io_fptr_finalize rb_io_fptr_finalize_internal
127VALUE rb_io_popen(VALUE pname, VALUE pmode, VALUE env, VALUE opt);
128
129VALUE rb_io_prep_stdin(void);
130VALUE rb_io_prep_stdout(void);
131VALUE rb_io_prep_stderr(void);
132
133RUBY_SYMBOL_EXPORT_BEGIN
134/* io.c (export) */
135void rb_maygvl_fd_fix_cloexec(int fd);
136int rb_gc_for_fd(int err);
137void rb_write_error_str(VALUE mesg);
138
139VALUE rb_io_blocking_region_wait(struct rb_io *io, rb_blocking_function_t *function, void *argument, enum rb_io_event events);
140VALUE rb_io_blocking_region(struct rb_io *io, rb_blocking_function_t *function, void *argument);
141RUBY_SYMBOL_EXPORT_END
142
143#endif /* INTERNAL_IO_H */
rb_io_event
Type of events that an IO can wait.
Definition io.h:81
char * ptr
Pointer to the underlying memory region, of at least capa bytes.
Definition io.h:2
Decomposed encoding flags (e.g.
Definition io.h:119
IO buffers.
Definition io.h:94
Ruby's IO, metadata and buffers.
Definition io.h:143
int mode
mode flags: FMODE_XXXs
Definition io.h:158
rb_io_buffer_t wbuf
Write buffer.
Definition io.h:178
void(* finalize)(struct rb_io *, int)
finalize proc
Definition io.h:174
rb_econv_t * readconv
Encoding converter used when reading from this IO.
Definition io.h:200
rb_econv_t * writeconv
Encoding converter used when writing to this IO.
Definition io.h:211
struct rb_io_encoding encs
Decomposed encoding flags.
Definition io.h:196
VALUE self
The IO's Ruby level counterpart.
Definition io.h:146
VALUE write_lock
This is a Ruby level mutex.
Definition io.h:248
VALUE timeout
The timeout associated with this IO when performing blocking operations.
Definition io.h:254
FILE * stdio_file
stdio ptr for read/write, if available.
Definition io.h:150
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:238
VALUE tied_io_for_writing
Duplex IO object, if set.
Definition io.h:193
int writeconv_initialized
Whether rb_io_t::writeconv is already set up.
Definition io.h:224
int fd
file descriptor.
Definition io.h:154
rb_io_buffer_t rbuf
(Byte) read buffer.
Definition io.h:185
int lineno
number of lines read
Definition io.h:166
VALUE writeconv_asciicompat
This is, when set, an instance of rb_cString which holds the "common" encoding.
Definition io.h:220
rb_io_buffer_t cbuf
rb_io_ungetc() destination.
Definition io.h:207
rb_pid_t pid
child's pid (for pipes)
Definition io.h:162
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:231
VALUE pathv
pathname for file
Definition io.h:170
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40