https://gcc.gnu.org/g:758a95db8a9ee0048a5de5334b59027535e2ecbc
commit r15-4903-g758a95db8a9ee0048a5de5334b59027535e2ecbc Author: Daniel King <dmk...@adacore.com> Date: Fri Sep 13 16:16:52 2024 +0100 ada: Fix alignment of pthread_mutex_t On most targets the alignment of unsigned long is the same as pointer alignment, but on CHERI targets pointers have larger alignment (16 bytes compared to 8 bytes). pthread_mutex_t needs the same alignment as System.Address to account for CHERI targets. gcc/ada/ChangeLog: * libgnat/s-oslock__posix.ads: Fix alignment of pthread_mutex_t for CHERI targets. Diff: --- gcc/ada/libgnat/s-oslock__posix.ads | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gcc/ada/libgnat/s-oslock__posix.ads b/gcc/ada/libgnat/s-oslock__posix.ads index e2c237f26981..cde92e5f23a3 100644 --- a/gcc/ada/libgnat/s-oslock__posix.ads +++ b/gcc/ada/libgnat/s-oslock__posix.ads @@ -52,6 +52,11 @@ private Data : char_array (1 .. OS_Constants.PTHREAD_MUTEX_SIZE); end record; pragma Convention (C, pthread_mutex_t); - for pthread_mutex_t'Alignment use Interfaces.C.unsigned_long'Alignment; + for pthread_mutex_t'Alignment use + Integer'Max (Interfaces.C.unsigned_long'Alignment, + System.Address'Alignment); + -- On some targets (e.g. CHERI), pointers have larger alignment than + -- unsigned_long. On other targets (e.g. some 16-bit targets) long is + -- larger than a pointer. Choose the largest to err on the side of caution. end System.OS_Locks;