From: Daniel King Date: Fri, 13 Sep 2024 15:16:52 +0000 (+0100) Subject: ada: Fix alignment of pthread_mutex_t X-Git-Tag: basepoints/gcc-16~4650 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=758a95db8a9ee0048a5de5334b59027535e2ecbc;p=thirdparty%2Fgcc.git 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 --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;