From 1e61f993e7832817156ed60eb8fb430495610c24 Mon Sep 17 00:00:00 2001 From: "W. Felix Handte" Date: Tue, 12 Mar 2024 14:01:17 -0700 Subject: [PATCH] Use `utimensat()` on FreeBSD FreeBSD only claims to support POSIX 2001 [0]. But they do in fact support `utimensat()`. This adds a specific check to opt them in to using it. This value was selected by consulting [1]. See discussion on #3952. Further addresses #3748. [0] https://github.com/freebsd/freebsd-src/blob/937a0055858a098027f464abf0b2b1ec5d36748f/sys/sys/unistd.h#L96 [1] https://docs.freebsd.org/en/books/porters-handbook/versions/ --- programs/util.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/programs/util.c b/programs/util.c index 862fc80080d..54e9903a47c 100644 --- a/programs/util.c +++ b/programs/util.c @@ -45,6 +45,10 @@ extern "C" { # include /* strerror, memcpy */ #endif /* #ifdef _WIN32 */ +#if defined(__FreeBSD__) +#include /* __FreeBSD_version */ +#endif /* #ifdef __FreeBSD__ */ + /*-**************************************** * Internal Macros ******************************************/ @@ -259,7 +263,8 @@ int UTIL_utime(const char* filename, const stat_t *statbuf) * 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) +#if (((PLATFORM_POSIX_VERSION >= 200809L) && defined(st_mtime)) \ + || (defined(__FreeBSD__) && __FreeBSD_version >= 1100056)) { /* (atime, mtime) */ struct timespec timebuf[2] = { {0, UTIME_NOW} }; @@ -1546,7 +1551,6 @@ int UTIL_countCores(int logical) #elif defined(__FreeBSD__) -#include #include /* Use physical core sysctl when available