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

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

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
75 RBIMPL_ATTR_NONNULL(())
76 RBIMPL_ATTR_NOALIAS()
85static inline void
86rb_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
101rb_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 *
120rb_fd_ptr(rb_fdset_t *f)
121{
122 return f;
123}
124
125 RBIMPL_ATTR_CONST()
132static inline int
133rb_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))
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
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_max
static int rb_fd_max(const rb_fdset_t *f)
It seems this function has no use.
Definition posix.h:133
rb_fd_dup
static void rb_fd_dup(rb_fdset_t *dst, const fd_set *src)
Destructively overwrites an fdset with another.
Definition posix.h:101
rb_fd_ptr
static fd_set * rb_fd_ptr(rb_fdset_t *f)
Raw pointer to fd_set.
Definition posix.h:120
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_copy
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
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