Re: bitfield and gcc

From: Marti Raudsepp <marti(at)juffo(dot)org>
To: Gaetano Mendola <mendola(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: bitfield and gcc
Date: 2012-02-13 10:38:16
Message-ID: CABRT9RAD-aOoJ4_ZaJdMs_EU34XcLb=4jQe3i5yESMCTK+JTQA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Feb 11, 2012 at 01:54, Gaetano Mendola <mendola(at)gmail(dot)com> wrote:
> I wonder if somewhere in Postgres source "we" are relying on the GCC
> "correct behaviour" regarding the read-modify-write of bitfield in
> structures.

Probably not. I'm pretty sure that we don't have any bitfields, since
not all compilers are happy with them. And it looks like this behavior
doesn't affect other kinds of struct fields.

It sounds like the GCC guys are saying that it's theoretically
possible that the compiler will generate 64-bit read-modify-writes
regardless of the struct member types. In this light, PostgreSQL code
is not "correct" -- our slock_t uses a char type on i386/AMD64/SPARC
and 32-bit int on IA-64/PPC64. There are plenty of places where it's
adjacent to other small fields.

However, I don't think the latter is a problem with any compilers in
practice, as that would break a lot more code than just btrfs and
Postgres.

Regards,
Marti

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kohei KaiGai 2012-02-13 10:39:23 Re: CUDA Sorting
Previous Message Chetan Suttraway 2012-02-13 10:02:38 Re: Optimize referential integrity checks (todo item)