2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
23 * related information and legal notices. It is expected that any future
24 * projects/authors will amend these files as needed.
28 * bit.h: Definitions for variable sized bitfields
30 * Known contributors to this file:
37 typedef unsigned int bit_mask;
38 typedef bit_mask *bit_fdmask;
41 #define bit(x) (1 << (x))
45 * File descriptor bit manipulation macros for use with select(2)
48 #define BIT_BITSPERMASK (sizeof(bit_mask) * BIT_NBBY)
50 #define BIT_SETB(a,b) \
51 ((b)[(a)/BIT_BITSPERMASK] |= 1 << ((a) % BIT_BITSPERMASK))
52 #define BIT_CLRB(a,b) \
53 ((b)[(a)/BIT_BITSPERMASK] &= ~(1<< ((a) % BIT_BITSPERMASK)))
54 #define BIT_ISSETB(a,b) \
55 ((b)[(a)/BIT_BITSPERMASK] & (1<< ((a) % BIT_BITSPERMASK)))
56 #define BIT_ISCLRB(a,b) \
57 (((b)[(a)/BIT_BITSPERMASK] & (1<<((a) % BIT_BITSPERMASK))) == 0)
59 extern bit_fdmask bit_newfdmask();
61 extern bit_fdmask bit_newfdmask(void );
62 extern void bit_zero(bit_fdmask );
63 extern void bit_not(bit_fdmask );
64 extern void bit_copy(bit_fdmask , bit_fdmask );
65 extern void bit_or(bit_fdmask , bit_fdmask );
66 extern void bit_or3(bit_fdmask , bit_fdmask , bit_fdmask );
67 extern void bit_and(bit_fdmask , bit_fdmask );
68 extern void bit_and3(bit_fdmask , bit_fdmask , bit_fdmask );
69 extern int bit_fd(bit_fdmask );