Select the types of activity you want to include in your feed.
Remove libkqueue and use in-kernel kqueues
This commit pretty much just implements the bridge between userspace and kernel code for kqueues; for the real details of the change, check out the commit in the LKM.
···102102 ${CMAKE_BINARY_DIR}/${DARLING_SDK_RELATIVE_PATH}/usr/include/libxml2
103103)
104104105105-add_subdirectory(external/libkqueue)
106106-107105# needs to come before libplatform because it generates mig headers that libplatform needs
108106add_subdirectory(kernel)
109107
···1010#include "kqueue.h"
1111#include "../bsdthread/workq_kernreturn.h"
12121313-static int default_kq = -1;
1313+// not static because `mach_init.c` needs to reset it on fork
1414+// (but since we're using symbol visibility, no one else will be able to see it, so it's ok)
1515+// we can remove this once our LKM supports kqueue workqs and workloops (at that point, this syscall will turn into a simple trap into the LKM)
1616+int default_kq = -1;
14171518extern void* memmove(void* dst, const void* src, __SIZE_TYPE__ n);
1919+2020+// we have an LKM trap for kevent_qos, but due to our LKM not supporting workqs and workloops yet,
2121+// it's easier to keep our old behavior and translate this into a kevent64 call and handle workq stuff ourselves.
2222+// TODO: support workqs and workloops in the LKM (requires in-kernel pthread operations)
16231724static void kevent_qos_to_64(const struct kevent_qos_s *ev, struct kevent64_s* ev64);
1825static void kevent_64_to_qos(const struct kevent64_s* ev64, struct kevent_qos_s *ev);
···3340 if (default_kq == -1)
3441 {
3542 default_kq = sys_kqueue();
3636- sys_fcntl(default_kq, F_SETFD, FD_CLOEXEC);
3743 }
38443945 if (changelist != NULL && nchanges > 0)
···33#include "../errno.h"
44#include <linux-syscalls/linux.h>
5566-__attribute__((weak))
77-__attribute__((visibility("default")))
88-void kqueue_dup(int oldfd, int newfd) { }
99-106long sys_dup(int fd)
117{
128 int ret;
···1410 ret = LINUX_SYSCALL1(__NR_dup, fd);
1511 if (ret < 0)
1612 ret = errno_linux_to_bsd(ret);
1717- else
1818- kqueue_dup(fd, ret);
19132014 return ret;
2115}
-4
src/kernel/emulation/linux/unistd/dup2.c
···44#include <linux-syscalls/linux.h>
55#include "../duct_errno.h"
6677-extern void kqueue_dup(int oldfd, int newfd);
88-97long sys_dup2(int fd_from, int fd_to)
108{
119 int ret;
···2220 #endif
2321 if (ret < 0)
2422 ret = errno_linux_to_bsd(ret);
2525- else
2626- kqueue_dup(fd_from, fd_to);
27232824 return ret;
2925}
+4
src/kernel/libsyscall/mach/mach_init.c
···64646565#ifdef DARLING
6666#include <darling/lkm/api.h>
6767+6868+extern int default_kq;
6769#endif
68706971mach_port_t bootstrap_port = MACH_PORT_NULL;
···139141_mach_fork_child(void)
140142{
141143#ifdef DARLING
144144+ // we only have to reset to `-1`; the LKM takes care of closing it for us
145145+ default_kq = -1;
142146 mach_init_doit(NULL);
143147#else
144148 mach_init_doit();