libuv: Restore support for macOS 10.x

Upstream libuv no longer supports these versions.
This commit is contained in:
Brad King
2026-03-08 19:45:40 -04:00
parent 81c86aae4a
commit abac34eda2
3 changed files with 38 additions and 4 deletions
+4
View File
@@ -124,6 +124,9 @@ STATIC_ASSERT(offsetof(uv_buf_t, len) == offsetof(struct iovec, iov_len));
/* https://github.com/libuv/libuv/issues/1674 */
int uv_clock_gettime(uv_clock_id clock_id, uv_timespec64_t* ts) {
#if defined(__APPLE__) && MAC_OS_X_VERSION_MIN_REQUIRED < 101200
return UV_ENOSYS;
#else
struct timespec t;
int r;
@@ -148,6 +151,7 @@ int uv_clock_gettime(uv_clock_id clock_id, uv_timespec64_t* ts) {
ts->tv_nsec = t.tv_nsec;
return 0;
#endif
}
+12
View File
@@ -32,6 +32,12 @@
#include <sys/sysctl.h>
#include <unistd.h> /* sysconf */
#if MAC_OS_X_VERSION_MIN_REQUIRED < 101200
# include <dlfcn.h>
# define mach_continuous_time uv__mach_continuous_time
static uint64_t (*uv__mach_continuous_time)(void);
#endif
static uv_once_t once = UV_ONCE_INIT;
static mach_timebase_info_data_t timebase;
@@ -54,6 +60,12 @@ void uv__platform_loop_delete(uv_loop_t* loop) {
static void uv__hrtime_init_once(void) {
if (KERN_SUCCESS != mach_timebase_info(&timebase))
abort();
#if MAC_OS_X_VERSION_MIN_REQUIRED < 101200
uv__mach_continuous_time = (uint64_t (*)(void))
dlsym(RTLD_DEFAULT, "mach_continuous_time");
if (uv__mach_continuous_time == NULL)
uv__mach_continuous_time = mach_absolute_time;
#endif
}
+22 -4
View File
@@ -203,7 +203,7 @@ static ssize_t uv__fs_fdatasync(uv_fs_t* req) {
}
#if defined(__APPLE__) \
#if (defined(__APPLE__) && MAC_OS_X_VERSION_MIN_REQUIRED >= 101300) \
|| defined(_AIX71) \
|| defined(__DragonFly__) \
|| defined(__FreeBSD__) \
@@ -234,7 +234,7 @@ static struct timespec uv__fs_to_timespec(double time) {
static ssize_t uv__fs_futime(uv_fs_t* req) {
#if defined(__APPLE__) \
#if (defined(__APPLE__) && MAC_OS_X_VERSION_MIN_REQUIRED >= 101300) \
|| defined(_AIX71) \
|| defined(__DragonFly__) \
|| defined(__FreeBSD__) \
@@ -1167,7 +1167,7 @@ static ssize_t uv__fs_sendfile(uv_fs_t* req) {
static ssize_t uv__fs_utime(uv_fs_t* req) {
#if defined(__APPLE__) \
#if (defined(__APPLE__) && MAC_OS_X_VERSION_MIN_REQUIRED >= 101300) \
|| defined(_AIX71) \
|| defined(__DragonFly__) \
|| defined(__FreeBSD__) \
@@ -1202,7 +1202,7 @@ static ssize_t uv__fs_utime(uv_fs_t* req) {
static ssize_t uv__fs_lutime(uv_fs_t* req) {
#if defined(__APPLE__) \
#if (defined(__APPLE__) && MAC_OS_X_VERSION_MIN_REQUIRED >= 101300) \
|| defined(_AIX71) \
|| defined(__DragonFly__) \
|| defined(__FreeBSD__) \
@@ -1258,7 +1258,11 @@ static ssize_t uv__fs_copyfile(uv_fs_t* req) {
uv_file dstfd;
struct stat src_statsbuf;
struct stat dst_statsbuf;
#if defined(__APPLE__) && MAC_OS_X_VERSION_MIN_REQUIRED < 101300
struct timeval times[2];
#else
struct timespec times[2];
#endif
int dst_flags;
int result;
int err;
@@ -1340,8 +1344,15 @@ static ssize_t uv__fs_copyfile(uv_fs_t* req) {
* Change the timestamps of the destination file to match the source file.
*/
#if defined(__APPLE__)
# if MAC_OS_X_VERSION_MIN_REQUIRED < 101300
times[0].tv_sec = src_statsbuf.st_atimespec.tv_sec;
times[0].tv_usec = src_statsbuf.st_atimespec.tv_nsec / 1000;
times[1].tv_sec = src_statsbuf.st_mtimespec.tv_sec;
times[1].tv_usec = src_statsbuf.st_mtimespec.tv_nsec / 1000;
# else
times[0] = src_statsbuf.st_atimespec;
times[1] = src_statsbuf.st_mtimespec;
# endif
#elif defined(_AIX)
times[0].tv_sec = src_statsbuf.st_atime;
times[0].tv_nsec = src_statsbuf.st_atime_n;
@@ -1352,10 +1363,17 @@ static ssize_t uv__fs_copyfile(uv_fs_t* req) {
times[1] = src_statsbuf.st_mtim;
#endif
#if defined(__APPLE__) && MAC_OS_X_VERSION_MIN_REQUIRED < 101300
if (futimes(dstfd, times) == -1) {
err = UV__ERR(errno);
goto out;
}
#else
if (futimens(dstfd, times) == -1) {
err = UV__ERR(errno);
goto out;
}
#endif
/*
* Change the ownership and permissions of the destination file to match the