source: branches/minix3-book/include/sys/select.h

Last change on this file was 4, checked in by Mattia Monga, 14 years ago

Importazione sorgenti libro

File size: 1.4 KB
RevLine 
[4]1#ifndef _SYS_SELECT_H
2#define _SYS_SELECT_H 1
3
4#include <sys/time.h>
5#include <sys/types.h>
6#include <limits.h>
7#include <string.h>
8
9/* Use this datatype as basic storage unit in fd_set */
10typedef u32_t fd_mask;
11
12/* This many bits fit in an fd_set word. */
13#define _FDSETBITSPERWORD (sizeof(fd_mask)*8)
14
15/* Bit manipulation macros */
16#define _FD_BITMASK(b) (1L << ((b) % _FDSETBITSPERWORD))
17#define _FD_BITWORD(b) ((b)/_FDSETBITSPERWORD)
18
19/* Default FD_SETSIZE is OPEN_MAX. */
20#ifndef FD_SETSIZE
21#define FD_SETSIZE OPEN_MAX
22#endif
23
24/* We want to store FD_SETSIZE bits. */
25#define _FDSETWORDS ((FD_SETSIZE+_FDSETBITSPERWORD-1)/_FDSETBITSPERWORD)
26
27typedef struct {
28 fd_mask fds_bits[_FDSETWORDS];
29} fd_set;
30
31_PROTOTYPE( int select, (int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *timeout) );
32
33#define FD_ZERO(s) do { int _i; for(_i = 0; _i < _FDSETWORDS; _i++) { (s)->fds_bits[_i] = 0; } } while(0)
34#define FD_SET(f, s) do { (s)->fds_bits[_FD_BITWORD(f)] |= _FD_BITMASK(f); } while(0)
35#define FD_CLR(f, s) do { (s)->fds_bits[_FD_BITWORD(f)] &= ~(_FD_BITMASK(f)); } while(0)
36#define FD_ISSET(f, s) ((s)->fds_bits[_FD_BITWORD(f)] & _FD_BITMASK(f))
37
38/* possible select() operation types; read, write, errors */
39/* (FS/driver internal use only) */
40#define SEL_RD (1 << 0)
41#define SEL_WR (1 << 1)
42#define SEL_ERR (1 << 2)
43#define SEL_NOTIFY (1 << 3) /* not a real select operation */
44
45#endif /* _SYS_SELECT_H */
46
Note: See TracBrowser for help on using the repository browser.