Ruby 3.5.0dev (2025-02-22 revision 412997300569c1853c09813e4924b6df3d7e8669)
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
37
48typedef 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
85static inline void
86rb_fd_copy(rb_fdset_t *dst, const fd_set *src, int n)
87{
88 *dst = *src;
89}
90
100static inline void
101rb_fd_dup(rb_fdset_t *dst, const fd_set *src)
102{
103 *dst = *src;
104}
105
107/* :TODO: can this function be __attribute__((returns_nonnull)) or not? */
119static inline fd_set *
121{
122 return f;
123}
124
132static inline int
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))
144#endif /* RBIMPL_INTERN_SELECT_POSIX_H */
Defines RBIMPL_ATTR_CONST.
#define RBIMPL_ATTR_CONST()
Wraps (or simulates) __attribute__((const))
Definition const.h:36
Defines RBIMPL_ATTR_NOALIAS.
#define RBIMPL_ATTR_NOALIAS()
Wraps (or simulates) __declspec((noalias))
Definition noalias.h:66
Defines RBIMPL_ATTR_NONNULL.
#define RBIMPL_ATTR_NONNULL(list)
Wraps (or simulates) __attribute__((nonnull))
Definition nonnull.h:30
static int rb_fd_max(const rb_fdset_t *f)
It seems this function has no use.
Definition posix.h:133
static void rb_fd_dup(rb_fdset_t *dst, const fd_set *src)
Destructively overwrites an fdset with another.
Definition posix.h:101
static fd_set * rb_fd_ptr(rb_fdset_t *f)
Raw pointer to fd_set.
Definition posix.h:120
fd_set rb_fdset_t
The data structure which wraps the fd_set bitmap used by select(2).
Definition posix.h:48
static void rb_fd_copy(rb_fdset_t *dst, const fd_set *src, int n)
Destructively overwrites an fdset with another.
Definition posix.h:86
#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
Defines RBIMPL_ATTR_PURE.
#define RBIMPL_ATTR_PURE()
Wraps (or simulates) __attribute__((pure))
Definition pure.h:33
The data structure which wraps the fd_set bitmap used by select(2).
Definition largesize.h:71