19 #ifndef _COBALT_KERNEL_SELECT_H 20 #define _COBALT_KERNEL_SELECT_H 22 #include <cobalt/kernel/list.h> 23 #include <cobalt/kernel/thread.h> 30 #define XNSELECT_READ 0 31 #define XNSELECT_WRITE 1 32 #define XNSELECT_EXCEPT 2 33 #define XNSELECT_MAX_TYPES 3 36 struct xnsynch synchbase;
40 } fds [XNSELECT_MAX_TYPES];
41 struct list_head destroy_link;
42 struct list_head bindings;
45 #define __NFDBITS__ (8 * sizeof(unsigned long)) 46 #define __FDSET_LONGS__ (__FD_SETSIZE/__NFDBITS__) 47 #define __FDELT__(d) ((d) / __NFDBITS__) 48 #define __FDMASK__(d) (1UL << ((d) % __NFDBITS__)) 50 static inline void __FD_SET__(
unsigned long __fd, __kernel_fd_set *__fdsetp)
52 unsigned long __tmp = __fd / __NFDBITS__;
53 unsigned long __rem = __fd % __NFDBITS__;
54 __fdsetp->fds_bits[__tmp] |= (1UL<<__rem);
57 static inline void __FD_CLR__(
unsigned long __fd, __kernel_fd_set *__fdsetp)
59 unsigned long __tmp = __fd / __NFDBITS__;
60 unsigned long __rem = __fd % __NFDBITS__;
61 __fdsetp->fds_bits[__tmp] &= ~(1UL<<__rem);
64 static inline int __FD_ISSET__(
unsigned long __fd,
const __kernel_fd_set *__p)
66 unsigned long __tmp = __fd / __NFDBITS__;
67 unsigned long __rem = __fd % __NFDBITS__;
68 return (__p->fds_bits[__tmp] & (1UL<<__rem)) != 0;
71 static inline void __FD_ZERO__(__kernel_fd_set *__p)
73 unsigned long *__tmp = __p->fds_bits;
76 __i = __FDSET_LONGS__;
85 struct list_head bindings;
88 #define DECLARE_XNSELECT(name) struct xnselect name 90 struct xnselect_binding {
91 struct xnselector *selector;
94 unsigned int bit_index;
95 struct list_head link;
96 struct list_head slink;
102 struct xnselect_binding *binding,
103 struct xnselector *selector,
105 unsigned int bit_index,
108 int __xnselect_signal(
struct xnselect *select_block,
unsigned int state);
123 if (!list_empty(&select_block->bindings))
124 return __xnselect_signal(select_block, state);
133 int xnselect(
struct xnselector *selector,
134 fd_set *out_fds[XNSELECT_MAX_TYPES],
135 fd_set *in_fds[XNSELECT_MAX_TYPES],
137 xnticks_t timeout, xntmode_t timeout_mode);
141 int xnselect_mount(
void);
143 int xnselect_umount(
void);
void xnselector_destroy(struct xnselector *selector)
Destroy a selector block.
Definition: select.c:402
void xnselect_destroy(struct xnselect *select_block)
Destroy the xnselect structure associated with a file descriptor.
Definition: select.c:177
int xnselector_init(struct xnselector *selector)
Initialize a selector structure.
Definition: select.c:286
void xnselect_init(struct xnselect *select_block)
Initialize a struct xnselect structure.
Definition: select.c:65
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:327
static int xnselect_signal(struct xnselect *select_block, unsigned int state)
Signal a file descriptor state change.
Definition: select.h:121
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:109