diff --git a/.travis.yml b/.travis.yml index a87c604aa..297dcdd62 100644 --- a/.travis.yml +++ b/.travis.yml @@ -137,6 +137,13 @@ matrix: - make arminstall - make armfuzz + # Introduced to check compat with old toolchains, to prevent e.g. #1872 + - name: ARM Build Test (on Trusty) + dist: trusty + script: + - make arminstall + - make armbuild + - name: Qemu PPC + Fuzz Test # ~13mn dist: trusty # it seems ppc cross-compilation fails on "current" script: diff --git a/programs/platform.h b/programs/platform.h index 5934e59cf..64ecd21fc 100644 --- a/programs/platform.h +++ b/programs/platform.h @@ -109,6 +109,15 @@ extern "C" { #endif /* PLATFORM_POSIX_VERSION */ +#if PLATFORM_POSIX_VERSION > 1 + /* glibc < 2.26 may not expose struct timespec def without this. + * See issue #1920. */ +# ifndef _ATFILE_SOURCE +# define _ATFILE_SOURCE +# endif +#endif + + /*-********************************************* * Detect if isatty() and fileno() are available ************************************************/ diff --git a/programs/util.c b/programs/util.c index 0fc95512e..51d848018 100644 --- a/programs/util.c +++ b/programs/util.c @@ -145,20 +145,24 @@ int UTIL_setFileStat(const char *filename, stat_t *statbuf) return -1; /* set access and modification times */ -#if defined(_WIN32) || (PLATFORM_POSIX_VERSION < 200809L) + /* We check that st_mtime is a macro here in order to give us confidence + * that struct stat has a struct timespec st_mtim member. We need this + * check because there are some platforms that claim to be POSIX 2008 + * compliant but which do not have st_mtim... */ +#if (PLATFORM_POSIX_VERSION >= 200809L) && defined(st_mtime) + { + /* (atime, mtime) */ + struct timespec timebuf[2] = { {0, UTIME_NOW} }; + timebuf[1] = statbuf->st_mtim; + res += utimensat(AT_FDCWD, filename, timebuf, 0); + } +#else { struct utimbuf timebuf; timebuf.actime = time(NULL); timebuf.modtime = statbuf->st_mtime; res += utime(filename, &timebuf); } -#else - { - /* (atime, mtime) */ - struct timespec timebuf[2] = { {0, UTIME_NOW} }; - timebuf[1].tv_sec = statbuf->st_mtime; - res += utimensat(AT_FDCWD, filename, timebuf, 0); - } #endif #if !defined(_WIN32)