diff options
author | David Robillard <d@drobilla.net> | 2014-10-03 17:09:44 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2014-10-03 17:09:44 +0000 |
commit | 164337b78f11c7fdb5881df6262ea0d02a1cad6f (patch) | |
tree | 0a0904e03e37388982f5d1f28bd9d52e7382d848 | |
parent | cf50a460fcc84687d18764a61cf79d662766414b (diff) | |
download | serd-164337b78f11c7fdb5881df6262ea0d02a1cad6f.tar.gz serd-164337b78f11c7fdb5881df6262ea0d02a1cad6f.tar.bz2 serd-164337b78f11c7fdb5881df6262ea0d02a1cad6f.zip |
Remove dependence on fmax() to avoid portability issues.
git-svn-id: http://svn.drobilla.net/serd/trunk@476 490d8e77-9747-427b-9fa3-0b8f29cee8a0
-rw-r--r-- | NEWS | 6 | ||||
-rw-r--r-- | src/node.c | 11 | ||||
-rw-r--r-- | src/serd_internal.h | 8 | ||||
-rw-r--r-- | wscript | 8 |
4 files changed, 16 insertions, 17 deletions
@@ -1,3 +1,9 @@ +serd (0.21.0) unstable; + + * Remove dependence on fmax() to avoid portability issues + + -- David Robillard <d@drobilla.net> Fri, 03 Oct 2014 13:08:29 -0400 + serd (0.20.0) stable; * Support new RDF 1.1 Turtle @@ -216,6 +216,13 @@ serd_node_new_uri(const SerdURI* uri, const SerdURI* base, SerdURI* out) return node; } +static inline unsigned +serd_digits(double abs) +{ + const double lg = ceil(log10(abs + 1.0)); + return lg < 1.0 ? 1U : (unsigned)lg; +} + SERD_API SerdNode serd_node_new_decimal(double d, unsigned frac_digits) @@ -225,7 +232,7 @@ serd_node_new_decimal(double d, unsigned frac_digits) } const double abs_d = fabs(d); - const unsigned int_digits = (unsigned)fmax(1.0, ceil(log10(abs_d + 1))); + const unsigned int_digits = serd_digits(abs_d); char* buf = (char*)calloc(int_digits + frac_digits + 3, 1); SerdNode node = { (const uint8_t*)buf, 0, 0, 0, SERD_LITERAL }; const double int_part = floor(abs_d); @@ -276,7 +283,7 @@ SerdNode serd_node_new_integer(int64_t i) { int64_t abs_i = (i < 0) ? -i : i; - const unsigned digits = fmax(1.0, ceil(log10((double)abs_i + 1))); + const unsigned digits = serd_digits(abs_i); char* buf = (char*)calloc(digits + 2, 1); SerdNode node = { (const uint8_t*)buf, 0, 0, 0, SERD_LITERAL }; diff --git a/src/serd_internal.h b/src/serd_internal.h index d96d4969..20700bb8 100644 --- a/src/serd_internal.h +++ b/src/serd_internal.h @@ -38,14 +38,6 @@ # define MIN(a, b) (((a) < (b)) ? (a) : (b)) #endif -#ifndef HAVE_FMAX -static inline double -fmax(double a, double b) -{ - return (a < b) ? b : a; -} -#endif - /* File and Buffer Utilities */ static inline FILE* @@ -11,7 +11,7 @@ import waflib.extras.autowaf as autowaf # major increment <=> incompatible changes # minor increment <=> compatible changes (additions) # micro increment <=> no interface changes -SERD_VERSION = '0.20.0' +SERD_VERSION = '0.21.0' SERD_MAJOR_VERSION = '0' # Mandatory waf variables @@ -67,12 +67,6 @@ def configure(conf): define_name = 'HAVE_GCOV', mandatory = False) - conf.check(function_name = 'fmax', - header_name = 'math.h', - define_name = 'HAVE_FMAX', - lib = ['m'], - mandatory = False) - if not Options.options.no_posix: conf.check(function_name = 'posix_memalign', header_name = 'stdlib.h', |