[PATCH v3] x32: Align sem_t to 8 bytes [BZ #33632]

H.J. Lu hjl.tools@gmail.com
Tue Nov 18 00:16:13 GMT 2025


x32 has been using 64-bit atomic operations on 4-byte aligned sem_t:

typedef union
{
  char __size[16];
  long int __align;
} sem_t;

However unaligned 64-bit atomic operations on x32 may not be atomic.
Change x32 sem_t to

typedef union
{
  char __size[16];
  long long int __align;
} sem_t;

to align it to 8 bytes so that the future x32 binaries will always use
64-bit atomic operations on aligned sem_t.  Behavior of the existing x32
binaries is unchanged.

1. Add a macro, SEM_T_ALIGN, for sem_t alignment.
2. Add a macro, HAVE_UNALIGNED_64B_ATOMICS.  Define it if unaligned 64-bit
atomic operations are supported.
3. Add a macro, USE_64B_ATOMICS_ON_SEM_T.  Define to 1 if 64-bit atomic
operations are supported and SEM_T_ALIGN is at least 8-byte aligned or
HAVE_UNALIGNED_64B_ATOMICS is defined.
4. Assert that size and alignment of sem_t are not lower than those of
the internal struct new_sem.
5. Check USE_64B_ATOMICS_ON_SEM_T, instead of USE_64B_ATOMICS, when using
64-bit atomic operations on sem_t.

This fixes BZ #33632.

-- 
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: v3-0001-x32-Align-sem_t-to-8-bytes-BZ-33632.patch
Type: text/x-patch
Size: 16680 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20251118/37873b13/attachment-0001.bin>


More information about the Libc-alpha mailing list