]> arthur.barton.de Git - netdata.git/blobdiff - src/inlined.h
fix apps.plugin values on 32bit machines
[netdata.git] / src / inlined.h
index e776f830e489e7577ac01b1c376779f8d436c17d..01492b04451d23539f578d7cb02dfa94e87dcfe3 100644 (file)
@@ -3,6 +3,19 @@
 
 #include "common.h"
 
+#ifdef KERNEL_32BIT
+typedef uint32_t kernel_uint_t;
+#define str2kernel_unit_t(string) str2uint32_t(string)
+#define KERNEL_UINT_FORMAT "%u"
+#else
+typedef uint64_t kernel_uint_t;
+#define str2kernel_unit_t(string) str2uint64_t(string)
+#define KERNEL_UINT_FORMAT "%" PRIu64
+#endif
+
+#define str2pid_t(string) str2uint32_t(string)
+
+
 // for faster execution, allow the compiler to inline
 // these functions that are called thousands of times per second
 
@@ -70,6 +83,26 @@ static inline long str2l(const char *s) {
     return n;
 }
 
+static inline uint32_t str2uint32_t(const char *s) {
+    uint32_t n = 0;
+    char c;
+    for(c = *s; c >= '0' && c <= '9' ; c = *(++s)) {
+        n *= 10;
+        n += c - '0';
+    }
+    return n;
+}
+
+static inline uint64_t str2uint64_t(const char *s) {
+    uint64_t n = 0;
+    char c;
+    for(c = *s; c >= '0' && c <= '9' ; c = *(++s)) {
+        n *= 10;
+        n += c - '0';
+    }
+    return n;
+}
+
 static inline unsigned long str2ul(const char *s) {
     unsigned long n = 0;
     char c;