aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Deri <deri@ntop.org>2021-09-27 12:41:40 +0200
committerLuca Deri <deri@ntop.org>2021-09-27 12:41:40 +0200
commitb9ccff0761532b65a26edb1f7ac9f80c3ff58aa1 (patch)
tree5e02a40a6ef403653fd0c0a4a0a6d2c9387ca1cd
parent241ee32cbc283360fe7882b5d8f8dde1d3ed2640 (diff)
Compilation fixed on CentOS 7
Bitmap APi changes
-rw-r--r--src/include/ndpi_api.h.in8
-rw-r--r--src/include/ndpi_typedefs.h1
-rw-r--r--src/lib/ndpi_bitmap.c11
-rw-r--r--src/lib/third_party/src/roaring.cc21
4 files changed, 29 insertions, 12 deletions
diff --git a/src/include/ndpi_api.h.in b/src/include/ndpi_api.h.in
index 0af2113fe..53f389297 100644
--- a/src/include/ndpi_api.h.in
+++ b/src/include/ndpi_api.h.in
@@ -1618,9 +1618,17 @@ extern "C" {
void ndpi_bitmap_unset(ndpi_bitmap* b, u_int32_t value);
bool ndpi_bitmap_isset(ndpi_bitmap* b, u_int32_t value);
void ndpi_bitmap_clear(ndpi_bitmap* b);
+
size_t ndpi_bitmap_serialize(ndpi_bitmap* b, char **buf);
ndpi_bitmap* ndpi_bitmap_deserialize(char *buf);
+ void ndpi_bitmap_and(ndpi_bitmap* a, ndpi_bitmap* b_and);
+ void ndpi_bitmap_or(ndpi_bitmap* a, ndpi_bitmap* b_or);
+
+ ndpi_bitmap_iterator* ndpi_bitmap_iterator_alloc(ndpi_bitmap* b);
+ void ndpi_bitmap_iterator_free(ndpi_bitmap* b);
+ bool ndpi_bitmap_iterator_next(ndpi_bitmap_iterator* i, uint32_t *value);
+
/* ******************************* */
#ifdef __cplusplus
diff --git a/src/include/ndpi_typedefs.h b/src/include/ndpi_typedefs.h
index be66f376a..2e1e0c231 100644
--- a/src/include/ndpi_typedefs.h
+++ b/src/include/ndpi_typedefs.h
@@ -1705,6 +1705,7 @@ typedef int (*ndpi_custom_dga_predict_fctn)(const char* domain, int domain_lengt
/* **************************************** */
typedef void ndpi_bitmap;
+typedef void ndpi_bitmap_iterator;
/* **************************************** */
diff --git a/src/lib/ndpi_bitmap.c b/src/lib/ndpi_bitmap.c
index ecb238da7..17ba59b00 100644
--- a/src/lib/ndpi_bitmap.c
+++ b/src/lib/ndpi_bitmap.c
@@ -103,7 +103,7 @@ ndpi_bitmap* ndpi_bitmap_deserialize(char *buf) {
/* ******************************************* */
/* b = b & b_and */
-void ndpi_bitmap_and(ndpi_bitmap* b, ndpi_bitmap* b_and) {
+void ndpi_bitmap_and(ndpi_bitmap* a, ndpi_bitmap* b_and) {
roaring_bitmap_and_inplace((ndpi_bitmap*)a, (ndpi_bitmap*)b_and);
}
@@ -116,20 +116,13 @@ void ndpi_bitmap_or(ndpi_bitmap* a, ndpi_bitmap* b_or) {
/* ******************************************* */
-/* b = b | b_or */
-void ndpi_bitmap_or(ndpi_bitmap* a, ndpi_bitmap* b_or) {
- roaring_bitmap_or_inplace((ndpi_bitmap*)a, (ndpi_bitmap*)b_or);
-}
-
-/* ******************************************* */
-
ndpi_bitmap_iterator* ndpi_bitmap_iterator_alloc(ndpi_bitmap* b) {
return(roaring_create_iterator((ndpi_bitmap*)b));
}
/* ******************************************* */
-ndpi_bitmap_iterator* ndpi_bitmap_iterator_free(ndpi_bitmap* b) {
+void ndpi_bitmap_iterator_free(ndpi_bitmap* b) {
return(roaring_free_uint32_iterator((ndpi_bitmap*)b));
}
diff --git a/src/lib/third_party/src/roaring.cc b/src/lib/third_party/src/roaring.cc
index 0ac1eaa13..cee8dd55e 100644
--- a/src/lib/third_party/src/roaring.cc
+++ b/src/lib/third_party/src/roaring.cc
@@ -218,6 +218,14 @@ static inline uint32_t croaring_detect_supported_architectures() {
return buffer;
}
#else // defined(__cplusplus) and defined(_MSC_VER) && !defined(__clang__)
+#if defined(__GNUC_RH_RELEASE__) && (__GNUC_RH_RELEASE__ != 5)
+#define ROARING_DISABLE_AVX
+#undef __AVX2__
+/* CentOS 7 */
+static inline uint32_t croaring_detect_supported_architectures() {
+ return(dynamic_croaring_detect_supported_architectures());
+}
+#else
#include <stdatomic.h>
static inline uint32_t croaring_detect_supported_architectures() {
static _Atomic int buffer = CROARING_UNINITIALIZED;
@@ -226,6 +234,7 @@ static inline uint32_t croaring_detect_supported_architectures() {
}
return buffer;
}
+#endif // defined(__GNUC_RH_RELEASE__) && (__GNUC_RH_RELEASE__ != 5)
#endif // defined(_MSC_VER) && !defined(__clang__)
#ifdef ROARING_DISABLE_AVX
@@ -315,6 +324,12 @@ extern "C" { // portability definitions are in global scope, not a namespace
#undef CROARING_IS_X64
#endif
+#if defined(__GNUC_RH_RELEASE__) && (__GNUC_RH_RELEASE__ != 5 /* RH 8 */)
+ /* RH 7 don't have atomic includes */
+#undef CROARING_IS_X64
+#endif
+
+
#if defined(__clang_major__) && (__clang_major__<= 8) && !defined(__AVX2__)
// Older versions of clang have a bug affecting us
// https://stackoverflow.com/questions/57228537/how-does-one-use-pragma-clang-attribute-push-with-c-namespaces
@@ -7060,14 +7075,14 @@ static inline void tellmeall() {
(long unsigned int)sizeof(size_t),
(long unsigned int)sizeof(int));
}
-#if __LITTLE_ENDIAN__
+#ifdef __LITTLE_ENDIAN__
// This is what we expect!
// printf("you have little endian machine");
#endif
-#if __BIG_ENDIAN__
+#ifdef __BIG_ENDIAN__
printf("you have a big endian machine");
#endif
-#if __CHAR_BIT__
+#ifdef __CHAR_BIT__
if (__CHAR_BIT__ != 8) printf("on your machine, chars don't have 8bits???");
#endif
}