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

commit r16-9839-gc5510ceb4ff3c866ecee6989cdc5fae02d843cc3
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 4102fe989e0b..4bd193e5f79b 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