Ruby: internal/io.h Source File

Ruby 3.4.1p0 (2024-12-25 revision 48d4efcb85000e1ebae42004e963b5d0cedddcf2)

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
28 FILE *stdio_file;
29
31 int fd;
32
34 int mode;
35
37 rb_pid_t pid;
38
40 int lineno;
41
43 VALUE pathv;
44
46 void (*finalize)(struct rb_io*,int);
47
49 rb_io_buffer_t wbuf;
50
55 rb_io_buffer_t rbuf;
56
62 VALUE tied_io_for_writing;
63
64 struct rb_io_encoding encs;
65
67 rb_econv_t *readconv;
68
73 rb_io_buffer_t cbuf;
74
76 rb_econv_t *writeconv;
77
84 VALUE writeconv_asciicompat;
85
87 int writeconv_initialized;
88
93 int writeconv_pre_ecflags;
94
99 VALUE writeconv_pre_ecopts;
100
108 VALUE write_lock;
109
113 VALUE timeout;
114};
115
116/* io.c */
117void ruby_set_inplace_mode(const char *);
118void rb_stdio_set_default_encoding(void);
119 VALUE 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
127 VALUE rb_io_popen(VALUE pname, VALUE pmode, VALUE env, VALUE opt);
128
129 VALUE rb_io_prep_stdin(void);
130 VALUE rb_io_prep_stdout(void);
131 VALUE 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
139 VALUE rb_io_blocking_region_wait(struct rb_io *io, rb_blocking_function_t *function, void *argument, enum rb_io_event events);
140 VALUE 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_econv_t
struct rb_econv_t rb_econv_t
An opaque struct that represents a lowest level of encoding conversion.
Definition transcode.h:73
io.h
rb_io_event
rb_io_event
Type of events that an IO can wait.
Definition io.h:81
rb_io_buffer_t
struct rb_io_internal_buffer rb_io_buffer_t
Just another name of rb_io_buffer_t.
Definition io.h:110
ruby.h
rb_io
Ruby's IO, metadata and buffers.
Definition io.h:143
rb_io::mode
int mode
mode flags: FMODE_XXXs
Definition io.h:158
rb_io::wbuf
rb_io_buffer_t wbuf
Write buffer.
Definition io.h:178
rb_io::finalize
void(* finalize)(struct rb_io *, int)
finalize proc
Definition io.h:174
rb_io::readconv
rb_econv_t * readconv
Encoding converter used when reading from this IO.
Definition io.h:200
rb_io::writeconv
rb_econv_t * writeconv
Encoding converter used when writing to this IO.
Definition io.h:211
rb_io::encs
struct rb_io_encoding encs
Decomposed encoding flags.
Definition io.h:196
rb_io::self
VALUE self
The IO's Ruby level counterpart.
Definition io.h:146
rb_io::write_lock
VALUE write_lock
This is a Ruby level mutex.
Definition io.h:248
rb_io::timeout
VALUE timeout
The timeout associated with this IO when performing blocking operations.
Definition io.h:254
rb_io::stdio_file
FILE * stdio_file
stdio ptr for read/write, if available.
Definition io.h:150
rb_io::writeconv_pre_ecopts
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
rb_io::tied_io_for_writing
VALUE tied_io_for_writing
Duplex IO object, if set.
Definition io.h:193
rb_io::writeconv_initialized
int writeconv_initialized
Whether rb_io_t::writeconv is already set up.
Definition io.h:224
rb_io::fd
int fd
file descriptor.
Definition io.h:154
rb_io::rbuf
rb_io_buffer_t rbuf
(Byte) read buffer.
Definition io.h:185
rb_io::lineno
int lineno
number of lines read
Definition io.h:166
rb_io::writeconv_asciicompat
VALUE writeconv_asciicompat
This is, when set, an instance of rb_cString which holds the "common" encoding.
Definition io.h:220
rb_io::cbuf
rb_io_buffer_t cbuf
rb_io_ungetc() destination.
Definition io.h:207
rb_io::pid
rb_pid_t pid
child's pid (for pipes)
Definition io.h:162
rb_io::writeconv_pre_ecflags
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
rb_io::pathv
VALUE pathv
pathname for file
Definition io.h:170
VALUE
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40