From e1dbbf7e8e0b2d5101aa4e06d90f82cfab5087d2 Mon Sep 17 00:00:00 2001 From: Mauro Sardara Date: Mon, 11 Mar 2019 19:19:15 +0100 Subject: [HICN-106] Added generation of .lib for dll shared libraries fixed warning for shift in csum_fold function in libhicn added declaration of external symbol in libtransport log. Change-Id: I9377eb6016a74f14eb8f05df2ced36ee41a27bfd Signed-off-by: Mauro Sardara --- lib/src/common.h | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'lib/src/common.h') diff --git a/lib/src/common.h b/lib/src/common.h index 1d4b1e6bf..33323da1b 100644 --- a/lib/src/common.h +++ b/lib/src/common.h @@ -60,6 +60,28 @@ typedef uint8_t u8; #define STATIC_ASSERT(x) +/* Architecture-dependent uword size */ +#if INTPTR_MAX == INT64_MAX +#define log2_uword_bits 6 +#elif INTPTR_MAX == INT32_MAX +#define log2_uword_bits 5 +#else +#error "Impossible to detect architecture" +#endif + +#define uword_bits (1 << log2_uword_bits) + +/* Word types. */ +#if uword_bits == 64 +/* 64 bit word machines. */ +typedef u64 uword; +#else +/* 32 bit word machines. */ +typedef u32 uword; +#endif + +typedef uword ip_csum_t; + #endif /* ! HICN_VPP_PLUGIN */ /* @@ -173,8 +195,6 @@ int get_addr_family (const char *ip_address); #ifndef HICN_VPP_PLUGIN -typedef u16 ip_csum_t; - /* * Checksum update (incremental and non-incremental) * @@ -186,7 +206,7 @@ static_always_inline u16 ip_csum_fold (ip_csum_t c) { /* Reduce to 16 bits. */ -#if 0 // uword_bits == 64 +#if uword_bits == 64 c = (c & (ip_csum_t) 0xffffffff) + (c >> (ip_csum_t) 32); c = (c & 0xffff) + (c >> 16); #endif @@ -194,7 +214,7 @@ ip_csum_fold (ip_csum_t c) c = (c & 0xffff) + (c >> 16); c = (c & 0xffff) + (c >> 16); - return c; + return (u16)c; } static_always_inline ip_csum_t -- cgit 1.2.3-korg