]>
Commit | Line | Data |
---|---|---|
ad02a0eb SH |
1 | /************************************************************************ |
2 | * RSTP library - Rapid Spanning Tree (802.1t, 802.1w) | |
3 | * Copyright (C) 2001-2003 Optical Access | |
4 | * Author: Alex Rozin | |
5 | * | |
6 | * This file is part of RSTP library. | |
7 | * | |
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 | |
11 | * | |
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. | |
16 | * | |
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 | |
20 | * 02111-1307, USA. | |
21 | **********************************************************************/ | |
22 | ||
23 | #ifndef __BITMAP_H | |
24 | #define __BITMAP_H | |
25 | ||
26 | #define NUMBER_OF_PORTS 4 | |
27 | ||
28 | typedef struct tagBITMAP | |
29 | { | |
30 | unsigned long part0; /* Least Significant part */ | |
31 | } BITMAP_T; | |
32 | ||
33 | #define BitmapClear(BitmapPtr) \ | |
34 | { (BitmapPtr)->part0 = 0; } | |
35 | ||
36 | #define BitmapSetAllBits(BitmapPtr) \ | |
37 | { (BitmapPtr)->part0 = 0xF; } | |
38 | ||
39 | #define BitmapClearBits(BitmapPtr,BitmapBitsPtr) \ | |
40 | { (BitmapPtr)->part0 &= ~((BitmapBitsPtr)->part0); } | |
41 | ||
42 | #define BitmapSetBits(BitmapPtr,BitmapBitsPtr) \ | |
43 | { (BitmapPtr)->part0 |= ((BitmapBitsPtr)->part0); } | |
44 | ||
45 | #define BitmapOr(ResultPtr,BitmapPtr1,BitmapPtr2) \ | |
46 | { (ResultPtr)->part0 = (BitmapPtr1)->part0 | (BitmapPtr2)->part0; } | |
47 | ||
48 | #define BitmapAnd(ResultPtr,BitmapPtr1,BitmapPtr2) \ | |
49 | { (ResultPtr)->part0 = (BitmapPtr1)->part0 & (BitmapPtr2)->part0; } | |
50 | ||
51 | #define BitmapNot(ResultPtr,BitmapPtr) \ | |
52 | { (ResultPtr)->part0 = ~((BitmapPtr)->part0); } | |
53 | ||
54 | ||
55 | /* Return zero if identical */ | |
56 | #define BitmapCmp(BitmapPtr1,BitmapPtr2) \ | |
57 | ((BitmapPtr1)->part0 != (BitmapPtr2)->part0) | |
58 | ||
59 | #define BitmapIsZero(BitmapPtr) \ | |
60 | (!(BitmapPtr)->part0) | |
61 | ||
62 | #define BitmapIsAllOnes(BitmapPtr) \ | |
63 | ((BitmapPtr)->part0 == 0xF) | |
64 | ||
65 | #define BitmapGetBit(BitmapPtr,Bit) \ | |
66 | ((BitmapPtr)->part0 & (1 << (Bit))) | |
67 | ||
68 | /* Bit range [0 .. 63] */ | |
69 | #define BitmapSetBit(BitmapPtr,Bit) \ | |
70 | {(BitmapPtr)->part0 |= (1 << (Bit)); } | |
71 | ||
72 | #define BitmapClearBit(BitmapPtr,Bit) \ | |
73 | (BitmapPtr)->part0 &= ~(1 << (Bit)); | |
74 | ||
75 | #define BitmapCopy(BitmapDstPtr,BitmapSrcPtr) \ | |
76 | { (BitmapDstPtr)->part0 = (BitmapSrcPtr)->part0; } | |
77 | ||
78 | #define BitmapXor(ResultPtr,BitmapPtr1,BitmapPtr2) \ | |
79 | { (ResultPtr)->part0 = (BitmapPtr1)->part0 ^ (BitmapPtr2)->part0; } | |
80 | ||
81 | #endif /* __BITMAP_H */ | |
82 |