Fixed and cleaned up select.h.
Exports now the prototype correctly in C++. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1735 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+39
-30
@@ -1,50 +1,59 @@
|
|||||||
/* select.h */
|
|
||||||
|
|
||||||
#ifndef _SYS_SELECT_H
|
#ifndef _SYS_SELECT_H
|
||||||
#define _SYS_SELECT_H
|
#define _SYS_SELECT_H
|
||||||
|
|
||||||
#include <sys/time.h> /* for struct timeval */
|
|
||||||
/*
|
/*
|
||||||
* You can define your own FDSETSIZE if you want more bits
|
** Distributed under the terms of the OpenBeOS License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* If FD_SET is already defined, only the select() prototype is
|
||||||
|
* exported in this header.
|
||||||
*/
|
*/
|
||||||
|
#ifndef FD_SET
|
||||||
|
|
||||||
|
/* You can define your own FDSETSIZE if you need more bits - but
|
||||||
|
* it should be enough for most uses.
|
||||||
|
*/
|
||||||
#ifndef FD_SETSIZE
|
#ifndef FD_SETSIZE
|
||||||
#define FD_SETSIZE 1024
|
# define FD_SETSIZE 1024
|
||||||
#endif /* FD_SETSIZE */
|
#endif
|
||||||
|
|
||||||
/* compatability with BSD */
|
/* Compatibily only: use FD_SETSIZE instead */
|
||||||
#define NBBY 8 /* number of bits in a byte */
|
#ifndef FDSETSIZE
|
||||||
|
# define FDSETSIZE FD_SETSIZE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* compatibility with BSD */
|
||||||
|
#define NBBY 8 /* number of bits in a byte */
|
||||||
|
|
||||||
typedef unsigned long fd_mask;
|
typedef unsigned long fd_mask;
|
||||||
|
|
||||||
#ifndef howmany
|
#ifndef howmany
|
||||||
#define howmany(x, y) (((x) + ((y) - 1)) / (y))
|
# define howmany(x, y) (((x) + ((y) - 1)) / (y))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
#define NFDBITS (sizeof(fd_mask) * NBBY)
|
||||||
* Compatibily only: use FD_SETSIZE instead
|
|
||||||
*/
|
|
||||||
#ifndef FDSETSIZE
|
|
||||||
#define FDSETSIZE FD_SETSIZE
|
|
||||||
#endif /* FDSETSIZE */
|
|
||||||
|
|
||||||
#define NFDBITS 32
|
|
||||||
|
|
||||||
typedef struct fd_set {
|
typedef struct fd_set {
|
||||||
unsigned mask[FDSETSIZE / NFDBITS];
|
fd_mask bits[howmany(FD_SETSIZE, NFDBITS)];
|
||||||
} fd_set;
|
} fd_set;
|
||||||
|
|
||||||
#define _FDMSKNO(fd) ((fd) / NFDBITS)
|
#define _FD_BITSINDEX(fd) ((fd) / NFDBITS)
|
||||||
#define _FDBITNO(fd) ((fd) % NFDBITS)
|
#define _FD_BIT(fd) (1L << ((fd) % NFDBITS))
|
||||||
|
|
||||||
#define FD_ZERO(setp) memset((setp)->mask, 0, sizeof((setp)->mask))
|
#define FD_ZERO(set) memset((set), 0, sizeof(fd_set))
|
||||||
#define FD_SET(fd, setp) ((setp)->mask[_FDMSKNO(fd)] |= (1 << (_FDBITNO(fd))))
|
#define FD_SET(fd, set) ((set)->bits[_FD_BITSINDEX(fd)] |= _FD_BIT(fd))
|
||||||
#define FD_CLR(fd, setp) ((setp)->mask[_FDMSKNO(fd)] &= ~(1 << (_FDBITNO(fd))))
|
#define FD_CLR(fd, set) ((set)->bits[_FD_BITSINDEX(fd)] &= ~_FD_BIT(fd))
|
||||||
#define FD_ISSET(fd, setp) ((setp)->mask[_FDMSKNO(fd)] & (1 << (_FDBITNO(fd))))
|
#define FD_ISSET(fd, set) ((set)->bits[_FD_BITSINDEX(fd)] & _FD_BIT(fd))
|
||||||
|
|
||||||
int select(int nbits, struct fd_set *rbits,
|
#endif /* FD_SET */
|
||||||
struct fd_set *wbits,
|
|
||||||
struct fd_set *ebits,
|
|
||||||
struct timeval *timeout);
|
|
||||||
|
|
||||||
#endif /* _SYS_SELECT_H */
|
extern
|
||||||
|
#ifdef __cplusplus
|
||||||
|
"C"
|
||||||
|
#endif
|
||||||
|
int select(int nbits, struct fd_set *rbits, struct fd_set *wbits,
|
||||||
|
struct fd_set *ebits, struct timeval *timeout);
|
||||||
|
|
||||||
|
#endif /* _SYS_SELECT_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user