Xenomai API  2.5.6.1
include/nucleus/select.h
Go to the documentation of this file.
00001 
00025 #ifndef XNSELECT_H
00026 #define XNSELECT_H
00027 
00031 #include <nucleus/thread.h>
00032 
00033 #define XNSELECT_READ      0
00034 #define XNSELECT_WRITE     1
00035 #define XNSELECT_EXCEPT    2
00036 #define XNSELECT_MAX_TYPES 3
00037 
00038 struct xnselector {
00039         xnsynch_t synchbase;
00040         struct fds {
00041                 fd_set expected;
00042                 fd_set pending;
00043         } fds [XNSELECT_MAX_TYPES];
00044         xnholder_t destroy_link;
00045         xnqueue_t bindings; /* only used by xnselector_destroy */
00046 };
00047 
00048 #ifdef CONFIG_XENO_OPT_SELECT
00049 
00050 struct xnselect {
00051         xnqueue_t bindings;
00052 };
00053 
00054 #define DECLARE_XNSELECT(name) struct xnselect name
00055 
00056 struct xnselect_binding {
00057         struct xnselector *selector;
00058         struct xnselect *fd;
00059         unsigned type;
00060         unsigned bit_index;
00061         xnholder_t link;  /* link in selected fds list. */
00062         xnholder_t slink; /* link in selector list */
00063 };
00064 
00065 #ifdef __cplusplus
00066 extern "C" {
00067 #endif /* __cplusplus */
00068 
00069 void xnselect_init(struct xnselect *select_block);
00070 
00071 int xnselect_bind(struct xnselect *select_block,
00072                   struct xnselect_binding *binding,
00073                   struct xnselector *selector,
00074                   unsigned type,
00075                   unsigned bit_index,
00076                   unsigned state);
00077 
00078 int __xnselect_signal(struct xnselect *select_block, unsigned state);
00079 
00090 static inline int
00091 xnselect_signal(struct xnselect *select_block, unsigned state)
00092 {
00093         if (!emptyq_p(&select_block->bindings))
00094                 return __xnselect_signal(select_block, state);
00095         return 0;
00096 }
00097 
00098 void xnselect_destroy(struct xnselect *select_block);
00099 
00100 int xnselector_init(struct xnselector *selector);
00101 
00102 int xnselect(struct xnselector *selector,
00103              fd_set *out_fds[XNSELECT_MAX_TYPES],
00104              fd_set *in_fds[XNSELECT_MAX_TYPES],
00105              int nfds,
00106              xnticks_t timeout, xntmode_t timeout_mode);
00107 
00108 void xnselector_destroy(struct xnselector *selector);
00109 
00110 int xnselect_mount(void);
00111 
00112 int xnselect_umount(void);
00113 
00114 #ifdef __cplusplus
00115 }
00116 #endif /* __cplusplus */
00117 
00118 #else /* !CONFIG_XENO_OPT_SELECT */
00119 struct xnselector;
00120 #define DECLARE_XNSELECT(name)
00121 #define xnselect_init(block)
00122 #define xnselect_bind(select_block,binding,selector,type,bit_index,state) \
00123         ({ -EBADF; })
00124 #define xnselect_signal(block, state) ({ int __ret = 0; __ret; })
00125 #define xnselect_destroy(block)
00126 #endif /* !CONFIG_XENO_OPT_SELECT */
00127 
00130 #endif /* XNSELECT_H */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines