31 #include <nucleus/thread.h>
33 #define XNSELECT_READ 0
34 #define XNSELECT_WRITE 1
35 #define XNSELECT_EXCEPT 2
36 #define XNSELECT_MAX_TYPES 3
43 } fds [XNSELECT_MAX_TYPES];
44 xnholder_t destroy_link;
48 #define __NFDBITS__ (8 * sizeof(unsigned long))
49 #define __FDSET_LONGS__ (__FD_SETSIZE/__NFDBITS__)
50 #define __FDELT__(d) ((d) / __NFDBITS__)
51 #define __FDMASK__(d) (1UL << ((d) % __NFDBITS__))
53 static inline void __FD_SET__(
unsigned long __fd, __kernel_fd_set *__fdsetp)
55 unsigned long __tmp = __fd / __NFDBITS__;
56 unsigned long __rem = __fd % __NFDBITS__;
57 __fdsetp->fds_bits[__tmp] |= (1UL<<__rem);
60 static inline void __FD_CLR__(
unsigned long __fd, __kernel_fd_set *__fdsetp)
62 unsigned long __tmp = __fd / __NFDBITS__;
63 unsigned long __rem = __fd % __NFDBITS__;
64 __fdsetp->fds_bits[__tmp] &= ~(1UL<<__rem);
67 static inline int __FD_ISSET__(
unsigned long __fd,
const __kernel_fd_set *__p)
69 unsigned long __tmp = __fd / __NFDBITS__;
70 unsigned long __rem = __fd % __NFDBITS__;
71 return (__p->fds_bits[__tmp] & (1UL<<__rem)) != 0;
74 static inline void __FD_ZERO__(__kernel_fd_set *__p)
76 unsigned long *__tmp = __p->fds_bits;
79 __i = __FDSET_LONGS__;
87 #ifdef CONFIG_XENO_OPT_SELECT
93 #define DECLARE_XNSELECT(name) struct xnselect name
95 struct xnselect_binding {
96 struct xnselector *selector;
111 struct xnselect_binding *binding,
112 struct xnselector *selector,
117 int __xnselect_signal(
struct xnselect *select_block,
unsigned state);
130 xnselect_signal(
struct xnselect *select_block,
unsigned state)
132 if (!emptyq_p(&select_block->bindings))
133 return __xnselect_signal(select_block, state);
141 int xnselect(
struct xnselector *selector,
142 fd_set *out_fds[XNSELECT_MAX_TYPES],
143 fd_set *in_fds[XNSELECT_MAX_TYPES],
145 xnticks_t timeout, xntmode_t timeout_mode);
149 int xnselect_mount(
void);
151 int xnselect_umount(
void);
159 #define DECLARE_XNSELECT(name)
160 #define xnselect_init(block)
161 #define xnselect_bind(select_block,binding,selector,type,bit_index,state) \
163 #define xnselect_signal(block, state) ({ int __ret = 0; __ret; })
164 #define xnselect_destroy(block)
int xnselect_bind(struct xnselect *select_block, struct xnselect_binding *binding, struct xnselector *selector, unsigned type, unsigned index, unsigned state)
Bind a file descriptor (represented by its xnselect structure) to a selector block.
Definition: select.c:110
int xnselect(struct xnselector *selector, fd_set *out_fds[XNSELECT_MAX_TYPES], fd_set *in_fds[XNSELECT_MAX_TYPES], int nfds, xnticks_t timeout, xntmode_t timeout_mode)
Check the state of a number of file descriptors, wait for a state change if no descriptor is ready...
Definition: select.c:322
void xnselect_destroy(struct xnselect *select_block)
Destroy the xnselect structure associated with a file descriptor.
Definition: select.c:179
int xnselector_init(struct xnselector *selector)
Initialize a selector structure.
Definition: select.c:285
void xnselector_destroy(struct xnselector *selector)
Destroy a selector block.
Definition: select.c:397
void xnselect_init(struct xnselect *select_block)
Initialize a struct xnselect structure.
Definition: select.c:70