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

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

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
44typedef struct {
45 int capa;
46 fd_set *fdset;
47} rb_fdset_t;
48
49 void rb_fd_init(rb_fdset_t *);
50 void rb_fd_term(rb_fdset_t *);
51 void rb_fd_set(int, rb_fdset_t *);
52void rb_w32_fd_copy(rb_fdset_t *, const fd_set *, int);
53void rb_w32_fd_dup(rb_fdset_t *dst, const rb_fdset_t *src);
54
55 RBIMPL_SYMBOL_EXPORT_END()
56
57 RBIMPL_ATTR_NONNULL(())
58 RBIMPL_ATTR_NOALIAS()
59static inline void
60 rb_fd_zero(rb_fdset_t *f)
61{
62 f->fdset->fd_count = 0;
63}
64
65 RBIMPL_ATTR_NONNULL(())
66static inline void
67 rb_fd_clr(int n, rb_fdset_t *f)
68{
69 rb_w32_fdclr(n, f->fdset);
70}
71
72 RBIMPL_ATTR_NONNULL(())
73static inline int
74 rb_fd_isset(int n, rb_fdset_t *f)
75{
76 return rb_w32_fdisset(n, f->fdset);
77}
78
79 RBIMPL_ATTR_NONNULL(())
80static inline void
81rb_fd_copy(rb_fdset_t *dst, const fd_set *src, int n)
82{
83 rb_w32_fd_copy(dst, src, n);
84}
85
86 RBIMPL_ATTR_NONNULL(())
87static inline void
88rb_fd_dup(rb_fdset_t *dst, const rb_fdset_t *src)
89{
90 rb_w32_fd_dup(dst, src);
91}
92
93static inline int
94 rb_fd_select(int n, rb_fdset_t *rfds, rb_fdset_t *wfds, rb_fdset_t *efds, struct timeval *timeout)
95{
96 return rb_w32_select(
97 n,
98 rfds ? rfds->fdset : NULL,
99 wfds ? wfds->fdset : NULL,
100 efds ? efds->fdset : NULL,
101 timeout);
102}
103
104 RBIMPL_ATTR_NONNULL(())
105 RBIMPL_ATTR_PURE()
106/* :TODO: can this function be __attribute__((returns_nonnull)) or not? */
107static inline fd_set *
108rb_fd_ptr(const rb_fdset_t *f)
109{
110 return f->fdset;
111}
112
113 RBIMPL_ATTR_NONNULL(())
114 RBIMPL_ATTR_PURE()
115static inline int
116rb_fd_max(const rb_fdset_t *f)
117{
118 const fd_set *p = f->fdset;
119
120 RBIMPL_ASSERT_OR_ASSUME(p);
121 return p->fd_count;
122}
123
124#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
Tewaking visibility of C variables/functions.
RBIMPL_SYMBOL_EXPORT_END
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition: dllexport.h:86
RBIMPL_SYMBOL_EXPORT_BEGIN
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition: dllexport.h:77
dosish.h
Support for so-called dosish systems.
rb_w32_fd_dup
void rb_w32_fd_dup(rb_fdset_t *dst, const rb_fdset_t *src)
Definition: win32.c:2928
rb_w32_fd_copy
void rb_w32_fd_copy(rb_fdset_t *, const fd_set *, int)
Definition: win32.c:2913
noalias.h
Defines RBIMPL_ATTR_NOALIAS.
RBIMPL_ATTR_NOALIAS
#define RBIMPL_ATTR_NOALIAS()
Wraps (or simulates) __declspec((noalias))
Definition: noalias.h:55
nonnull.h
Defines RBIMPL_ATTR_NONNULL.
RBIMPL_ATTR_NONNULL
#define RBIMPL_ATTR_NONNULL(list)
Wraps (or simulates) __attribute__((nonnull))
Definition: nonnull.h:29
rb_fd_isset
#define rb_fd_isset
Definition: posix.h:41
rb_fd_select
#define rb_fd_select
Definition: posix.h:43
rb_fd_init
#define rb_fd_init
Definition: posix.h:42
rb_fd_set
#define rb_fd_set
Definition: posix.h:39
rb_fd_zero
#define rb_fd_zero
Definition: posix.h:38
rb_fd_clr
#define rb_fd_clr
Definition: posix.h:40
rb_fd_term
#define rb_fd_term(f)
Definition: posix.h:80
pure.h
Defines RBIMPL_ATTR_PURE.
RBIMPL_ATTR_PURE
#define RBIMPL_ATTR_PURE()
Wraps (or simulates) __attribute__((pure))
Definition: pure.h:33
NULL
#define NULL
Definition: regenc.h:69
f
#define f
const
#define const
Definition: strftime.c:108
rb_fdset_t
Definition: largesize.h:69
rb_fdset_t::fdset
fd_set * fdset
Definition: largesize.h:71
rb_fdset_t::capa
int capa
Definition: win32.h:45
timeval
Definition: missing.h:51
rb_w32_fdclr
void rb_w32_fdclr(int, fd_set *)
Definition: win32.c:2883
rb_w32_select
int WSAAPI rb_w32_select(int, fd_set *, fd_set *, fd_set *, struct timeval *)
Definition: win32.c:3306
rb_w32_fdisset
int rb_w32_fdisset(int, fd_set *)
Definition: win32.c:2901