Re: AW: AW: Could turn on -O2 in AIX

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Zeugswetter Andreas SB <ZeugswetterA(at)wien(dot)spardat(dot)at>, Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: AW: AW: Could turn on -O2 in AIX
Date: 2001-01-23 01:13:46
Message-ID: 200101230113.UAA22069@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Tom, can you remind me where we left this?

> Zeugswetter Andreas SB <ZeugswetterA(at)wien(dot)spardat(dot)at> writes:
> >> But that is unfortunately not the problem. Looks like yet
> >> another broken compiler to me :-(
>
> > Ok, the comparison ((int) time) > ((int) 0x80000001) is the problem.
> > Reading the comment again and again, I have come to the conclusion,
> > that the intent was originally to avoid INT_MIN on AIX.
>
> No, I think the other way round. Digging into Postgres 4.2, I find
>
> #if defined(PORTNAME_aix)
> /*
> * AIX considers 2147483648 == -2147483648 (since they have the same bit
> * representation) but uses a different sign sense in a comparison to
> * these integer constants depending on whether the constant is signed
> * or not!
> */
> #include <values.h>
> #define NOSTART_ABSTIME ((AbsoluteTime) HIBITI) /* - 2^31 */
> #else
> #define NOSTART_ABSTIME ((AbsoluteTime) 2147483648) /* - 2^31 */
> #endif /* PORTNAME_aix */
>
> where HIBITI must come from a system header, because it doesn't appear
> anywhere else in Postgres 4.2. But I'm betting it was a representation
> of 0x80000000. By the time of our oldest CVS sources, this had
> metamorphosed into
>
> #if defined(PORTNAME_aix)
> /*
> * AIX considers 2147483648 == -2147483648 (since they have the same bit
> * representation) but uses a different sign sense in a comparison to
> * these integer constants depending on whether the constant is signed
> * or not!
> */
> #include <values.h>
> /*#define NOSTART_ABSTIME ((AbsoluteTime) HIBITI) */ /* - 2^31 */
> #define NOSTART_ABSTIME ((AbsoluteTime) INT_MIN)
> #else
> /*#define NOSTART_ABSTIME ((AbsoluteTime) 2147483648)*/ /* - 2^31 */
> #define NOSTART_ABSTIME ((AbsoluteTime) -2147483647) /* - 2^31 */
> #endif /* PORTNAME_aix */
>
> Hard to tell how we got from point A to point B, but it seems
> crystal-clear that the *original* author intended to use 0x80000000
> on all platforms.
>
> > My solution would be to use INT_MIN for all ports, which has the advantage
> > that the above problematic comparison can be converted to !=,
> > since no integer will be smaller than INT_MIN.
>
> I agree. When I was looking at this code this morning, I was wondering
> what INT_MIN was supposed to represent anyway, if NOSTART_ABSTIME is
> INT_MIN + 1. I think someone messed this up between 4.2 and Postgres95.
>
> Thomas, any objection to this plan?
>
> regards, tom lane
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2001-01-23 01:18:38 Re: AW: AW: Could turn on -O2 in AIX
Previous Message Tom Lane 2001-01-23 01:06:15 Re: realloc suggestion