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

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

win32.h
Go to the documentation of this file.
1#ifndef RBIMPL_INTERN_SELECT_WIN32_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RBIMPL_INTERN_SELECT_WIN32_H
23#include "ruby/internal/dosish.h" /* for rb_w32_select */
24#include "ruby/internal/attr/nonnull.h"
25#include "ruby/internal/attr/pure.h"
26#include "ruby/internal/attr/noalias.h"
27#include "ruby/internal/dllexport.h"
28#include "ruby/assert.h"
29
31#define rb_fd_zero rb_fd_zero
32#define rb_fd_clr rb_fd_clr
33#define rb_fd_isset rb_fd_isset
34#define rb_fd_copy rb_fd_copy
35#define rb_fd_dup rb_fd_dup
36#define rb_fd_ptr rb_fd_ptr
37#define rb_fd_max rb_fd_max
40 RBIMPL_SYMBOL_EXPORT_BEGIN()
41
42struct timeval;
43
49typedef struct {
50 int capa;
51 fd_set *fdset;
52} rb_fdset_t;
53
54 RBIMPL_ATTR_NONNULL(())
66void rb_fd_init(rb_fdset_t *f);
67
68 RBIMPL_ATTR_NONNULL(())
77 void rb_fd_term(rb_fdset_t *f);
78
79 RBIMPL_ATTR_NONNULL(())
87 void rb_fd_set(int fd, rb_fdset_t *f);
88
89 RBIMPL_ATTR_NONNULL(())
98void rb_w32_fd_copy(rb_fdset_t *dst, const fd_set *src, int max);
99
100 RBIMPL_ATTR_NONNULL(())
109void rb_w32_fd_dup(rb_fdset_t *dst, const rb_fdset_t *src);
110
111 RBIMPL_SYMBOL_EXPORT_END()
112
113 RBIMPL_ATTR_NONNULL(())
114 RBIMPL_ATTR_NOALIAS()
121static inline void
122 rb_fd_zero(rb_fdset_t *f)
123{
124 f->fdset->fd_count = 0;
125}
126
127 RBIMPL_ATTR_NONNULL(())
135static inline void
136 rb_fd_clr(int n, rb_fdset_t *f)
137{
138 rb_w32_fdclr(n, f->fdset);
139}
140
141 RBIMPL_ATTR_NONNULL(())
150static inline int
151 rb_fd_isset(int n, rb_fdset_t *f)
152{
153 return rb_w32_fdisset(n, f->fdset);
154}
155
156 RBIMPL_ATTR_NONNULL(())
165static inline void
166rb_fd_copy(rb_fdset_t *dst, const fd_set *src, int n)
167{
168 rb_w32_fd_copy(dst, src, n);
169}
170
171 RBIMPL_ATTR_NONNULL(())
180static inline void
181rb_fd_dup(rb_fdset_t *dst, const rb_fdset_t *src)
182{
183 rb_w32_fd_dup(dst, src);
184}
185
211static inline int
212 rb_fd_select(int n, rb_fdset_t *rfds, rb_fdset_t *wfds, rb_fdset_t *efds, struct timeval *timeout)
213{
214 return rb_w32_select(
215 n,
216 rfds ? rfds->fdset : NULL,
217 wfds ? wfds->fdset : NULL,
218 efds ? efds->fdset : NULL,
219 timeout);
220}
221
222 RBIMPL_ATTR_NONNULL(())
223 RBIMPL_ATTR_PURE()
236static inline fd_set *
237rb_fd_ptr(const rb_fdset_t *f)
238{
239 return f->fdset;
240}
241
242 RBIMPL_ATTR_NONNULL(())
243 RBIMPL_ATTR_PURE_UNLESS_DEBUG()
250static inline int
251rb_fd_max(const rb_fdset_t *f)
252{
253 const fd_set *p = f->fdset;
254
255 RBIMPL_ASSERT_OR_ASSUME(p);
256 return p->fd_count;
257}
258
259#endif /* RBIMPL_INTERN_SELECT_WIN32_H */
assert.h
RBIMPL_ASSERT_OR_ASSUME
#define RBIMPL_ASSERT_OR_ASSUME(expr)
This is either RUBY_ASSERT or RBIMPL_ASSUME, depending on RUBY_DEBUG.
Definition assert.h:229
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
dosish.h
Support for so-called dosish systems.
rb_fd_max
static int rb_fd_max(const rb_fdset_t *f)
It seems this function has no use.
Definition win32.h:251
rb_w32_fd_dup
void rb_w32_fd_dup(rb_fdset_t *dst, const rb_fdset_t *src)
Identical to rb_w32_fd_copy(), except it copies unlimited number of file descriptors.
Definition win32.c:2977
rb_w32_fd_copy
void rb_w32_fd_copy(rb_fdset_t *dst, const fd_set *src, int max)
Destructively overwrites an fdset with another.
Definition win32.c:2962
rb_fd_dup
static 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.
Definition win32.h:181
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 win32.h:237
rb_fd_copy
static void rb_fd_copy(rb_fdset_t *dst, const fd_set *src, int n)
Destructively overwrites an fdset with another.
Definition win32.h:166
noalias.h
Defines RBIMPL_ATTR_NOALIAS.
RBIMPL_ATTR_NOALIAS
#define RBIMPL_ATTR_NOALIAS()
Wraps (or simulates) __declspec((noalias))
Definition noalias.h:66
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
RBIMPL_ATTR_PURE_UNLESS_DEBUG
#define RBIMPL_ATTR_PURE_UNLESS_DEBUG()
Enables RBIMPL_ATTR_PURE if and only if.
Definition pure.h:38
rb_fdset_t
The data structure which wraps the fd_set bitmap used by select(2).
Definition largesize.h:71
rb_fdset_t::fdset
fd_set * fdset
File descriptors buffer.
Definition largesize.h:73
rb_fdset_t::capa
int capa
Maximum allowed number of FDs.
Definition win32.h:50
timeval
Definition missing.h:63