Re: bitfield and gcc - Mailing list pgsql-hackers

From Marti Raudsepp
Subject Re: bitfield and gcc
Date
Msg-id CABRT9RAD-aOoJ4_ZaJdMs_EU34XcLb=4jQe3i5yESMCTK+JTQA@mail.gmail.com
Whole thread Raw
In response to bitfield and gcc  (Gaetano Mendola <mendola@gmail.com>)
Responses Re: bitfield and gcc
List pgsql-hackers
On Sat, Feb 11, 2012 at 01:54, Gaetano Mendola <mendola@gmail.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


pgsql-hackers by date:

Previous
From: Chetan Suttraway
Date:
Subject: Re: Optimize referential integrity checks (todo item)
Next
From: Kohei KaiGai
Date:
Subject: Re: CUDA Sorting