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

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

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/pure.h"
34#include "ruby/internal/attr/const.h"
35
36 typedef fd_set rb_fdset_t;
37
38#define rb_fd_zero FD_ZERO
39#define rb_fd_set FD_SET
40#define rb_fd_clr FD_CLR
41#define rb_fd_isset FD_ISSET
42#define rb_fd_init FD_ZERO
43#define rb_fd_select select
45#define rb_fd_copy rb_fd_copy
46#define rb_fd_dup rb_fd_dup
47#define rb_fd_ptr rb_fd_ptr
48#define rb_fd_max rb_fd_max
51static inline void
52 rb_fd_copy(rb_fdset_t *dst, const fd_set *src, int n)
53{
54 *dst = *src;
55}
56
57static inline void
58 rb_fd_dup(rb_fdset_t *dst, const fd_set *src)
59{
60 *dst = *src;
61}
62
63 RBIMPL_ATTR_PURE()
64/* :TODO: can this function be __attribute__((returns_nonnull)) or not? */
65static inline fd_set *
66rb_fd_ptr(rb_fdset_t *f)
67{
68 return f;
69}
70
71 RBIMPL_ATTR_CONST()
72static inline int
73rb_fd_max(const rb_fdset_t *f)
74{
75 return FD_SETSIZE;
76}
77
78/* :FIXME: What are these? They don't exist for shibling implementations. */
79#define rb_fd_init_copy(d, s) (*(d) = *(s))
80#define rb_fd_term(f) ((void)(f))
81
82#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
config.h
Thin wrapper to ruby/config.h.
rb_fd_copy
void rb_fd_copy(rb_fdset_t *, const fd_set *, int)
rb_fd_dup
void rb_fd_dup(rb_fdset_t *dst, const rb_fdset_t *src)
rb_fdset_t
fd_set rb_fdset_t
Definition: posix.h:36
pure.h
Defines RBIMPL_ATTR_PURE.
RBIMPL_ATTR_PURE
#define RBIMPL_ATTR_PURE()
Wraps (or simulates) __attribute__((pure))
Definition: pure.h:33
f
#define f
const
#define const
Definition: strftime.c:108
rb_fdset_t
Definition: largesize.h:69