This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: fix aix build error with math.h in gcc/sreal.c
- From: Jan Hubicka <hubicka at ucw dot cz>
- To: Richard Biener <richard dot guenther at gmail dot com>
- Cc: Michael Haubenwallner <michael dot haubenwallner at ssi-schaefer dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>, David Edelsohn <dje dot gcc at gmail dot com>, Jan Hubicka <hubicka at ucw dot cz>
- Date: Tue, 16 Dec 2014 20:05:11 +0100
- Subject: Re: fix aix build error with math.h in gcc/sreal.c
- Authentication-results: sourceware.org; auth=none
- References: <54905811 dot 50502 at ssi-schaefer dot com> <CAFiYyc02XiH-ciVMTUb_gcZp1M4f_ORk5_070-d5SA=M7jf1iA at mail dot gmail dot com>
> On Tue, Dec 16, 2014 at 5:04 PM, Michael Haubenwallner
> <michael.haubenwallner@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
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.haubenwallner@ssi-schaefer.com>
> >
> > Both config.h and system.h define ABI/API macros for system headers.
> > * sreal.c: Include math.h later.
> >
> > Thanks!
> > /haubi/