@@ -118,35 +118,37 @@ BSON_CMP_SET (greater_equal,
118
118
#undef BSON_CMP_SET
119
119
120
120
121
- /* Define in_range functions for *signed* type Type. */
122
- #define BSON_IN_RANGE_SET_SIGNED (Type , min , max ) \
123
- static BSON_INLINE bool BSON_CONCAT3 (bson_in_range_, Type, _signed) ( \
124
- int64_t value) \
125
- { \
126
- return bson_cmp_greater_equal_ss (value, min) && \
127
- bson_cmp_less_equal_ss (value, max); \
128
- } \
129
- \
130
- static BSON_INLINE bool BSON_CONCAT3 (bson_in_range_, Type, _unsigned) ( \
131
- uint64_t value) \
132
- { \
133
- return bson_cmp_greater_equal_us (value, min) && \
134
- bson_cmp_less_equal_us (value, max); \
121
+ /* Return true if the given value is within the range of the corresponding
122
+ * signed type. The suffix must match the signedness of the given value. */
123
+ #define BSON_IN_RANGE_SET_SIGNED (Type , min , max ) \
124
+ static BSON_INLINE bool BSON_CONCAT3 (bson_in_range, _##Type, _signed) ( \
125
+ int64_t value) \
126
+ { \
127
+ return bson_cmp_greater_equal_ss (value, min) && \
128
+ bson_cmp_less_equal_ss (value, max); \
129
+ } \
130
+ \
131
+ static BSON_INLINE bool BSON_CONCAT3 (bson_in_range, _##Type, _unsigned) ( \
132
+ uint64_t value) \
133
+ { \
134
+ return bson_cmp_greater_equal_us (value, min) && \
135
+ bson_cmp_less_equal_us (value, max); \
135
136
}
136
137
137
- /* Define in_range functions for *unsigned* type Type. */
138
- #define BSON_IN_RANGE_SET_UNSIGNED (Type , max ) \
139
- static BSON_INLINE bool BSON_CONCAT3 (bson_in_range_, Type, _signed) ( \
140
- int64_t value) \
141
- { \
142
- return bson_cmp_greater_equal_su (value, 0u) && \
143
- bson_cmp_less_equal_su (value, max); \
144
- } \
145
- \
146
- static BSON_INLINE bool BSON_CONCAT3 (bson_in_range_, Type, _unsigned) ( \
147
- uint64_t value) \
148
- { \
149
- return bson_cmp_less_equal_uu (value, max); \
138
+ /* Return true if the given value is within the range of the corresponding
139
+ * unsigned type. The suffix must match the signedness of the given value. */
140
+ #define BSON_IN_RANGE_SET_UNSIGNED (Type , max ) \
141
+ static BSON_INLINE bool BSON_CONCAT3 (bson_in_range, _##Type, _signed) ( \
142
+ int64_t value) \
143
+ { \
144
+ return bson_cmp_greater_equal_su (value, 0u) && \
145
+ bson_cmp_less_equal_su (value, max); \
146
+ } \
147
+ \
148
+ static BSON_INLINE bool BSON_CONCAT3 (bson_in_range, _##Type, _unsigned) ( \
149
+ uint64_t value) \
150
+ { \
151
+ return bson_cmp_less_equal_uu (value, max); \
150
152
}
151
153
152
154
BSON_IN_RANGE_SET_SIGNED (signed_char , SCHAR_MIN , SCHAR_MAX )
@@ -181,12 +183,12 @@ BSON_IN_RANGE_SET_UNSIGNED (size_t, SIZE_MAX)
181
183
/* Return true if the value with *signed* type is in the representable range of
182
184
* Type and false otherwise. */
183
185
#define bson_in_range_signed (Type , value ) \
184
- BSON_CONCAT3 (bson_in_range_, Type, _signed) (value)
186
+ BSON_CONCAT3 (bson_in_range, _## Type, _signed) (value)
185
187
186
188
/* Return true if the value with *unsigned* type is in the representable range
187
189
* of Type and false otherwise. */
188
190
#define bson_in_range_unsigned (Type , value ) \
189
- BSON_CONCAT3 (bson_in_range_, Type, _unsigned) (value)
191
+ BSON_CONCAT3 (bson_in_range, _## Type, _unsigned) (value)
190
192
191
193
192
194
BSON_END_DECLS
0 commit comments