aboutsummaryrefslogtreecommitdiffstats
path: root/src/vppinfra
diff options
context:
space:
mode:
Diffstat (limited to 'src/vppinfra')
-rw-r--r--src/vppinfra/types.h13
-rw-r--r--src/vppinfra/vec_bootstrap.h5
2 files changed, 14 insertions, 4 deletions
diff --git a/src/vppinfra/types.h b/src/vppinfra/types.h
index 42217968dcc..ad85af35ac9 100644
--- a/src/vppinfra/types.h
+++ b/src/vppinfra/types.h
@@ -131,6 +131,9 @@ typedef u32 clib_address_t;
#define CLIB_U32_MAX __UINT32_MAX__
#define CLIB_U64_MAX __UINT64_MAX__
+#define CLIB_F64_MAX __DBL_MAX__
+#define CLIB_F32_MAX __FLT_MAX__
+
#if clib_address_bits == 64
#define CLIB_WORD_MAX CLIB_I64_MAX
#define CLIB_UWORD_MAX CLIB_U64_MAX
@@ -197,11 +200,17 @@ typedef word wordu __attribute__ ((aligned (1), __may_alias__));
typedef uword uwordu __attribute__ ((aligned (1), __may_alias__));
#define foreach_int(__var, ...) \
- for (int __int_array[] = { __VA_ARGS__ }, *__int_ptr = __int_array, \
+ for (int __int_array[] = { __VA_ARGS__, 0 }, *__int_ptr = __int_array, \
__var = *__int_ptr; \
- __int_ptr - ARRAY_LEN (__int_array) < __int_array; \
+ __int_ptr - (ARRAY_LEN (__int_array) - 1) < __int_array; \
__var = *++__int_ptr)
+#define foreach_pointer(__var, ...) \
+ for (void *__ptr_array[] = { __VA_ARGS__, 0 }, **__ptr_ptr = __ptr_array, \
+ *__var = *__ptr_ptr; \
+ __ptr_ptr - (ARRAY_LEN (__ptr_array) - 1) < __ptr_array; \
+ __var = *++__ptr_ptr)
+
#endif /* included_clib_types_h */
/*
diff --git a/src/vppinfra/vec_bootstrap.h b/src/vppinfra/vec_bootstrap.h
index 5c827d4aa5a..5ea7a8003f5 100644
--- a/src/vppinfra/vec_bootstrap.h
+++ b/src/vppinfra/vec_bootstrap.h
@@ -239,8 +239,9 @@ _vec_set_len (void *v, uword len, uword elt_sz)
for ((var) = vec_len ((v)) - 1; (var) >= 0; (var)--)
#define vec_foreach_pointer(e, v) \
- for (typeof (**v) **__ep = (v), *(e) = *__ep; __ep - (v) < vec_len (v); \
- __ep++, (e) = *__ep)
+ if (v) \
+ for (typeof (**v) **__ep = (v), *(e) = *__ep; __ep - (v) < vec_len (v); \
+ __ep++, (e) = *__ep)
#endif /* included_clib_vec_bootstrap_h */