diff options
author | vkalintiris <vasilis@netdata.cloud> | 2022-02-22 14:24:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-22 14:24:57 +0200 |
commit | 1ce39d11f4d1a4c1dd5d9d46727586b795bbbae5 (patch) | |
tree | 03dc03d4cb54794cfa9da3213ed6ddfabad0de43 /libnetdata/buffer | |
parent | acec96052500ccc2988abfb95cc608ce688dffe4 (diff) |
Remove SIZEOF_VOIDP and ENVIRONMENT{32,64} macros. (#12046)
Diffstat (limited to 'libnetdata/buffer')
-rw-r--r-- | libnetdata/buffer/buffer.c | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/libnetdata/buffer/buffer.c b/libnetdata/buffer/buffer.c index c37da21e18..8ea90985c3 100644 --- a/libnetdata/buffer/buffer.c +++ b/libnetdata/buffer/buffer.c @@ -87,14 +87,19 @@ inline char *print_number_llu_r(char *str, unsigned long long uvalue) { } inline char *print_number_llu_r_smart(char *str, unsigned long long uvalue) { -#ifdef ENVIRONMENT32 - if(uvalue > (unsigned long long)0xffffffff) - str = print_number_llu_r(str, uvalue); - else - str = print_number_lu_r(str, uvalue); -#else - do *str++ = (char)('0' + (uvalue % 10)); while(uvalue /= 10); -#endif + switch (sizeof(void *)) { + case 4: + str = (uvalue > (unsigned long long) 0xffffffff) ? print_number_llu_r(str, uvalue) : + print_number_lu_r(str, uvalue); + break; + case 8: + do { + *str++ = (char) ('0' + (uvalue % 10)); + } while (uvalue /= 10); + break; + default: + fatal("Netdata supports only 32-bit & 64-bit systems."); + } return str; } @@ -106,14 +111,19 @@ void buffer_print_llu(BUFFER *wb, unsigned long long uvalue) char *str = &wb->buffer[wb->len]; char *wstr = str; -#ifdef ENVIRONMENT32 - if(uvalue > (unsigned long long)0xffffffff) - wstr = print_number_llu_r(wstr, uvalue); - else - wstr = print_number_lu_r(wstr, uvalue); -#else - do *wstr++ = (char)('0' + (uvalue % 10)); while(uvalue /= 10); -#endif + switch (sizeof(void *)) { + case 4: + wstr = (uvalue > (unsigned long long) 0xffffffff) ? print_number_llu_r(wstr, uvalue) : + print_number_lu_r(wstr, uvalue); + break; + case 8: + do { + *wstr++ = (char) ('0' + (uvalue % 10)); + } while (uvalue /= 10); + break; + default: + fatal("Netdata supports only 32-bit & 64-bit systems."); + } // terminate it *wstr = '\0'; |