]> arthur.barton.de Git - netdata.git/commitdiff
math library optional
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Thu, 19 Mar 2015 20:11:13 +0000 (22:11 +0200)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Thu, 19 Mar 2015 20:11:13 +0000 (22:11 +0200)
src/Makefile
src/storage_number.c
src/unit_test.c
src/web_buffer.c

index 4809455bcb9bbcd27152f020e6def2e3cb5cac67..b5e52cb32faab9c5b01bbc823b23c09880d33c9a 100755 (executable)
@@ -27,7 +27,11 @@ CC = gcc
 
 proc_sources = proc_net_dev.c proc_net_ip_vs_stats.c proc_diskstats.c proc_meminfo.c proc_net_netstat.c proc_net_snmp.c proc_net_stat_conntrack.c proc_stat.c proc_vmstat.c proc_net_rpc_nfsd.c
 sources = procfile.c common.c log.c popen.c url.c config.c web_buffer.c storage_number.c web_client.c global_statistics.c rrd.c rrd2json.c web_server.c plugins_d.c daemon.c plugin_tc.c plugin_checks.c plugin_idlejitter.c plugin_proc.c unit_test.c main.c
-libs    = -pthread -lz -lm
+libs    = -pthread -lz
+
+ifdef STORAGE_WITH_MATH
+libs += -lm
+endif
 
 # nfacct requires root access, so we prefer it as a plugin.d external plugin
 ifdef INTERNAL_PLUGIN_NFACCT
index fa18805fc76e122c9a4f8615917fe38548424f77..6ef994def0f4f58972413789c17faf22c910c5a7 100755 (executable)
@@ -1,4 +1,6 @@
+#ifdef STORAGE_WITH_MATH
 #include <math.h>
+#endif
 
 #include "log.h"
 #include "storage_number.h"
@@ -45,9 +47,11 @@ storage_number pack_storage_number(calculated_number value)
 
        mul = m;
 
+#ifdef STORAGE_WITH_MATH
        // without this there are rounding problems
        // example: 0.9 becomes 0.89
        n = lrint(n);
+#endif
 
        r = (sign << 31) + (exp << 30) + (mul << 27) + n;
        // fprintf(stderr, "PACK: %08X, sign = %d, exp = %d, mul = %d, n = " CALCULATED_NUMBER_FORMAT "\n", r, sign, exp, mul, n);
index 15875ca2fc8d246151c949bf7c6ba8d62abe65df..3750b961762be292f6d077a172503af2e4200d2b 100755 (executable)
@@ -8,7 +8,7 @@
 #include "log.h"
 #include "web_buffer.h"
 
-#define ACCURACY_LOSS 0.0000001
+#define ACCURACY_LOSS 100.0000001
 
 int check_storage_number(calculated_number n, int debug) {
        char buffer[100];
index 513471827b96830a85a437cb61fb045636e538fa..7c57ce8c6a9a034669d5531bb02107a38fdcbabc 100755 (executable)
@@ -1,5 +1,8 @@
 #include <stdlib.h>
+
+#ifdef STORAGE_WITH_MATH
 #include <math.h>
+#endif
 
 #include "web_buffer.h"
 
@@ -24,9 +27,13 @@ int print_calculated_number(char *str, calculated_number value)
        int sign = (value < 0) ? 1 : 0;
        if(sign) value = -value;
 
+#ifdef STORAGE_WITH_MATH
        // without llrint() there are rounding problems
        // for example 0.9 becomes 0.89
        unsigned long long uvalue = llrint(value * (calculated_number)100000);
+#else
+       unsigned long long uvalue = value * (calculated_number)100000;
+#endif
 
        // print each digit
        do *wstr++ = (char)(48 + (uvalue % 10)); while(uvalue /= 10);