libuv folks keep breaking the code: https://github.com/libuv/libuv/commit/c0a61c3bb323724532fa9c1ac190afb36e4ae264 Restore the working version. --- src/unix/darwin.c +++ src/unix/darwin.c @@ -25,6 +25,7 @@ #include #include +#include #include #include #include /* _NSGetExecutablePath */ @@ -33,6 +34,7 @@ #include /* sysconf */ static uv_once_t once = UV_ONCE_INIT; +static uint64_t (*time_func)(void); static mach_timebase_info_data_t timebase; @@ -54,12 +56,16 @@ static void uv__hrtime_init_once(void) { if (KERN_SUCCESS != mach_timebase_info(&timebase)) abort(); + + time_func = (uint64_t (*)(void)) dlsym(RTLD_DEFAULT, "mach_continuous_time"); + if (time_func == NULL) + time_func = mach_absolute_time; } uint64_t uv__hrtime(uv_clocktype_t type) { uv_once(&once, uv__hrtime_init_once); - return mach_continuous_time() * timebase.numer / timebase.denom; + return time_func() * timebase.numer / timebase.denom; } Fix breakage caused by https://github.com/libuv/libuv/commit/1c778bd001543371c915a79b7ac3c5864fe59e74 10.7 may be too low of a threshold, but on powerpc we do not care. --- src/unix/udp.c +++ src/unix/udp.c @@ -152,7 +152,7 @@ } static int uv__udp_recvmmsg(uv_udp_t* handle, uv_buf_t* buf) { -#if defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__) +#if defined(__linux__) || defined(__FreeBSD__) || (defined(__APPLE__) && (MAC_OS_X_VERSION_MIN_REQUIRED >= 1070)) struct sockaddr_in6 peers[20]; struct iovec iov[ARRAY_SIZE(peers)]; struct mmsghdr msgs[ARRAY_SIZE(peers)]; @@ -215,9 +215,9 @@ handle->recv_cb(handle, 0, buf, NULL, UV_UDP_MMSG_FREE); } return nread; -#else /* __linux__ || ____FreeBSD__ || __APPLE__ */ +#else /* __linux__ || __FreeBSD__ || (defined(__APPLE__) && (MAC_OS_X_VERSION_MIN_REQUIRED >= 1070)) */ return UV_ENOSYS; -#endif /* __linux__ || ____FreeBSD__ || __APPLE__ */ +#endif /* __linux__ || __FreeBSD__ || (defined(__APPLE__) && (MAC_OS_X_VERSION_MIN_REQUIRED >= 1070)) */ } static void uv__udp_recvmsg(uv_udp_t* handle) { @@ -890,7 +890,7 @@ int uv_udp_using_recvmmsg(const uv_udp_t* handle) { -#if defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__) +#if defined(__linux__) || defined(__FreeBSD__) || (defined(__APPLE__) && (MAC_OS_X_VERSION_MIN_REQUIRED >= 1070)) if (handle->flags & UV_HANDLE_UDP_RECVMMSG) return 1; #endif --- src/unix/fs.c +++ src/unix/fs.c @@ -26,6 +26,10 @@ * getting the errno to the right place (req->result or as the return value.) */ +#ifdef __APPLE__ +#define _MACPORTS_LEGACY_COMPATIBLE_SCANDIR 1 +#endif + #include "uv.h" #include "internal.h" @@ -1073,7 +1077,7 @@ return -1; } /* sendfile() on iOS(arm64) will throw SIGSYS signal cause crash. */ -#elif (defined(__APPLE__) && !TARGET_OS_IPHONE) \ +#elif (defined(__APPLE__) && (!TARGET_OS_IPHONE || (MAC_OS_X_VERSION_MAX_ALLOWED >= 1050))) \ || defined(__DragonFly__) \ || defined(__FreeBSD__) { @@ -1442,7 +1446,7 @@ dst->st_blksize = src->st_blksize; dst->st_blocks = src->st_blocks; -#if defined(__APPLE__) +#if defined(__APPLE__) && (MAC_OS_X_VERSION_MAX_ALLOWED >= 1050) dst->st_atim.tv_sec = src->st_atimespec.tv_sec; dst->st_atim.tv_nsec = src->st_atimespec.tv_nsec; dst->st_mtim.tv_sec = src->st_mtimespec.tv_sec; --- src/unix/process.c +++ src/unix/process.c @@ -36,7 +36,9 @@ #include #if defined(__APPLE__) +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 # include +#endif # include # include # include @@ -387,7 +389,7 @@ #endif -#if defined(__APPLE__) +#if defined(__APPLE__) && (MAC_OS_X_VERSION_MIN_REQUIRED >= 1050) typedef struct uv__posix_spawn_fncs_tag { struct { int (*addchdir_np)(const posix_spawn_file_actions_t *, const char *); @@ -588,9 +590,11 @@ } } +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 if (fd == use_fd) err = posix_spawn_file_actions_addinherit_np(actions, fd); else +#endif err = posix_spawn_file_actions_adddup2(actions, use_fd, fd); assert(err != ENOSYS); if (err != 0) @@ -839,7 +843,7 @@ int exec_errorno; ssize_t r; -#if defined(__APPLE__) +#if defined(__APPLE__) && (MAC_OS_X_VERSION_MIN_REQUIRED >= 1050) uv_once(&posix_spawn_init_once, uv__spawn_init_posix_spawn); /* Special child process spawn case for macOS Big Sur (11.0) onwards --- src/unix/tty.c +++ src/unix/tty.c @@ -85,7 +85,7 @@ int dummy; result = ioctl(fd, TIOCGPTN, &dummy) != 0; -#elif defined(__APPLE__) +#elif defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 char dummy[256]; result = ioctl(fd, TIOCPTYGNAME, &dummy) != 0; --- src/unix/udp.c +++ src/unix/udp.c @@ -335,7 +335,7 @@ } } -#if defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__) +#if defined(__linux__) || defined(__FreeBSD__) || (defined(__APPLE__) && (MAC_OS_X_VERSION_MIN_REQUIRED >= 1070)) static void uv__udp_sendmsg_many(uv_udp_t* handle) { uv_udp_send_t* req; struct mmsghdr h[20]; @@ -434,7 +434,7 @@ q = uv__queue_head(&handle->write_queue); req = uv__queue_data(q, uv_udp_send_t, queue); -#if defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__) +#if defined(__linux__) || defined(__FreeBSD__) || (defined(__APPLE__) && (MAC_OS_X_VERSION_MIN_REQUIRED >= 1070)) /* Use sendmmsg() if this send request contains more than one datagram OR * there is more than one send request (because that automatically implies * there is more than one datagram.) @@ -927,6 +927,7 @@ !defined(__ANDROID__) && \ !defined(__DragonFly__) && \ !defined(__QNX__) && \ + (!defined(__APPLE__) || (MAC_OS_X_VERSION_MAX_ALLOWED >= 1070)) && \ !defined(__GNU__) static int uv__udp_set_source_membership4(uv_udp_t* handle, const struct sockaddr_in* multicast_addr, @@ -1118,6 +1119,7 @@ !defined(__ANDROID__) && \ !defined(__DragonFly__) && \ !defined(__QNX__) && \ + (!defined(__APPLE__) || (MAC_OS_X_VERSION_MAX_ALLOWED >= 1070)) && \ !defined(__GNU__) int err; union uv__sockaddr mcast_addr; --- test/test-fs.c +++ test/test-fs.c @@ -1477,7 +1477,7 @@ ASSERT_OK(uv_fs_fstat(NULL, &req, file, NULL)); ASSERT_OK(req.result); s = req.ptr; -# if defined(__APPLE__) +# if defined(__APPLE__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050) ASSERT_EQ(s->st_birthtim.tv_sec, t.st_birthtimespec.tv_sec); ASSERT_EQ(s->st_birthtim.tv_nsec, t.st_birthtimespec.tv_nsec); # elif defined(__linux__) @@ -1518,7 +1518,7 @@ ASSERT_EQ(s->st_size, (uint64_t) t.st_size); ASSERT_EQ(s->st_blksize, (uint64_t) t.st_blksize); ASSERT_EQ(s->st_blocks, (uint64_t) t.st_blocks); -#if defined(__APPLE__) +# if defined(__APPLE__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050) ASSERT_EQ(s->st_atim.tv_sec, t.st_atimespec.tv_sec); ASSERT_EQ(s->st_atim.tv_nsec, t.st_atimespec.tv_nsec); ASSERT_EQ(s->st_mtim.tv_sec, t.st_mtimespec.tv_sec);