1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:38:10 +00:00
serenity/Ports/cmake/patches/0009-purge-non-serenity-syscalls.patch
AnotherTest 80d6f46d4e Ports: Add a cmake port
Yes, you build this *inside* serenity.
2021-02-15 17:32:56 +01:00

199 lines
5.7 KiB
Diff

From 6939797ada5dbf5545d857cc60cfd5a8ceddb0ae Mon Sep 17 00:00:00 2001
From: AnotherTest <ali.mpfard@gmail.com>
Date: Fri, 12 Feb 2021 04:49:01 +0330
Subject: [PATCH 09/11] purge non-serenity syscalls
very breaky!
---
Utilities/cmlibuv/src/unix/fs.c | 31 ++++++++++++++++++++++++++++
Utilities/cmlibuv/src/unix/poll.c | 2 ++
Utilities/cmlibuv/src/unix/process.c | 2 ++
Utilities/cmlibuv/src/unix/stream.c | 3 +--
4 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/Utilities/cmlibuv/src/unix/fs.c b/Utilities/cmlibuv/src/unix/fs.c
index 48c0123..fd102a8 100644
--- a/Utilities/cmlibuv/src/unix/fs.c
+++ b/Utilities/cmlibuv/src/unix/fs.c
@@ -85,6 +85,8 @@
defined(__HAIKU__) || \
defined(__QNX__)
# include <sys/statvfs.h>
+#elif defined(__serenity__)
+// No statfs
#else
# include <sys/statfs.h>
#endif
@@ -540,7 +542,11 @@ static ssize_t uv__fs_scandir(uv_fs_t* req) {
int n;
dents = NULL;
+#ifndef __serenity__
n = scandir(req->path, &dents, uv__fs_scandir_filter, uv__fs_scandir_sort);
+#else
+ n = 0;
+#endif
/* NOTE: We will use nbufs as an index field */
req->nbufs = 0;
@@ -651,6 +657,9 @@ static int uv__fs_statfs(uv_fs_t* req) {
struct statvfs buf;
if (0 != statvfs(req->path, &buf))
+#elif defined(__serenity__)
+ char buf = 0;
+ if (1)
#else
struct statfs buf;
@@ -658,6 +667,7 @@ static int uv__fs_statfs(uv_fs_t* req) {
#endif /* defined(__sun) */
return -1;
+#if !defined(__serenity__)
stat_fs = uv__malloc(sizeof(*stat_fs));
if (stat_fs == NULL) {
errno = ENOMEM;
@@ -681,6 +691,7 @@ static int uv__fs_statfs(uv_fs_t* req) {
stat_fs->f_files = buf.f_files;
stat_fs->f_ffree = buf.f_ffree;
req->ptr = stat_fs;
+#endif // !defined(__serenity__)
return 0;
}
@@ -1107,7 +1118,11 @@ static ssize_t uv__fs_write(uv_fs_t* req) {
r = writev(req->file, (struct iovec*) req->bufs, req->nbufs);
} else {
if (req->nbufs == 1) {
+# if defined(__serenity__)
+ r = -1;
+# else
r = pwrite(req->file, req->bufs[0].base, req->bufs[0].len, req->off);
+# endif
goto done;
}
#if HAVE_PREADV
@@ -1117,7 +1132,11 @@ static ssize_t uv__fs_write(uv_fs_t* req) {
if (no_pwritev) retry:
# endif
{
+# if defined(__serenity__)
+ r = -1;
+# else
r = pwrite(req->file, req->bufs[0].base, req->bufs[0].len, req->off);
+# endif
}
# if defined(__linux__)
else {
@@ -1604,7 +1623,9 @@ static void uv__fs_work(struct uv__work* w) {
X(COPYFILE, uv__fs_copyfile(req));
X(FCHMOD, fchmod(req->file, req->mode));
X(FCHOWN, fchown(req->file, req->uid, req->gid));
+#ifndef __serenity__
X(LCHOWN, lchown(req->path, req->uid, req->gid));
+#endif
X(FDATASYNC, uv__fs_fdatasync(req));
X(FSTAT, uv__fs_fstat(req->file, &req->statbuf));
X(FSYNC, uv__fs_fsync(req));
@@ -1618,7 +1639,9 @@ static void uv__fs_work(struct uv__work* w) {
X(MKSTEMP, uv__fs_mkstemp(req));
X(OPEN, uv__fs_open(req));
X(READ, uv__fs_read(req));
+#ifndef __serenity__
X(SCANDIR, uv__fs_scandir(req));
+#endif
X(OPENDIR, uv__fs_opendir(req));
X(READDIR, uv__fs_readdir(req));
X(CLOSEDIR, uv__fs_closedir(req));
@@ -1628,7 +1651,9 @@ static void uv__fs_work(struct uv__work* w) {
X(RMDIR, rmdir(req->path));
X(SENDFILE, uv__fs_sendfile(req));
X(STAT, uv__fs_stat(req->path, &req->statbuf));
+#ifndef __serenity__
X(STATFS, uv__fs_statfs(req));
+#endif
X(SYMLINK, symlink(req->path, req->new_path));
X(UNLINK, unlink(req->path));
X(UTIME, uv__fs_utime(req));
@@ -1743,7 +1768,9 @@ int uv_fs_lchown(uv_loop_t* loop,
uv_uid_t uid,
uv_gid_t gid,
uv_fs_cb cb) {
+#ifndef __serenity__
INIT(LCHOWN);
+#endif
PATH;
req->uid = uid;
req->gid = gid;
@@ -1912,7 +1939,9 @@ int uv_fs_scandir(uv_loop_t* loop,
const char* path,
int flags,
uv_fs_cb cb) {
+#ifndef __serenity__
INIT(SCANDIR);
+#endif
PATH;
req->flags = flags;
POST;
@@ -2134,7 +2163,9 @@ int uv_fs_statfs(uv_loop_t* loop,
uv_fs_t* req,
const char* path,
uv_fs_cb cb) {
+#ifndef __serenity__
INIT(STATFS);
+#endif
PATH;
POST;
}
diff --git a/Utilities/cmlibuv/src/unix/poll.c b/Utilities/cmlibuv/src/unix/poll.c
index 3d5022b..721423f 100644
--- a/Utilities/cmlibuv/src/unix/poll.c
+++ b/Utilities/cmlibuv/src/unix/poll.c
@@ -79,9 +79,11 @@ int uv_poll_init(uv_loop_t* loop, uv_poll_t* handle, int fd) {
* Workaround for e.g. kqueue fds not supporting ioctls.
*/
err = uv__nonblock(fd, 1);
+#ifndef __serenity__
if (err == UV_ENOTTY)
if (uv__nonblock == uv__nonblock_ioctl)
err = uv__nonblock_fcntl(fd, 1);
+#endif
if (err)
return err;
diff --git a/Utilities/cmlibuv/src/unix/process.c b/Utilities/cmlibuv/src/unix/process.c
index 08aa2f3..135260f 100644
--- a/Utilities/cmlibuv/src/unix/process.c
+++ b/Utilities/cmlibuv/src/unix/process.c
@@ -129,6 +129,8 @@ static int uv__make_socketpair(int fds[2]) {
return UV__ERR(errno);
return 0;
+#elif defined(__serenity__)
+ return UV__ERR(ENOTSUP);
#else
int err;
diff --git a/Utilities/cmlibuv/src/unix/stream.c b/Utilities/cmlibuv/src/unix/stream.c
index 3b6da8d..3e2ed5e 100644
--- a/Utilities/cmlibuv/src/unix/stream.c
+++ b/Utilities/cmlibuv/src/unix/stream.c
@@ -985,13 +985,12 @@ uv_handle_type uv__handle_type(int fd) {
case AF_UNIX:
return UV_NAMED_PIPE;
case AF_INET:
- case AF_INET6:
return UV_TCP;
}
}
if (type == SOCK_DGRAM &&
- (ss.ss_family == AF_INET || ss.ss_family == AF_INET6))
+ (ss.ss_family == AF_INET))
return UV_UDP;
return UV_UNKNOWN_HANDLE;
--
2.30.1