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

Ruby 3.4.7p58 (2025-10-08 revision 7a5688e2a27668e48f8d6ff4af5b2208b98a2f5e)

posix.h
Go to the documentation of this file.
1#ifndef RBIMPL_INTERN_SELECT_POSIX_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RBIMPL_INTERN_SELECT_POSIX_H
23#include "ruby/internal/config.h"
24
25#ifdef HAVE_SYS_SELECT_H
26# include <sys/select.h> /* for select(2) (modern POSIX) */
27#endif
28
29#ifdef HAVE_UNISTD_H
30# include <unistd.h> /* for select(2) (archaic UNIX) */
31#endif
32
33#include "ruby/internal/attr/const.h"
34#include "ruby/internal/attr/noalias.h"
35#include "ruby/internal/attr/nonnull.h"
36#include "ruby/internal/attr/pure.h"
37
48 typedef fd_set rb_fdset_t;
49
51#define rb_fd_zero FD_ZERO
52
54#define rb_fd_set FD_SET
55
57#define rb_fd_clr FD_CLR
58
60#define rb_fd_isset FD_ISSET
61
63#define rb_fd_init FD_ZERO
64
66#define rb_fd_select select
67
69#define rb_fd_copy rb_fd_copy
70#define rb_fd_dup rb_fd_dup
71#define rb_fd_ptr rb_fd_ptr
72#define rb_fd_max rb_fd_max
74
75 RBIMPL_ATTR_NONNULL(())
76 RBIMPL_ATTR_NOALIAS()
85static inline void
86 rb_fd_copy(rb_fdset_t *dst, const fd_set *src, int n)
87{
88 *dst = *src;
89}
90
91 RBIMPL_ATTR_NONNULL(())
92 RBIMPL_ATTR_NOALIAS()
100static inline void
101 rb_fd_dup(rb_fdset_t *dst, const fd_set *src)
102{
103 *dst = *src;
104}
105
106 RBIMPL_ATTR_PURE()
107/* :TODO: can this function be __attribute__((returns_nonnull)) or not? */
119static inline fd_set *
120 rb_fd_ptr(rb_fdset_t *f)
121{
122 return f;
123}
124
125 RBIMPL_ATTR_CONST()
132static inline int
133 rb_fd_max(const rb_fdset_t *f)
134{
135 return FD_SETSIZE;
136}
137
139/* :FIXME: What are these? They don't exist for sibling implementations. */
140#define rb_fd_init_copy(d, s) (*(d) = *(s))
141#define rb_fd_term(f) ((void)(f))
143
144#endif /* RBIMPL_INTERN_SELECT_POSIX_H */
const.h
Defines RBIMPL_ATTR_CONST.
RBIMPL_ATTR_CONST
#define RBIMPL_ATTR_CONST()
Wraps (or simulates) __attribute__((const))
Definition const.h:36
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_ptr
static fd_set * rb_fd_ptr(const rb_fdset_t *f)
Raw pointer to fd_set.
Definition largesize.h:195
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
inline
#define inline
Old Visual Studio versions do not support the inline keyword, so we need to define it to be __inline.
Definition defines.h:91
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