Re: signed vs. unsigned in TYPEALIGN (was Re: space reserved for WAL record does not match what was written: panic on windows) - Mailing list pgsql-hackers

From Andres Freund
Subject Re: signed vs. unsigned in TYPEALIGN (was Re: space reserved for WAL record does not match what was written: panic on windows)
Date
Msg-id 20131017221017.GC442708@alap2.anarazel.de
Whole thread Raw
In response to signed vs. unsigned in TYPEALIGN (was Re: space reserved for WAL record does not match what was written: panic on windows)  (Noah Misch <noah@leadboat.com>)
Responses Re: signed vs. unsigned in TYPEALIGN (was Re: space reserved for WAL record does not match what was written: panic on windows)  (Noah Misch <noah@leadboat.com>)
List pgsql-hackers
On 2013-10-17 18:04:34 -0400, Noah Misch wrote:
> On Thu, Oct 17, 2013 at 08:27:01PM +0200, Andres Freund wrote:
> > On 2013-10-17 12:33:45 -0400, Noah Misch wrote:
> > > > 1. Is there any guarantee that sizeof(intptr_t) >= sizeof(size_t)?
> > > > (Note that Size is just a typedef for size_t, in c.h)
> > > 
> > > C99 doesn't require it, but I have never heard of a platform where it is
> > > false.  sizeof(intptr_t) > sizeof(size_t) systems have existed.
> > 
> > Either way, both have to be at least 4byte on 32bit platforms and 8byte
> > on 64bit ones. So I as well think we're good.
> 
> C99 does not have concepts like "32bit platform" and "64bit platform", so it
> cannot make such a constraint.  Nonetheless, I agree we're good with respect
> to implementations actually worth anticipating.

But afaik we indirectly require either 4 or 8 byte pointers or in
configure. And we have a requirement for non-segmented memory afaics. So
both size_t and intptr_t have to be big enough to store a pointer. Which
in turn implies that they have to be at least 4/8 bytes.

> Having said that, changing the ancient macros to use uintptr_t does have the
> advantage you mention, and I'm failing to think of a disadvantage.

+1

Greetings,

Andres Freund



pgsql-hackers by date:

Previous
From: Noah Misch
Date:
Subject: signed vs. unsigned in TYPEALIGN (was Re: space reserved for WAL record does not match what was written: panic on windows)
Next
From: Jim Nasby
Date:
Subject: Multiple psql -c / -f options