summaryrefslogtreecommitdiffstats
path: root/libnetdata/buffer/buffer.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-04-14 18:12:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-04-14 18:12:10 +0000
commitb5321aff06d6ea8d730d62aec2ffd8e9271c1ffc (patch)
tree36c41e35994786456154f9d3bf88c324763aeea4 /libnetdata/buffer/buffer.c
parentAdding upstream version 1.33.1. (diff)
downloadnetdata-b5321aff06d6ea8d730d62aec2ffd8e9271c1ffc.tar.xz
netdata-b5321aff06d6ea8d730d62aec2ffd8e9271c1ffc.zip
Adding upstream version 1.34.0.upstream/1.34.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'libnetdata/buffer/buffer.c')
-rw-r--r--libnetdata/buffer/buffer.c42
1 files changed, 26 insertions, 16 deletions
diff --git a/libnetdata/buffer/buffer.c b/libnetdata/buffer/buffer.c
index c37da21e1..8ea90985c 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';