diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2017-08-16 21:52:38 +0300 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2017-08-16 21:52:38 +0300 |
commit | ac883ac453e9c479f397780918f235c440b7a02f (patch) | |
tree | aaaccbaee521dd6e67d055c1654d26f3fdea9c07 /src/include/c.h | |
parent | 4395f7daf3b40ecbd316bd2a68c253a56013a538 (diff) | |
download | postgresql-ac883ac453e9c479f397780918f235c440b7a02f.tar.gz |
Fix shm_toc.c to always return buffer-aligned memory.
Previously, if you passed a non-aligned size to shm_toc_create(), the
memory returned by shm_toc_allocate() would be similarly non-aligned.
This was exposed by commit 3cda10f41b, which allocated structs containing
a pg_atomic_uint64 field with shm_toc_allocate(). On systems with
MAXIMUM_ALIGNOF = 4, such structs still need to be 8-bytes aligned, but
the memory returned by shm_toc_allocate() was only 4-bytes aligned.
It's quite bogus that we abuse BUFFERALIGN to align the structs for
pg_atomic_uint64. It doesn't really have anything to do with buffers. But
that's a separate issue.
This ought to fix the buildfarm failures on 32-bit x86 systems.
Discussion: https://www.postgresql.org/message-id/7e0a73a5-0df9-1859-b8ae-9acf122dc38d@iki.fi
Diffstat (limited to 'src/include/c.h')
-rw-r--r-- | src/include/c.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/include/c.h b/src/include/c.h index 9066e3c578..af799dc1df 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -598,6 +598,7 @@ typedef NameData *Name; #define LONGALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_LONG, (LEN)) #define DOUBLEALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_DOUBLE, (LEN)) #define MAXALIGN_DOWN(LEN) TYPEALIGN_DOWN(MAXIMUM_ALIGNOF, (LEN)) +#define BUFFERALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_BUFFER, (LEN)) /* * The above macros will not work with types wider than uintptr_t, like with |