Skip to content

Commit

Permalink
Use utimensat() on FreeBSD
Browse files Browse the repository at this point in the history
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 facebook#3952.

Further addresses facebook#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/
  • Loading branch information
felixhandte committed Mar 13, 2024
1 parent a6ff119 commit 1e61f99
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions programs/util.c
Expand Up @@ -45,6 +45,10 @@ extern "C" {
# include <string.h> /* strerror, memcpy */
#endif /* #ifdef _WIN32 */

#if defined(__FreeBSD__)
#include <sys/param.h> /* __FreeBSD_version */
#endif /* #ifdef __FreeBSD__ */

/*-****************************************
* Internal Macros
******************************************/
Expand Down Expand Up @@ -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} };
Expand Down Expand Up @@ -1546,7 +1551,6 @@ int UTIL_countCores(int logical)

#elif defined(__FreeBSD__)

#include <sys/param.h>
#include <sys/sysctl.h>

/* Use physical core sysctl when available
Expand Down

0 comments on commit 1e61f99

Please sign in to comment.