diff options
Diffstat (limited to 'libnetdata')
-rw-r--r-- | libnetdata/buffer/buffer.c | 4 | ||||
-rw-r--r-- | libnetdata/buffer/buffer.h | 4 | ||||
-rw-r--r-- | libnetdata/config/appconfig.c | 4 | ||||
-rw-r--r-- | libnetdata/libnetdata.h | 99 |
4 files changed, 88 insertions, 23 deletions
diff --git a/libnetdata/buffer/buffer.c b/libnetdata/buffer/buffer.c index 91bc4dd602..8d80c9fe0e 100644 --- a/libnetdata/buffer/buffer.c +++ b/libnetdata/buffer/buffer.c @@ -315,6 +315,8 @@ void buffer_json_initialize(BUFFER *wb, const char *key_quote, const char *value if(add_anonymous_object) buffer_fast_strcat(wb, "{", 1); + + wb->content_type = CT_APPLICATION_JSON; } void buffer_json_finalize(BUFFER *wb) { @@ -503,7 +505,7 @@ int buffer_unittest(void) { return errors; } -#ifdef ENABLE_HTTPD +#ifdef ENABLE_H2O h2o_iovec_t buffer_to_h2o_iovec(BUFFER *wb) { h2o_iovec_t ret; ret.base = wb->buffer; diff --git a/libnetdata/buffer/buffer.h b/libnetdata/buffer/buffer.h index 17a7b378c1..d5adabd42a 100644 --- a/libnetdata/buffer/buffer.h +++ b/libnetdata/buffer/buffer.h @@ -6,7 +6,7 @@ #include "../string/utf8.h" #include "../libnetdata.h" -#ifdef ENABLE_HTTPD +#ifdef ENABLE_H2O #include "h2o/memory.h" #endif @@ -133,7 +133,7 @@ void buffer_char_replace(BUFFER *wb, char from, char to); void buffer_print_sn_flags(BUFFER *wb, SN_FLAGS flags, bool send_anomaly_bit); -#ifdef ENABLE_HTTPD +#ifdef ENABLE_H2O h2o_iovec_t buffer_to_h2o_iovec(BUFFER *wb); #endif diff --git a/libnetdata/config/appconfig.c b/libnetdata/config/appconfig.c index 37b8d7c7d0..adca337614 100644 --- a/libnetdata/config/appconfig.c +++ b/libnetdata/config/appconfig.c @@ -518,9 +518,9 @@ int appconfig_get_boolean_ondemand(struct config *root, const char *section, con s = appconfig_get(root, section, name, s); if(!s) return value; - if(!strcmp(s, "yes")) + if(!strcmp(s, "yes") || !strcmp(s, "true") || !strcmp(s, "on")) return CONFIG_BOOLEAN_YES; - else if(!strcmp(s, "no")) + else if(!strcmp(s, "no") || !strcmp(s, "false") || !strcmp(s, "off")) return CONFIG_BOOLEAN_NO; else if(!strcmp(s, "auto") || !strcmp(s, "on demand")) return CONFIG_BOOLEAN_AUTO; diff --git a/libnetdata/libnetdata.h b/libnetdata/libnetdata.h index 80a0026896..8d87745f22 100644 --- a/libnetdata/libnetdata.h +++ b/libnetdata/libnetdata.h @@ -11,6 +11,21 @@ extern "C" { #include <config.h> #endif +#ifdef ENABLE_LZ4 +#define ENABLE_RRDPUSH_COMPRESSION 1 +#endif + +#ifdef ENABLE_OPENSSL +#define ENABLE_HTTPS 1 +#endif + +#ifdef HAVE_LIBDATACHANNEL +#define ENABLE_WEBRTC 1 +#endif + +#define STRINGIFY(x) #x +#define TOSTRING(x) STRINGIFY(x) + #define JUDYHS_INDEX_SIZE_ESTIMATE(key_bytes) (((key_bytes) + sizeof(Word_t) - 1) / sizeof(Word_t) * 4) #if defined(NETDATA_DEV_MODE) && !defined(NETDATA_INTERNAL_CHECKS) @@ -592,32 +607,80 @@ char *find_and_replace(const char *src, const char *find, const char *replace, c #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) #ifdef ENV32BIT + +typedef struct bitmapX { + uint32_t bits; + uint32_t data[]; +} BITMAPX; + typedef struct bitmap256 { - uint32_t data[8]; + uint32_t bits; + uint32_t data[256 / 32]; } BITMAP256; -#define bitmap256_get_bit(ptr, idx) (((ptr)->data[(idx) >> 5] & (1ULL << ((idx) & 31))) != 0) -static inline void bitmap256_set_bit(BITMAP256 *ptr, uint8_t idx, bool value) { - uint32_t mask = 1U << (idx & 31); - if (value) - ptr->data[idx >> 5] |= mask; - else - ptr->data[idx >> 5] &= ~mask; +typedef struct bitmap1024 { + uint32_t bits; + uint32_t data[1024 / 32]; +} BITMAP1024; + +static inline BITMAPX *bitmapX_create(uint32_t bits) { + BITMAPX *bmp = (BITMAPX *)callocz(1, sizeof(BITMAPX) + sizeof(uint32_t) * ((bits + 31) / 32)); + uint32_t *p = (uint32_t *)&bmp->bits; + *p = bits; + return bmp; } -#else // 64bit + +#define bitmapX_get_bit(ptr, idx) ((ptr)->data[(idx) >> 5] & (1U << ((idx) & 31))) +#define bitmapX_set_bit(ptr, idx, value) do { \ + register uint32_t _bitmask = 1U << ((idx) & 31); \ + if (value) \ + (ptr)->data[(idx) >> 5] |= _bitmask; \ + else \ + (ptr)->data[(idx) >> 5] &= ~_bitmask; \ +} while(0) + +#else // 64bit version of bitmaps + +typedef struct bitmapX { + uint32_t bits; + uint64_t data[]; +} BITMAPX; + typedef struct bitmap256 { - uint64_t data[4]; + uint32_t bits; + uint64_t data[256 / 64]; } BITMAP256; -#define bitmap256_get_bit(ptr, idx) ((ptr)->data[(idx) >> 6] & (1ULL << ((idx) & 63))) -static inline void bitmap256_set_bit(BITMAP256 *ptr, uint8_t idx, bool value) { - uint64_t mask = 1ULL << (idx & 63); - if (value) - ptr->data[idx >> 6] |= mask; - else - ptr->data[idx >> 6] &= ~mask; +typedef struct bitmap1024 { + uint32_t bits; + uint64_t data[1024 / 64]; +} BITMAP1024; + +static inline BITMAPX *bitmapX_create(uint32_t bits) { + BITMAPX *bmp = (BITMAPX *)callocz(1, sizeof(BITMAPX) + sizeof(uint64_t) * ((bits + 63) / 64)); + bmp->bits = bits; + return bmp; } -#endif // 64bit + +#define bitmapX_get_bit(ptr, idx) ((ptr)->data[(idx) >> 6] & (1ULL << ((idx) & 63))) +#define bitmapX_set_bit(ptr, idx, value) do { \ + register uint64_t _bitmask = 1ULL << ((idx) & 63); \ + if (value) \ + (ptr)->data[(idx) >> 6] |= _bitmask; \ + else \ + (ptr)->data[(idx) >> 6] &= ~_bitmask; \ +} while(0) + +#endif // 64bit version of bitmaps + +#define BITMAPX_INITIALIZER(wanted_bits) { .bits = (wanted_bits), .data = {0} } +#define BITMAP256_INITIALIZER (BITMAP256)BITMAPX_INITIALIZER(256) +#define BITMAP1024_INITIALIZER (BITMAP1024)BITMAPX_INITIALIZER(1024) +#define bitmap256_get_bit(ptr, idx) bitmapX_get_bit((BITMAPX *)ptr, idx) +#define bitmap256_set_bit(ptr, idx, value) bitmapX_set_bit((BITMAPX *)ptr, idx, value) +#define bitmap1024_get_bit(ptr, idx) bitmapX_get_bit((BITMAPX *)ptr, idx) +#define bitmap1024_set_bit(ptr, idx, value) bitmapX_set_bit((BITMAPX *)ptr, idx, value) + #define COMPRESSION_MAX_MSG_SIZE 0x4000 #define PLUGINSD_LINE_MAX (COMPRESSION_MAX_MSG_SIZE - 1024) |