2
2
#ifndef __LINUX_OVERFLOW_H
3
3
#define __LINUX_OVERFLOW_H
4
4
5
- #include <linux/compiler.h>
5
+ #include <stddef.h>
6
+ #include <stdint.h>
6
7
7
8
/*
8
9
* In the fallback code below, we need to compute the minimum and
122
123
* we must provide a result in *d, and in fact we must produce the
123
124
* result promised by gcc's builtins, which is simply the possibly
124
125
* wrapped-around value. Fortunately, we can just formally do the
125
- * operations in the widest relevant unsigned type (u64 ) and then
126
+ * operations in the widest relevant unsigned type (uint64_t ) and then
126
127
* truncate the result - gcc is smart enough to generate the same code
127
- * with and without the (u64 ) casts.
128
+ * with and without the (uint64_t ) casts.
128
129
*/
129
130
130
131
/*
138
139
typeof(d) __d = (d); \
139
140
(void) (&__a == &__b); \
140
141
(void) (&__a == __d); \
141
- *__d = (u64 )__a + (u64 )__b; \
142
+ *__d = (uint64_t )__a + (uint64_t )__b; \
142
143
(((~(__a ^ __b)) & (*__d ^ __a)) \
143
144
& type_min(typeof(__a))) != 0; \
144
145
})
154
155
typeof(d) __d = (d); \
155
156
(void) (&__a == &__b); \
156
157
(void) (&__a == __d); \
157
- *__d = (u64 )__a - (u64 )__b; \
158
+ *__d = (uint64_t )__a - (uint64_t )__b; \
158
159
((((__a ^ __b)) & (*__d ^ __a)) \
159
160
& type_min(typeof(__a))) != 0; \
160
161
})
183
184
typeof(a) __tmin = type_min(typeof(a)); \
184
185
(void) (&__a == &__b); \
185
186
(void) (&__a == __d); \
186
- *__d = (u64 )__a * (u64 )__b; \
187
+ *__d = (uint64_t )__a * (uint64_t )__b; \
187
188
(__b > 0 && (__a > __tmax/__b || __a < __tmin/__b)) || \
188
189
(__b < (typeof(__b))-1 && (__a > __tmin/__b || __a < __tmax/__b)) || \
189
190
(__b == (typeof(__b))-1 && __a == __tmin); \
231
232
typeof(a) _a = a; \
232
233
typeof(s) _s = s; \
233
234
typeof(d) _d = d; \
234
- u64 _a_full = _a; \
235
+ uint64_t _a_full = _a; \
235
236
unsigned int _to_shift = \
236
237
is_non_negative(_s) && _s < 8 * sizeof(*d) ? _s : 0; \
237
238
*_d = (_a_full << _to_shift); \
238
239
(_to_shift != _s || is_negative(*_d) || is_negative(_a) || \
239
240
(*_d >> _to_shift) != _a); \
240
241
})
241
242
243
+ /*
244
+ * Disabling for EC since we don't currently have SIZE_MAX defined in our
245
+ * stdint.h.
246
+ */
247
+ #if 0
242
248
/**
243
249
* array_size() - Calculate size of 2-dimensional array.
244
250
*
250
256
* Returns: number of bytes needed to represent the array or SIZE_MAX on
251
257
* overflow.
252
258
*/
253
- static inline __must_check size_t array_size (size_t a , size_t b )
259
+ static inline /* __must_check*/ size_t array_size (size_t a , size_t b )
254
260
{
255
261
size_t bytes ;
256
262
@@ -272,7 +278,7 @@ static inline __must_check size_t array_size(size_t a, size_t b)
272
278
* Returns: number of bytes needed to represent the array or SIZE_MAX on
273
279
* overflow.
274
280
*/
275
- static inline __must_check size_t array3_size (size_t a , size_t b , size_t c )
281
+ static inline /* __must_check*/ size_t array3_size (size_t a , size_t b , size_t c )
276
282
{
277
283
size_t bytes ;
278
284
@@ -288,7 +294,7 @@ static inline __must_check size_t array3_size(size_t a, size_t b, size_t c)
288
294
* Compute a*b+c, returning SIZE_MAX on overflow. Internal helper for
289
295
* struct_size() below.
290
296
*/
291
- static inline __must_check size_t __ab_c_size (size_t a , size_t b , size_t c )
297
+ static inline /* __must_check*/ size_t __ab_c_size (size_t a , size_t b , size_t c )
292
298
{
293
299
size_t bytes ;
294
300
@@ -299,6 +305,7 @@ static inline __must_check size_t __ab_c_size(size_t a, size_t b, size_t c)
299
305
300
306
return bytes ;
301
307
}
308
+ #endif
302
309
303
310
/**
304
311
* struct_size() - Calculate size of structure with trailing array.
0 commit comments