redox/recipes/libs/libuv/redox.patch
2025-07-21 19:14:37 +00:00

168 lines
4.8 KiB
Diff

diff -ruwN source/CMakeLists.txt source-new/CMakeLists.txt
--- source/CMakeLists.txt 2023-05-19 18:21:01.000000000 +0700
+++ source-new/CMakeLists.txt 2025-07-22 01:48:56.591286953 +0700
@@ -1,3 +1,4 @@
+set (CMAKE_CXX_STANDARD 99)
cmake_minimum_required(VERSION 3.4)
if(POLICY CMP0091)
@@ -312,6 +313,17 @@
src/unix/hurd.c)
endif()
+
+if(CMAKE_SYSTEM_NAME STREQUAL "UnixPaths") # Redox
+ list(APPEND uv_libraries dl)
+ list(APPEND uv_sources
+ src/unix/no-fsevents.c
+ src/unix/proctitle.c
+ src/unix/posix-hrtime.c
+ src/unix/posix-poll.c
+ )
+endif()
+
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
list(APPEND uv_defines _GNU_SOURCE _POSIX_C_SOURCE=200112)
list(APPEND uv_libraries dl rt)
diff -ruwN source/include/uv/unix.h source-new/include/uv/unix.h
--- source/include/uv/unix.h 2023-05-19 18:21:01.000000000 +0700
+++ source-new/include/uv/unix.h 2025-07-22 01:53:54.941276543 +0700
@@ -66,6 +66,7 @@
defined(__MSYS__) || \
defined(__HAIKU__) || \
defined(__QNX__) || \
+ defined(__redox__) || \
defined(__GNU__)
# include "uv/posix.h"
#endif
diff -ruwN source/src/unix/core.c source-new/src/unix/core.c
--- source/src/unix/core.c 2023-05-19 18:21:01.000000000 +0700
+++ source-new/src/unix/core.c 2025-07-21 22:55:16.826444959 +0700
@@ -97,6 +97,10 @@
# include <sanitizer/linux_syscall_hooks.h>
#endif
+#if defined(__redox__)
+#define MSG_CMSG_CLOEXEC 0x40000000 //linux specific flag
+#endif
+
static void uv__run_pending(uv_loop_t* loop);
/* Verify that uv_buf_t is ABI-compatible with struct iovec. */
@@ -709,7 +713,8 @@
defined(__FreeBSD__) || \
defined(__NetBSD__) || \
defined(__OpenBSD__) || \
- defined(__linux__)
+ defined(__linux__) || \
+ defined(__redox__)
ssize_t rc;
rc = recvmsg(fd, msg, flags | MSG_CMSG_CLOEXEC);
if (rc == -1)
diff -ruwN source/src/unix/fs.c source-new/src/unix/fs.c
--- source/src/unix/fs.c 2023-05-19 18:21:01.000000000 +0700
+++ source-new/src/unix/fs.c 2025-07-21 22:55:16.826444959 +0700
@@ -87,7 +87,8 @@
defined(__MVS__) || \
defined(__NetBSD__) || \
defined(__HAIKU__) || \
- defined(__QNX__)
+ defined(__QNX__) || \
+ defined(__redox__)
# include <sys/statvfs.h>
#else
# include <sys/statfs.h>
@@ -648,13 +649,13 @@
defined(__MVS__) || \
defined(__NetBSD__) || \
defined(__HAIKU__) || \
- defined(__QNX__)
+ defined(__QNX__) || \
+ defined(__redox__)
struct statvfs buf;
if (0 != statvfs(req->path, &buf))
#else
struct statfs buf;
-
if (0 != statfs(req->path, &buf))
#endif /* defined(__sun) */
return -1;
@@ -670,7 +671,8 @@
defined(__OpenBSD__) || \
defined(__NetBSD__) || \
defined(__HAIKU__) || \
- defined(__QNX__)
+ defined(__QNX__) || \
+ defined(__redox__)
stat_fs->f_type = 0; /* f_type is not supported. */
#else
stat_fs->f_type = buf.f_type;
diff -ruwN source/src/unix/proctitle.c source-new/src/unix/proctitle.c
--- source/src/unix/proctitle.c 2023-05-19 18:21:01.000000000 +0700
+++ source-new/src/unix/proctitle.c 2025-07-22 02:10:12.760625178 +0700
@@ -30,7 +30,13 @@
size_t cap; /* Maximum capacity. Computed once in uv_setup_args(). */
};
+#if defined(__redox__)
+void uv__set_process_title(const char* title) {
+ // requires sys/prctl
+}
+#else
extern void uv__set_process_title(const char* title);
+#endif
static uv_mutex_t process_title_mutex;
static uv_once_t process_title_mutex_once = UV_ONCE_INIT;
diff -ruwN source/src/unix/stream.c source-new/src/unix/stream.c
--- source/src/unix/stream.c 2023-05-19 18:21:01.000000000 +0700
+++ source-new/src/unix/stream.c 2025-07-21 22:55:16.826444959 +0700
@@ -29,7 +29,14 @@
#include <errno.h>
#include <sys/types.h>
+#if defined(__redox__)
+#define _GNU_SOURCE
+#include <stdint.h>
#include <sys/socket.h>
+#include <netinet/in.h>
+#else
+#include <sys/socket.h>
+#endif
#include <sys/uio.h>
#include <sys/un.h>
#include <unistd.h>
@@ -39,6 +46,7 @@
# include <sys/event.h>
# include <sys/time.h>
# include <sys/select.h>
+#endif
/* Forward declaration */
typedef struct uv__stream_select_s uv__stream_select_t;
@@ -58,7 +66,6 @@
fd_set* swrite;
size_t swrite_sz;
};
-#endif /* defined(__APPLE__) */
union uv__cmsg {
struct cmsghdr hdr;
diff -ruwN source/src/unix/udp.c source-new/src/unix/udp.c
--- source/src/unix/udp.c 2023-05-19 18:21:01.000000000 +0700
+++ source-new/src/unix/udp.c 2025-07-21 22:55:16.826444959 +0700
@@ -31,6 +31,12 @@
#include <xti.h>
#endif
#include <sys/un.h>
+#if defined(__redox__)
+#include <netinet/in.h>
+#include <netinet/ip.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#endif
#if defined(IPV6_JOIN_GROUP) && !defined(IPV6_ADD_MEMBERSHIP)
# define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP