ia64/xen-unstable

view tools/xfrd/select.c @ 1921:24ecc060e9d7

bitkeeper revision 1.1108.21.1 (41062740xHG36OEbpVAmVX5N9WCaNw)

make vmlinuz really stripped
author cl349@freefall.cl.cam.ac.uk
date Tue Jul 27 09:58:24 2004 +0000 (2004-07-27)
parents 0e23f01219c6
children
line source
1 #include <stdlib.h>
2 #include <errno.h>
3 #include <unistd.h>
5 #include "select.h"
7 /** Zero all the file descriptor sets.
8 *
9 * @param set select set
10 * @param fd file descriptor
11 * @return 0 on success, -1 otherwise
12 */
13 void SelectSet_zero(SelectSet *set){
14 set->n = 0;
15 FD_ZERO(&set->rd);
16 FD_ZERO(&set->wr);
17 FD_ZERO(&set->er);
18 }
20 /** Add a file descriptor to the write set.
21 *
22 * @param set select set
23 * @param fd file descriptor
24 * @return 0 on success, -1 otherwise
25 */
26 void SelectSet_add_read(SelectSet *set, int fd){
27 FD_SET(fd, &set->rd);
28 if(fd > set->n) set->n = fd;
29 }
31 /** Add a file descriptor to the write set.
32 *
33 * @param set select set
34 * @param fd file descriptor
35 * @return 0 on success, -1 otherwise
36 */
37 void SelectSet_add_write(SelectSet *set, int fd){
38 FD_SET(fd, &set->wr);
39 if(fd > set->n) set->n = fd;
40 }
42 /** Select on file descriptors.
43 *
44 * @param set select set
45 * @param timeout timeout (may be NULL for no timeout)
46 * @return 0 on success, -1 otherwise
47 */
48 int SelectSet_select(SelectSet *set, struct timeval *timeout){
49 return select(set->n+1, &set->rd, &set->wr, &set->er, timeout);
50 }