On Tue, Dec 16, 2014 at 8:05 PM, Jan Hubicka <hubi...@ucw.cz> wrote: >> On Tue, Dec 16, 2014 at 5:04 PM, Michael Haubenwallner >> <michael.haubenwall...@ssi-schaefer.com> wrote: >> > Recent commit 218765 adding sreal::to_double() breaks on AIX due to math.h >> > being included before _LARGE_FILES and __STDC_FORMAT_MACROS being defined >> > later in config.h and system.h, respectively. >> >> sreal.c shouldn't include math.h, if really really really needed >> math.h needs to be >> included from system.h at the appropriate place. > > Hmm, I need math.h for the exponential function. genautomata is also > including math.h. > Should we thus move it to system.h
Do we even link GCC with libm ...? Probably as a side-effect with linking with mpfr? Only genautomata is explicitely linked with -lm. Can't you simply prototype exp2() properly? Also we don't require a C99 runtime, so I'm not sure that exp2 is available everywhere (didn't check the C++ standard when it appears, but if then via <cmath>, not <math.h> I suppose - but cmath doesn't have exp2). Please avoid libm code in GCC, I suppose using std::pow (2., (int)m_exp) is ok though after including <cmath> - there is a double, int overload that uses __builtin_powi which eventually expands to a libgcc call. Thus following genautomata I suppose we can try including <cmath> in sreal.c after the system.h include and if that works everywhere fine. Thanks, Richard. > Something like this? > > Since i do not caremuch about performance of to_double, we could also just > have loop > that multiplies/divides by 2 until exponent is reached. It is rather lame > though. > > Honza > > Index: system.h > =================================================================== > --- system.h (revision 218788) > +++ system.h (working copy) > @@ -45,6 +45,8 @@ > > #include <stdio.h> > > +#include <math.h> > + > /* Define a generic NULL if one hasn't already been defined. */ > #ifndef NULL > #define NULL 0 > Index: genautomata.c > =================================================================== > --- genautomata.c (revision 218788) > +++ genautomata.c (working copy) > @@ -113,7 +113,6 @@ > #include "errors.h" > #include "gensupport.h" > > -#include <math.h> > #include "hashtab.h" > #include "vec.h" > #include "fnmatch.h" > Index: sreal.c > =================================================================== > --- sreal.c (revision 218788) > +++ sreal.c (working copy) > @@ -49,7 +49,6 @@ > > #include "config.h" > #include "system.h" > -#include <math.h> > #include "coretypes.h" > #include "sreal.h" > > >> >> Richard, >> >> > 2014-12-16 Michael Haubenwallner <michael.haubenwall...@ssi-schaefer.com> >> > >> > Both config.h and system.h define ABI/API macros for system >> > headers. >> > * sreal.c: Include math.h later. >> > >> > Thanks! >> > /haubi/