Skip to content

Commit ba46b35

Browse files
committed
Dont assume a size for constants with UL and ULL.
According to Section 6.4.4.1 of the C, we do not need to prepend a type to a constant to get the right size. The compiler will infer the type according to the number of bits in the constant. Signed-off-by: George Bosilca <[email protected]>
1 parent 2941147 commit ba46b35

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

opal/class/opal_pointer_array.c

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ static void opal_pointer_array_destruct(opal_pointer_array_t *array)
8787
* A classical find first zero bit (ffs) on a large array. It checks starting
8888
* from the indicated position until it finds a zero bit. If SET is true,
8989
* the bit is set. The position of the bit is returned in store.
90+
*
91+
* According to Section 6.4.4.1 of the C standard we don't need to prepend a type
92+
* indicator to constants (the type is inferred by the compiler according to
93+
* the number of bits necessary to represent it).
9094
*/
9195
#define FIND_FIRST_ZERO(START_IDX, STORE) \
9296
do { \
@@ -96,27 +100,27 @@ static void opal_pointer_array_destruct(opal_pointer_array_t *array)
96100
break; \
97101
} \
98102
GET_BIT_POS((START_IDX), __b_idx, __b_pos); \
99-
for (; table->free_bits[__b_idx] == 0xFFFFFFFFFFFFFFFFULL; __b_idx++); \
103+
for (; table->free_bits[__b_idx] == 0xFFFFFFFFFFFFFFFFu; __b_idx++); \
100104
assert(__b_idx < (uint32_t)table->size); \
101105
uint64_t __check_value = table->free_bits[__b_idx]; \
102106
__b_pos = 0; \
103107
\
104-
if( 0x00000000FFFFFFFFULL == (__check_value & 0x00000000FFFFFFFFULL) ) { \
108+
if( 0x00000000FFFFFFFFu == (__check_value & 0x00000000FFFFFFFFu) ) { \
105109
__check_value >>= 32; __b_pos += 32; \
106110
} \
107-
if( 0x000000000000FFFFULL == (__check_value & 0x000000000000FFFFULL) ) { \
111+
if( 0x000000000000FFFFu == (__check_value & 0x000000000000FFFFu) ) { \
108112
__check_value >>= 16; __b_pos += 16; \
109113
} \
110-
if( 0x00000000000000FFULL == (__check_value & 0x00000000000000FFULL) ) { \
114+
if( 0x00000000000000FFu == (__check_value & 0x00000000000000FFu) ) { \
111115
__check_value >>= 8; __b_pos += 8; \
112116
} \
113-
if( 0x000000000000000FULL == (__check_value & 0x000000000000000FULL) ) { \
117+
if( 0x000000000000000Fu == (__check_value & 0x000000000000000Fu) ) { \
114118
__check_value >>= 4; __b_pos += 4; \
115119
} \
116-
if( 0x0000000000000003ULL == (__check_value & 0x0000000000000003ULL) ) { \
120+
if( 0x0000000000000003u == (__check_value & 0x0000000000000003u) ) { \
117121
__check_value >>= 2; __b_pos += 2; \
118122
} \
119-
if( 0x0000000000000001ULL == (__check_value & 0x0000000000000001ULL) ) { \
123+
if( 0x0000000000000001u == (__check_value & 0x0000000000000001u) ) { \
120124
__b_pos += 1; \
121125
} \
122126
(STORE) = (__b_idx * 8 * sizeof(uint64_t)) + __b_pos; \
@@ -129,8 +133,8 @@ static void opal_pointer_array_destruct(opal_pointer_array_t *array)
129133
do { \
130134
uint32_t __b_idx, __b_pos; \
131135
GET_BIT_POS((IDX), __b_idx, __b_pos); \
132-
assert( 0 == (table->free_bits[__b_idx] & (1UL << __b_pos))); \
133-
table->free_bits[__b_idx] |= (1ULL << __b_pos); \
136+
assert( 0 == (table->free_bits[__b_idx] & (((uint64_t)1) << __b_pos))); \
137+
table->free_bits[__b_idx] |= (((uint64_t)1) << __b_pos); \
134138
} while(0)
135139

136140
/**
@@ -140,8 +144,8 @@ static void opal_pointer_array_destruct(opal_pointer_array_t *array)
140144
do { \
141145
uint32_t __b_idx, __b_pos; \
142146
GET_BIT_POS((IDX), __b_idx, __b_pos); \
143-
assert( (table->free_bits[__b_idx] & (1UL << __b_pos))); \
144-
table->free_bits[__b_idx] ^= (1ULL << __b_pos); \
147+
assert( (table->free_bits[__b_idx] & (((uint64_t)1) << __b_pos))); \
148+
table->free_bits[__b_idx] ^= (((uint64_t)1) << __b_pos); \
145149
} while(0)
146150

147151
#if 0
@@ -159,9 +163,9 @@ static void opal_pointer_array_validate(opal_pointer_array_t *array)
159163
GET_BIT_POS(i, b_idx, p_idx);
160164
if( NULL == array->addr[i] ) {
161165
cnt++;
162-
assert( 0 == (array->free_bits[b_idx] & (1ULL << p_idx)) );
166+
assert( 0 == (array->free_bits[b_idx] & (((uint64_t)1) << p_idx)) );
163167
} else {
164-
assert( 0 != (array->free_bits[b_idx] & (1ULL << p_idx)) );
168+
assert( 0 != (array->free_bits[b_idx] & (((uint64_t)1) << p_idx)) );
165169
}
166170
}
167171
assert(cnt == array->number_free);

0 commit comments

Comments
 (0)