Commit: bc8952e3e5ef62a01c8df8cfc97833aeb88f7f8f
Parent: bce2aa1f7965ced85c9c3cc2ce4a4390e14f8b8b
Author: Randy Palamar
Date: Fri, 6 Dec 2024 05:56:18 -0700
remove last syscall wrapper
Diffstat:
3 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/platform_linux_amd64.c b/platform_linux_amd64.c
@@ -33,6 +33,7 @@
#define SYS_exit_group 231
#define SYS_inotify_add_watch 254
#define SYS_inotify_rm_watch 255
+#define SYS_pselect 270
#define SYS_inotify_init1 294
#define SYS_memfd_create 319
@@ -43,6 +44,8 @@ typedef __attribute__((aligned(16))) u8 stat_buffer[144];
#define STAT_INODE(sb) STAT_BUF_MEMBER(sb, i64, 8)
#define STAT_FILE_SIZE(sb) STAT_BUF_MEMBER(sb, i64, 48)
+typedef u64 fd_set[16];
+
#define DIRENT_RECLEN_OFF 16
#define DIRENT_TYPE_OFF 18
#define DIRENT_NAME_OFF 19
diff --git a/platform_linux_common.c b/platform_linux_common.c
@@ -35,6 +35,9 @@
#define WNOHANG 1
#define W_IF_EXITED(s) (!((s) & 0x7F))
+#define FD_SET(d, s) ((s)[(d) / (8 * sizeof(*(s)))] |= (1ULL << ((d) % (8 * sizeof(*(s))))))
+#define FD_ISSET(d, s) ((s)[(d) / (8 * sizeof(*(s)))] & (1ULL << ((d) % (8 * sizeof(*(s))))))
+
#define TIOCSCTTY 0x540E
#define TIOCSWINSZ 0x5414
#define TIOCSPTLCK 0x40045431 /* (un)lock pty */
diff --git a/platform_linux_x11.c b/platform_linux_x11.c
@@ -22,7 +22,6 @@ i32 XPending(void *display);
#include "vtgl.c"
#else
#include <dlfcn.h>
-#include <time.h>
#define DEBUG_LIB_NAME "./vtgl.so"
@@ -240,9 +239,6 @@ init_window(PlatformCtx *ctx, iv2 window_size)
return window;
}
-/* TODO: remove */
-#include <sys/select.h>
-
static void
update_input(PlatformCtx *ctx)
{
@@ -264,25 +260,24 @@ update_input(PlatformCtx *ctx)
ctx->char_stream.widx = 0;
- struct timespec timeout = {.tv_nsec = 25e6};
+ i64 timeout[2] = {0, 25e6};
if (input->pending_updates) {
- timeout.tv_nsec = 0;
+ timeout[1] = 0;
input->pending_updates = 0;
}
- fd_set rfd;
- FD_ZERO(&rfd);
- FD_SET(ctx->child.handle, &rfd);
- FD_SET(ctx->inotify_fd, &rfd);
- FD_SET(ctx->win_fd, &rfd);
+ fd_set rfd = {0};
+ FD_SET(ctx->child.handle, rfd);
+ FD_SET(ctx->inotify_fd, rfd);
+ FD_SET(ctx->win_fd, rfd);
i32 max_fd = MAX(ctx->inotify_fd, ctx->child.handle);
max_fd = MAX(max_fd, ctx->win_fd);
- pselect(max_fd + 1, &rfd, NULL, NULL, &timeout, NULL);
+ syscall6(SYS_pselect, max_fd + 1, (iptr)rfd, 0, 0, (iptr)timeout, 0);
- input->data_available = FD_ISSET(ctx->child.handle, &rfd) != 0;
+ input->data_available = FD_ISSET(ctx->child.handle, rfd) != 0;
- if (FD_ISSET(ctx->inotify_fd, &rfd))
+ if (FD_ISSET(ctx->inotify_fd, rfd))
dispatch_file_watch_events(ctx);
glfwPollEvents();