From 38c619115b0399bae8b0dcf66e57e623cc50809c Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Tue, 17 Oct 2023 16:06:26 +0000 Subject: dev: new device driver infra Type: feature Change-Id: I20c56e0d3103624407f18365c2bc1273dea5c199 Signed-off-by: Damjan Marion --- src/vppinfra/types.h | 13 +++++++++++-- src/vppinfra/vec_bootstrap.h | 5 +++-- 2 files changed, 14 insertions(+), 4 deletions(-) (limited to 'src/vppinfra') 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 */ -- cgit 1.2.3-korg