Ruby  3.4.0dev (2024-11-22 revision 0989400a925cd201defdca9eb28eb87200b30785)
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 
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
85 static inline void
86 rb_fd_copy(rb_fdset_t *dst, const fd_set *src, int n)
87 {
88  *dst = *src;
89 }
90 
100 static inline void
101 rb_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? */
119 static inline fd_set *
121 {
122  return f;
123 }
124 
132 static 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.
RBIMPL_ATTR_CONST() int rb_io_oflags_fmode(int oflags)
Converts an oflags (that rb_io_modestr_oflags() returns) to a fmode (that rb_io_mode_flags() returns)...
RBIMPL_ATTR_PURE() int rb_io_read_pending(rb_io_t *fptr)
Queries if the passed IO has any pending reads.
Defines RBIMPL_ATTR_NOALIAS.
#define RBIMPL_ATTR_NOALIAS()
Wraps (or simulates) __declspec((noalias))
Definition: noalias.h:62
Defines RBIMPL_ATTR_NONNULL.
#define RBIMPL_ATTR_NONNULL(list)
Wraps (or simulates) __attribute__((nonnull))
Definition: nonnull.h:27
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
fd_set rb_fdset_t
The data structure which wraps the fd_set bitmap used by select(2).
Definition: posix.h:48
static fd_set * rb_fd_ptr(rb_fdset_t *f)
Raw pointer to fd_set.
Definition: posix.h:120
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:88
Defines RBIMPL_ATTR_PURE.
The data structure which wraps the fd_set bitmap used by select(2).
Definition: largesize.h:71