mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 17:40:27 +00:00
4490668af2
fio allows you to test various different IO subsystems and patterns. It can help us test and benchmark the I/O subsystems of Serenity. This port gets the fio bootstrapped and working, using the included .fio file, I have been able to test the file I/O performance already.
128 lines
2.6 KiB
Diff
128 lines
2.6 KiB
Diff
From 50d3ac3b6faa9d117ec26296067aecee988dbd8c Mon Sep 17 00:00:00 2001
|
|
From: Brian Gianforcaro <b.gianfo@gmail.com>
|
|
Date: Tue, 21 Dec 2021 23:47:36 -0800
|
|
Subject: [PATCH 2/4] Port: fio - Add SerenityOS platform support
|
|
|
|
---
|
|
os/os-serenity.h | 87 ++++++++++++++++++++++++++++++++++++++++++++++++
|
|
os/os.h | 3 ++
|
|
2 files changed, 90 insertions(+)
|
|
create mode 100644 os/os-serenity.h
|
|
|
|
diff --git a/os/os-serenity.h b/os/os-serenity.h
|
|
new file mode 100644
|
|
index 0000000..941bf09
|
|
--- /dev/null
|
|
+++ b/os/os-serenity.h
|
|
@@ -0,0 +1,87 @@
|
|
+#ifndef FIO_OS_SERENITY_H
|
|
+#define FIO_OS_SERENITY_H
|
|
+
|
|
+#define FIO_OS os_serenity
|
|
+
|
|
+#include <sys/param.h>
|
|
+#include <sys/statvfs.h>
|
|
+#include <sys/utsname.h>
|
|
+#include <sys/mman.h>
|
|
+#include <sys/select.h>
|
|
+#include <netinet/in.h>
|
|
+
|
|
+#include "../file.h"
|
|
+
|
|
+#define FIO_NO_HAVE_SHM_H
|
|
+#define FIO_USE_GENERIC_INIT_RANDOM_STATE
|
|
+#define FIO_HAVE_FS_STAT
|
|
+#define FIO_HAVE_GETTID
|
|
+
|
|
+#define OS_MAP_ANON MAP_ANON
|
|
+
|
|
+/* Serenity doesn't support:
|
|
+ * - MADV_RANDOM
|
|
+ * - MADV_SEQUENTIAL
|
|
+ *
|
|
+ * So any values will work for these defines.
|
|
+ */
|
|
+#ifndef POSIX_MADV_RANDOM
|
|
+#define POSIX_MADV_RANDOM 0
|
|
+#endif
|
|
+
|
|
+#ifndef POSIX_MADV_SEQUENTIAL
|
|
+#define POSIX_MADV_SEQUENTIAL 0
|
|
+#endif
|
|
+
|
|
+/*
|
|
+ * Serenity doesn't have O_SYNC, so define it here so it can be
|
|
+ * rejected at runtime instead.
|
|
+ */
|
|
+#define O_SYNC 0x2000000
|
|
+
|
|
+static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes)
|
|
+{
|
|
+ // TODO: Implement
|
|
+ return ENOTSUP;
|
|
+}
|
|
+
|
|
+static inline int blockdev_invalidate_cache(struct fio_file *f)
|
|
+{
|
|
+ // TODO: Implement
|
|
+ return ENOTSUP;
|
|
+}
|
|
+
|
|
+static inline unsigned long long os_phys_mem(void)
|
|
+{
|
|
+ // TODO: Implement
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+static inline int nice(int incr)
|
|
+{
|
|
+ // TODO: Implement
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+static inline unsigned long long get_fs_free_size(const char *path)
|
|
+{
|
|
+ unsigned long long ret;
|
|
+ struct statvfs s;
|
|
+
|
|
+ if (statvfs(path, &s) < 0)
|
|
+ return -1ULL;
|
|
+
|
|
+ ret = s.f_frsize;
|
|
+ ret *= (unsigned long long) s.f_bfree;
|
|
+ return ret;
|
|
+}
|
|
+
|
|
+static inline in_addr_t inet_network(const char *cp)
|
|
+{
|
|
+ in_addr_t hbo;
|
|
+ in_addr_t nbo = inet_addr(cp);
|
|
+ hbo = ((nbo & 0xFF) << 24) + ((nbo & 0xFF00) << 8) + ((nbo & 0xFF0000) >> 8) + ((nbo & 0xFF000000) >> 24);
|
|
+ return hbo;
|
|
+}
|
|
+
|
|
+#endif
|
|
diff --git a/os/os.h b/os/os.h
|
|
index 5965d7b..46604f7 100644
|
|
--- a/os/os.h
|
|
+++ b/os/os.h
|
|
@@ -24,6 +24,7 @@ enum {
|
|
os_windows,
|
|
os_android,
|
|
os_dragonfly,
|
|
+ os_serenity,
|
|
|
|
os_nr,
|
|
};
|
|
@@ -55,6 +56,8 @@ typedef enum {
|
|
#include "os-windows.h"
|
|
#elif defined (__DragonFly__)
|
|
#include "os-dragonfly.h"
|
|
+#elif defined (__serenity__)
|
|
+#include "os-serenity.h"
|
|
#else
|
|
#error "unsupported os"
|
|
#endif
|
|
--
|
|
2.32.0
|
|
|