Ruby: include/ruby/internal/intern/select/largesize.h Source File

Ruby 3.2.5p208 (2024-07-26 revision 31d0f1a2e7dbfb60731d1f05b868e1d578cda493)

largesize.h
Go to the documentation of this file.
1#ifndef RBIMPL_INTERN_SELECT_LARGESIZE_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RBIMPL_INTERN_SELECT_LARGESIZE_H
55#include "ruby/internal/attr/nonnull.h"
56#include "ruby/internal/attr/pure.h"
57#include "ruby/internal/dllexport.h"
58
60#define rb_fd_ptr rb_fd_ptr
61#define rb_fd_max rb_fd_max
64struct timeval;
65
71 typedef struct {
72 int maxfd;
73 fd_set *fdset;
74} rb_fdset_t;
75
76 RBIMPL_SYMBOL_EXPORT_BEGIN()
77 RBIMPL_ATTR_NONNULL(())
85 void rb_fd_init(rb_fdset_t *f);
86
87 RBIMPL_ATTR_NONNULL(())
96 void rb_fd_term(rb_fdset_t *f);
97
98 RBIMPL_ATTR_NONNULL(())
105 void rb_fd_zero(rb_fdset_t *f);
106
107 RBIMPL_ATTR_NONNULL(())
115 void rb_fd_set(int fd, rb_fdset_t *f);
116
117 RBIMPL_ATTR_NONNULL(())
125 void rb_fd_clr(int fd, rb_fdset_t *f);
126
127 RBIMPL_ATTR_NONNULL(())
128 RBIMPL_ATTR_PURE()
138 int rb_fd_isset(int fd, const rb_fdset_t *f);
139
148 void rb_fd_copy(rb_fdset_t *dst, const fd_set *src, int max);
149
158 void rb_fd_dup(rb_fdset_t *dst, const rb_fdset_t *src);
159
177 int rb_fd_select(int nfds, rb_fdset_t *rfds, rb_fdset_t *wfds, rb_fdset_t *efds, struct timeval *timeout);
178 RBIMPL_SYMBOL_EXPORT_END()
179
180 RBIMPL_ATTR_NONNULL(())
181 RBIMPL_ATTR_PURE()
194static inline fd_set *
195rb_fd_ptr(const rb_fdset_t *f)
196{
197 return f->fdset;
198}
199
200 RBIMPL_ATTR_NONNULL(())
201 RBIMPL_ATTR_PURE()
208static inline int
209rb_fd_max(const rb_fdset_t *f)
210{
211 return f->maxfd;
212}
213
214#endif /* RBIMPL_INTERN_SELECT_LARGESIZE_H */
dllexport.h
Tweaking visibility of C variables/functions.
RBIMPL_SYMBOL_EXPORT_END
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition dllexport.h:106
RBIMPL_SYMBOL_EXPORT_BEGIN
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition dllexport.h:97
rb_fd_max
static int rb_fd_max(const rb_fdset_t *f)
It seems this function has no use.
Definition largesize.h:209
rb_fd_copy
void rb_fd_copy(rb_fdset_t *dst, const fd_set *src, int max)
Destructively overwrites an fdset with another.
rb_fd_dup
void rb_fd_dup(rb_fdset_t *dst, const rb_fdset_t *src)
Identical to rb_fd_copy(), except it copies unlimited number of file descriptors.
rb_fd_term
void rb_fd_term(rb_fdset_t *f)
Destroys the rb_fdset_t, releasing any memory and resources it used.
rb_fd_ptr
static fd_set * rb_fd_ptr(const rb_fdset_t *f)
Raw pointer to fd_set.
Definition largesize.h:195
nonnull.h
Defines RBIMPL_ATTR_NONNULL.
RBIMPL_ATTR_NONNULL
#define RBIMPL_ATTR_NONNULL(list)
Wraps (or simulates) __attribute__((nonnull))
Definition nonnull.h:30
rb_fd_isset
#define rb_fd_isset
Queries if the given fd is in the rb_fdset_t.
Definition posix.h:60
rb_fd_select
#define rb_fd_select
Waits for multiple file descriptors at once.
Definition posix.h:66
rb_fd_init
#define rb_fd_init
Initialises the :given :rb_fdset_t.
Definition posix.h:63
rb_fd_set
#define rb_fd_set
Sets the given fd to the rb_fdset_t.
Definition posix.h:54
rb_fdset_t
fd_set rb_fdset_t
The data structure which wraps the fd_set bitmap used by select(2).
Definition posix.h:48
rb_fd_zero
#define rb_fd_zero
Clears the given rb_fdset_t.
Definition posix.h:51
rb_fd_clr
#define rb_fd_clr
Unsets the given fd from the rb_fdset_t.
Definition posix.h:57
pure.h
Defines RBIMPL_ATTR_PURE.
RBIMPL_ATTR_PURE
#define RBIMPL_ATTR_PURE()
Wraps (or simulates) __attribute__((pure))
Definition pure.h:33
rb_fdset_t
The data structure which wraps the fd_set bitmap used by select(2).
Definition largesize.h:71
rb_fdset_t::maxfd
int maxfd
Maximum allowed number of FDs.
Definition largesize.h:72
rb_fdset_t::fdset
fd_set * fdset
File descriptors buffer.
Definition largesize.h:73
timeval
Definition missing.h:63