From d18992a3ea1df301d6cd15271400af33640f4b3f Mon Sep 17 00:00:00 2001 From: netbsduser <5460559+netbsduser@users.noreply.github.com> Date: Mon, 14 Oct 2024 12:21:40 +0100 Subject: [PATCH] options/internal: ensure FutexLockImpl alignment to 4 bytes On m68k the default alignment of 2 bytes for a uint32_t will result in futex calls failing, as a futex must be 4-byte aligned. --- options/internal/include/mlibc/lock.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/options/internal/include/mlibc/lock.hpp b/options/internal/include/mlibc/lock.hpp index 8bff98747..85ceb4e23 100644 --- a/options/internal/include/mlibc/lock.hpp +++ b/options/internal/include/mlibc/lock.hpp @@ -8,8 +8,12 @@ #include #include +// alignas(4) is specified for the benefit of m68k, where default alignment is +// 2 bytes for a uint32_t, while the futex syscall requires 4-byte alignment. +// It is a no-op on any other architecture. + template -struct FutexLockImpl { +struct alignas(4) FutexLockImpl { FutexLockImpl() : _state{0}, _recursion{0} { } FutexLockImpl(const FutexLockImpl &) = delete;