Hi Folks, This patch breaks bootstrap on Darwin platforms.
Pierre-Marie de Rodat <dero...@adacore.com> wrote: > The modification file time precision now defined by OS. > > Tested on x86_64-pc-linux-gnu, committed on trunk > > gcc/ada/ > > * adaint.c (__gnat_file_time): New routine. > (__gnat_copy_attribs): Copy timestamps in nanoseconds. > * libgnat/a-direct.adb (C_Modification_Time): Bind to > __gnat_file_time. > (Modification_Time): Call to C_Modification_Time.<patch.diff> #if defined(st_mtime) is a necessary test - but the fields in the stat structure on Darwin platforms are named st_{a,c,m}timespec rather than the Linux st_{a,c,m}tim. The following patch is a fix lightly tested, OK for master (if remaining testing is successful) or you have an alternate suggestion? thanks Iain diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c index b7406a03c31..ac5738a60d2 100644 --- a/gcc/ada/adaint.c +++ b/gcc/ada/adaint.c @@ -1528,8 +1528,12 @@ extern long long __gnat_file_time(char* name) #if defined(__GNUG__) && __GNUG__ <= 4 result = (sb.st_mtime - ada_epoch_offset) * 1E9; #if defined(st_mtime) +#if __APPLE__ + result += sb.st_mtimespec.tv_nsec; +#else result += sb.st_mtim.tv_nsec; #endif +#endif #else /* Next code similar to (sb.st_mtime - ada_epoch_offset) * 1E9 + sb.st_mtim.tv_nsec @@ -1544,11 +1548,17 @@ extern long long __gnat_file_time(char* name) } #if defined(st_mtime) +#if __APPLE__ + if (__builtin_saddll_overflow(result, sb.st_mtimespec.tv_nsec, &result)) { + return LLONG_MIN; + } +#else if (__builtin_saddll_overflow(result, sb.st_mtim.tv_nsec, &result)) { return LLONG_MIN; } #endif #endif +#endif #endif return result; } @@ -3278,8 +3288,13 @@ __gnat_copy_attribs (char *from ATTRIBUTE_UNUSED, char *to ATTRIBUTE_UNUSED, tbuf[1].tv_sec = fbuf.st_mtime; #if defined(st_mtime) + #if __APPLE__ + tbuf[0].tv_usec = fbuf.st_atimespec.tv_nsec / 1000; + tbuf[1].tv_usec = fbuf.st_mtimespec.tv_nsec / 1000; + #else tbuf[0].tv_usec = fbuf.st_atim.tv_nsec / 1000; tbuf[1].tv_usec = fbuf.st_mtim.tv_nsec / 1000; + #endif #else tbuf[0].tv_usec = 0; tbuf[1].tv_usec = 0;