diff options
author | Chun-wei Fan <fanchunwei@src.gnome.org> | 2016-05-09 16:37:39 +0800 |
---|---|---|
committer | Chun-wei Fan <fanchunwei@src.gnome.org> | 2016-05-10 17:14:07 +0800 |
commit | 092cb9e202a9f654152bc5fbb276521817346d11 (patch) | |
tree | 994776b3fb72a339bdb8c3281f3a92d25b46d7d4 /gtk/fallback-c89.c | |
parent | 7a0941c0908df71ce5f11f76537c288ef0cba26b (diff) | |
download | gtk+-092cb9e202a9f654152bc5fbb276521817346d11.tar.gz |
GTK: Fix build for pre-C99 compilers
Some compilers we support, such as pre-2013 Visual Studio, does not support
for INIFINITY, log2() and exp2(), so check for exp2() and log2() during
configure, and use fallbacks for them and INIFINTY if they are not found.
https://bugzilla.gnome.org/show_bug.cgi?id=766207
Diffstat (limited to 'gtk/fallback-c89.c')
-rw-r--r-- | gtk/fallback-c89.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/gtk/fallback-c89.c b/gtk/fallback-c89.c index e87bf76c0c..df28048feb 100644 --- a/gtk/fallback-c89.c +++ b/gtk/fallback-c89.c @@ -77,3 +77,30 @@ isinf (double x) return (!_finite (x) && !_isnan (x)); } #endif + +#ifndef INFINITY +/* define INFINITY for compilers that lack support for it */ +# ifdef HUGE_VALF +# define INFINITY HUGE_VALF +# else +# define INFINITY (float)HUGE_VAL +# endif +#endif + +#ifndef HAVE_LOG2 +/* Use a simple implementation for log2() for compilers that lack it */ +static inline double +log2 (double x) +{ + return log (x) / log (2.0); +} +#endif + +#ifndef HAVE_EXP2 +/* Use a simple implementation for exp2() for compilers that lack it */ +static inline double +exp2 (double x) +{ + return pow (2.0, x); +} +#endif |