1 /* Copyright (c) 2003, 2005 MySQL AB
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; version 2 of the License.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
16 #ifndef NODE_BITMASK_HPP
17 #define NODE_BITMASK_HPP
19 #include <ndb_limits.h>
20 #include <kernel_types.h>
21 #include <Bitmask.hpp>
24 * No of 32 bits words needed to store a node bitmask
25 * containing all the nodes in the system
26 * Both NDB nodes and API, MGM... nodes
28 * Note that this is used in a lot of signals
30 #define _NODE_BITMASK_SIZE 2
33 * No of 32 bits words needed to store a node bitmask
34 * containing all the ndb nodes in the system
36 * Note that this is used in a lot of signals
38 #define _NDB_NODE_BITMASK_SIZE 2
41 * No of 32 bits word needed to store B bits for N nodes
43 #define NODE_ARRAY_SIZE(N, B) (((N)*(B)+31) >> 5)
45 typedef Bitmask
<(unsigned int)_NODE_BITMASK_SIZE
> NodeBitmask
;
47 typedef Bitmask
<(unsigned int)_NDB_NODE_BITMASK_SIZE
> NdbNodeBitmask
;
49 #define __NBM_SZ ((MAX_NODES >> 5) + ((MAX_NODES & 31) != 0))
50 #define __NNBM_SZ ((MAX_NDB_NODES >> 5) + ((MAX_NDB_NODES & 31) != 0))
52 #if ( __NBM_SZ > _NODE_BITMASK_SIZE)
53 #error "MAX_NODES can not fit into NODE_BITMASK_SIZE"
56 #if ( __NNBM_SZ > _NDB_NODE_BITMASK_SIZE)
57 #error "MAX_NDB_NODES can not fit into NDB_NODE_BITMASK_SIZE"
61 * General B Bits operations
66 * return (A[w] >> s) & S4
73 * A[w] = t | ((v & S4) << s)