diff options
author | Mauro Sardara <msardara@cisco.com> | 2019-03-11 19:19:15 +0100 |
---|---|---|
committer | Mauro Sardara <msardara@cisco.com> | 2019-03-12 11:04:38 +0100 |
commit | e1dbbf7e8e0b2d5101aa4e06d90f82cfab5087d2 (patch) | |
tree | eb7ecbc11044255e7f0a6508d746024f956fc273 /lib/src/common.h | |
parent | f14470a4e352b15aea76a8c6176c409c595cf534 (diff) |
[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 <msardara@cisco.com>
Diffstat (limited to 'lib/src/common.h')
-rw-r--r-- | lib/src/common.h | 28 |
1 files changed, 24 insertions, 4 deletions
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 |