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

From: Noah Misch <noah(at)leadboat(dot)com>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, David Rowley <dgrowleyml(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: signed vs. unsigned in TYPEALIGN (was Re: space reserved for WAL record does not match what was written: panic on windows)
Date: 2013-10-21 01:10:13
Message-ID: 20131021011013.GA388774@tornado.leadboat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-www

On Fri, Oct 18, 2013 at 12:10:17AM +0200, Andres Freund wrote:
> 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.

Conformance is possible in an implementation with 8-byte size_t and 4-byte
pointers. Filling in the details makes for a decent party game.

> > 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

Committed that way, then.

--
Noah Misch
EnterpriseDB http://www.enterprisedb.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Nigel Heron 2013-10-21 04:14:43 stats for network traffic WIP
Previous Message Andrew Dunstan 2013-10-21 00:54:44 Re: strange behavior with C function and DEFAULT function parameters

Browse pgsql-www by date

  From Date Subject
Next Message Alvaro Herrera 2013-10-22 22:16:00 tracking commit timestamps
Previous Message Noah Misch 2013-10-18 20:46:18 Re: space reserved for WAL record does not match what was written: panic on windows