22#ifndef __LINUX_OVERFLOW_H
33#define __LINUX_OVERFLOW_H
44
5- #include <linux/compiler.h>
5+ #include <stddef.h>
6+ #include <stdint.h>
67
78/*
89 * In the fallback code below, we need to compute the minimum and
122123 * we must provide a result in *d, and in fact we must produce the
123124 * result promised by gcc's builtins, which is simply the possibly
124125 * 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
126127 * 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.
128129 */
129130
130131/*
138139 typeof(d) __d = (d); \
139140 (void) (&__a == &__b); \
140141 (void) (&__a == __d); \
141- *__d = (u64 )__a + (u64 )__b; \
142+ *__d = (uint64_t )__a + (uint64_t )__b; \
142143 (((~(__a ^ __b)) & (*__d ^ __a)) \
143144 & type_min(typeof(__a))) != 0; \
144145})
154155 typeof(d) __d = (d); \
155156 (void) (&__a == &__b); \
156157 (void) (&__a == __d); \
157- *__d = (u64 )__a - (u64 )__b; \
158+ *__d = (uint64_t )__a - (uint64_t )__b; \
158159 ((((__a ^ __b)) & (*__d ^ __a)) \
159160 & type_min(typeof(__a))) != 0; \
160161})
183184 typeof(a) __tmin = type_min(typeof(a)); \
184185 (void) (&__a == &__b); \
185186 (void) (&__a == __d); \
186- *__d = (u64 )__a * (u64 )__b; \
187+ *__d = (uint64_t )__a * (uint64_t )__b; \
187188 (__b > 0 && (__a > __tmax/__b || __a < __tmin/__b)) || \
188189 (__b < (typeof(__b))-1 && (__a > __tmin/__b || __a < __tmax/__b)) || \
189190 (__b == (typeof(__b))-1 && __a == __tmin); \
231232 typeof(a) _a = a; \
232233 typeof(s) _s = s; \
233234 typeof(d) _d = d; \
234- u64 _a_full = _a; \
235+ uint64_t _a_full = _a; \
235236 unsigned int _to_shift = \
236237 is_non_negative(_s) && _s < 8 * sizeof(*d) ? _s : 0; \
237238 *_d = (_a_full << _to_shift); \
238239 (_to_shift != _s || is_negative(*_d) || is_negative(_a) || \
239240 (*_d >> _to_shift) != _a); \
240241})
241242
243+ /*
244+ * Disabling for EC since we don't currently have SIZE_MAX defined in our
245+ * stdint.h.
246+ */
247+ #if 0
242248/**
243249 * array_size() - Calculate size of 2-dimensional array.
244250 *
250256 * Returns: number of bytes needed to represent the array or SIZE_MAX on
251257 * overflow.
252258 */
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 )
254260{
255261 size_t bytes ;
256262
@@ -272,7 +278,7 @@ static inline __must_check size_t array_size(size_t a, size_t b)
272278 * Returns: number of bytes needed to represent the array or SIZE_MAX on
273279 * overflow.
274280 */
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 )
276282{
277283 size_t bytes ;
278284
@@ -288,7 +294,7 @@ static inline __must_check size_t array3_size(size_t a, size_t b, size_t c)
288294 * Compute a*b+c, returning SIZE_MAX on overflow. Internal helper for
289295 * struct_size() below.
290296 */
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 )
292298{
293299 size_t bytes ;
294300
@@ -299,6 +305,7 @@ static inline __must_check size_t __ab_c_size(size_t a, size_t b, size_t c)
299305
300306 return bytes ;
301307}
308+ #endif
302309
303310/**
304311 * struct_size() - Calculate size of structure with trailing array.
0 commit comments