Get rid of anonymous struct

This is a C11 feature, and we require C99. While at it, go the further
step and get rid of the surrounding union (with uintptr_t) entirely,
as there is currently no use case for this file to access the header of
BlocktableEntry as a uintptr_t, and there are no additional alignment
requirements. The least invasive way seems to be to transfer the old
union name to this struct.

Reported by Pavel Borisov and Andres Freund, per buildfarm member mylodon
Reviewed by Pavel Borisov

Discussion: https://postgr.es/m/CALT9ZEH11NYV8AOzKb1bWhCf6J0H=H31f0MgT9xX+HdqvcA1rw@mail.gmail.com
This commit is contained in:
John Naylor 2024-04-09 16:16:01 +07:00
parent baa82b78dc
commit bf183f168c
1 changed files with 20 additions and 21 deletions

View File

@ -43,37 +43,36 @@
*/
typedef struct BlocktableEntry
{
union
struct
{
struct
{
#ifndef WORDS_BIGENDIAN
/*
* We need to position this member so that the backing radix tree
* can use the lowest bit for a pointer tag. In particular, it
* must be placed within 'header' so that it corresponds to the
* lowest byte in 'ptr'. We position 'nwords' along with it to
* avoid struct padding.
*/
uint8 flags;
/*
* We need to position this member to reserve space for the backing
* radix tree to tag the lowest bit when struct 'header' is stored
* inside a pointer or DSA pointer.
*/
uint8 flags;
int8 nwords;
int8 nwords;
#endif
/*
* We can store a small number of offsets here to avoid wasting
* space with a sparse bitmap.
*/
OffsetNumber full_offsets[NUM_FULL_OFFSETS];
/*
* We can store a small number of offsets here to avoid wasting space
* with a sparse bitmap.
*/
OffsetNumber full_offsets[NUM_FULL_OFFSETS];
#ifdef WORDS_BIGENDIAN
int8 nwords;
uint8 flags;
int8 nwords;
uint8 flags;
#endif
};
uintptr_t ptr;
} header;
/*
* We don't expect any padding space here, but to be cautious, code
* creating new entries should zero out space up to 'words'.
*/
bitmapword words[FLEXIBLE_ARRAY_MEMBER];
} BlocktableEntry;