1 /* $Id$ 2 * 3 * XPilot, a multiplayer gravity war game. Copyright (C) 1991-95 by 4 * 5 * Bj�rn Stabell (bjoerns@staff.cs.uit.no) 6 * Ken Ronny Schouten (kenrsc@stud.cs.uit.no) 7 * Bert G�sbers (bert@mc.bio.uva.nl) 8 * 9 * This program is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 2 of the License, or 12 * (at your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with this program; if not, write to the Free Software 21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 */ 23 24 #ifndef BIT_H 25 #define BIT_H 26 27 #define SET_BIT(w, bit) ( (w) |= (bit) ) 28 #define CLR_BIT(w, bit) ( (w) &= ~(bit) ) 29 #define BIT(w, bit) ( (w) & (bit) ) 30 #define TOGGLE_BIT(w, bit) ( (w) ^= (bit) ) 31 32 #define BITV_SIZE (8 * sizeof(bitv_t)) 33 #define BITV_DECL(X,N) bitv_t (X)[((N) + BITV_SIZE - 1) / BITV_SIZE] 34 #define BITV_SET(X,N) ((X)[(N) / BITV_SIZE] |= 1 << (N) % BITV_SIZE) 35 #define BITV_CLR(X,N) ((X)[(N) / BITV_SIZE] &= ~(1 << (N) % BITV_SIZE)) 36 #define BITV_ISSET(X,N) ((X)[(N) / BITV_SIZE] & (1 << (N) % BITV_SIZE)) 37 #define BITV_TOGGLE(X,N) ((X)[(N) / BITV_SIZE] ^= 1 << (N) % BITV_SIZE) 38 39 typedef unsigned char bitv_t; 40 41 #endif 42