https://gcc.gnu.org/g:ccd612d2b9fdcda9fd6b0e9167b6762579639aea

commit r17-5571-gccd612d2b9fdcda9fd6b0e9167b6762579639aea
Author: Nicolas Boulenguez <[email protected]>
Date:   Mon Oct 26 09:56:11 2026 +0100

    Ada: Ensure that Ada and C timespec match on 32-bit big-endian
    
    gcc/ada/
            PR ada/114065
            * s-oscons-tmplt.c (SIZEOF_tv_nsec): Adjust for Glibc platforms.

Diff:
---
 gcc/ada/s-oscons-tmplt.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/gcc/ada/s-oscons-tmplt.c b/gcc/ada/s-oscons-tmplt.c
index cb2e05f6aae5..1d5b624516ef 100644
--- a/gcc/ada/s-oscons-tmplt.c
+++ b/gcc/ada/s-oscons-tmplt.c
@@ -1771,7 +1771,17 @@ CNS(MAX_tv_sec, "")
    --  Sizes (in bytes) of the components of struct timespec.
    --  The tv_sec field is the same as in struct timeval.
 */
-#define SIZEOF_tv_nsec (sizeof (ts.tv_nsec))
+
+/**
+ ** On GNU libc, this accounts for an anonymous padding field in some cases
+ ** (https://sourceware.org/glibc/wiki/Y2038ProofnessDesign#struct_timespec)
+ ** and also ensures that the sizes of the Ada record and C struct match.
+ **/
+#if defined (__GLIBC__)
+# define SIZEOF_tv_nsec (sizeof (ts) - sizeof (ts.tv_sec))
+#else
+# define SIZEOF_tv_nsec (sizeof (ts.tv_nsec))
+#endif
 CND(SIZEOF_tv_nsec, "tv_nsec");
 }

Reply via email to