From 97b062503185cbafaf80cb5ec1da1c1c953411e1 Mon Sep 17 00:00:00 2001 From: barracuda156 Date: Tue, 8 Aug 2023 19:03:03 +0800 Subject: [PATCH] Fix libuv --- src/unix/darwin-proctitle.c | 2 ++ src/unix/fs.c | 2 +- src/unix/process.c | 10 +++++++--- src/unix/tty.c | 2 +- src/unix/udp.c | 2 ++ 5 files changed, 13 insertions(+), 5 deletions(-) diff --git src/unix/darwin-proctitle.c src/unix/darwin-proctitle.c index 5288083e..c1aa0531 100644 --- src/unix/darwin-proctitle.c +++ src/unix/darwin-proctitle.c @@ -41,9 +41,11 @@ static int uv__pthread_setname_np(const char* name) { strncpy(namebuf, name, sizeof(namebuf) - 1); namebuf[sizeof(namebuf) - 1] = '\0'; +#if TARGET_OS_IPHONE || (MAC_OS_X_VERSION_MIN_REQUIRED >= 1060) err = pthread_setname_np(namebuf); if (err) return UV__ERR(err); +#endif return 0; } diff --git src/unix/fs.c src/unix/fs.c index 6b051c12..18e274cf 100644 --- src/unix/fs.c +++ src/unix/fs.c @@ -1410,7 +1411,7 @@ static void uv__to_stat(struct stat* src, uv_stat_t* dst) { 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; diff --git src/unix/process.c src/unix/process.c index dd58c18d..35aa9b1b 100644 --- src/unix/process.c +++ src/unix/process.c @@ -36,7 +36,9 @@ #include #if defined(__APPLE__) -# include +# if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 +# include +# endif # include # include # include @@ -407,7 +409,7 @@ static void uv__process_child_init(const uv_process_options_t* options, } -#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 *); @@ -608,9 +610,11 @@ static int uv__spawn_set_posix_spawn_file_actions( } } +#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) @@ -859,7 +863,7 @@ static int uv__spawn_and_init_child( 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 diff --git src/unix/tty.c src/unix/tty.c index d099bdb3..899e3a66 100644 --- src/unix/tty.c +++ src/unix/tty.c @@ -85,7 +85,7 @@ static int uv__tty_is_slave(const int fd) { 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; diff --git src/unix/udp.c src/unix/udp.c index c2814512..cba9e821 100644 --- src/unix/udp.c +++ src/unix/udp.c @@ -148,7 +148,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)]; @@ -211,9 +211,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) { @@ -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]; @@ -422,7 +422,7 @@ uv__io_feed(handle->loop, &handle->io_watcher); } -#endif /* __linux__ || ____FreeBSD__ || __APPLE__ */ +#endif /* __linux__ || __FreeBSD__ || (defined(__APPLE__) && (MAC_OS_X_VERSION_MIN_REQUIRED >= 1070)) */ static void uv__udp_sendmsg(uv_udp_t* handle) { struct uv__queue* q; @@ -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.) @@ -892,6 +892,7 @@ static int uv__udp_set_membership6(uv_udp_t* handle, !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, @@ -1083,6 +1084,7 @@ int uv_udp_set_source_membership(uv_udp_t* handle, !defined(__ANDROID__) && \ !defined(__DragonFly__) && \ !defined(__QNX__) && \ + (!defined(__APPLE__) || (MAC_OS_X_VERSION_MAX_ALLOWED >= 1070)) && \ !defined(__GNU__) int err; union uv__sockaddr mcast_addr;