1 /************************************************************************
2 * RSTP library - Rapid Spanning Tree (802.1t, 802.1w)
3 * Copyright (C) 2001-2003 Optical Access
6 * This file is part of RSTP library.
8 * RSTP library is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License as published by the
10 * Free Software Foundation; version 2.1
12 * RSTP library is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
15 * General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with RSTP library; see the file COPYING. If not, write to the Free
19 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21 **********************************************************************/
26 #define NUMBER_OF_PORTS 4
28 typedef struct tagBITMAP
30 unsigned long part0
; /* Least Significant part */
33 #define BitmapClear(BitmapPtr) \
34 { (BitmapPtr)->part0 = 0; }
36 #define BitmapSetAllBits(BitmapPtr) \
37 { (BitmapPtr)->part0 = 0xF; }
39 #define BitmapClearBits(BitmapPtr,BitmapBitsPtr) \
40 { (BitmapPtr)->part0 &= ~((BitmapBitsPtr)->part0); }
42 #define BitmapSetBits(BitmapPtr,BitmapBitsPtr) \
43 { (BitmapPtr)->part0 |= ((BitmapBitsPtr)->part0); }
45 #define BitmapOr(ResultPtr,BitmapPtr1,BitmapPtr2) \
46 { (ResultPtr)->part0 = (BitmapPtr1)->part0 | (BitmapPtr2)->part0; }
48 #define BitmapAnd(ResultPtr,BitmapPtr1,BitmapPtr2) \
49 { (ResultPtr)->part0 = (BitmapPtr1)->part0 & (BitmapPtr2)->part0; }
51 #define BitmapNot(ResultPtr,BitmapPtr) \
52 { (ResultPtr)->part0 = ~((BitmapPtr)->part0); }
55 /* Return zero if identical */
56 #define BitmapCmp(BitmapPtr1,BitmapPtr2) \
57 ((BitmapPtr1)->part0 != (BitmapPtr2)->part0)
59 #define BitmapIsZero(BitmapPtr) \
62 #define BitmapIsAllOnes(BitmapPtr) \
63 ((BitmapPtr)->part0 == 0xF)
65 #define BitmapGetBit(BitmapPtr,Bit) \
66 ((BitmapPtr)->part0 & (1 << (Bit)))
68 /* Bit range [0 .. 63] */
69 #define BitmapSetBit(BitmapPtr,Bit) \
70 {(BitmapPtr)->part0 |= (1 << (Bit)); }
72 #define BitmapClearBit(BitmapPtr,Bit) \
73 (BitmapPtr)->part0 &= ~(1 << (Bit));
75 #define BitmapCopy(BitmapDstPtr,BitmapSrcPtr) \
76 { (BitmapDstPtr)->part0 = (BitmapSrcPtr)->part0; }
78 #define BitmapXor(ResultPtr,BitmapPtr1,BitmapPtr2) \
79 { (ResultPtr)->part0 = (BitmapPtr1)->part0 ^ (BitmapPtr2)->part0; }
81 #endif /* __BITMAP_H */