Files
haikuports/dev-libs/rocksdb/patches/rocksdb-9.10.0.patchset
2025-01-30 13:13:22 +00:00

121 lines
4.2 KiB
Plaintext

From 9691aa202cf82c88808721ad0816d4514944c779 Mon Sep 17 00:00:00 2001
From: "Mika T. Lindqvist" <postmaster@raasu.org>
Date: Mon, 30 Sep 2024 18:13:32 +0000
Subject: Initial support for Haiku.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f1103c5..2271309 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -506,6 +506,8 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "DragonFly")
add_definitions(-DOS_DRAGONFLYBSD)
elseif(CMAKE_SYSTEM_NAME MATCHES "Android")
add_definitions(-DOS_ANDROID)
+elseif(CMAKE_SYSTEM_NAME MATCHES "Haiku")
+ add_definitions(-DOS_HAIKU)
elseif(CMAKE_SYSTEM_NAME MATCHES "Windows")
add_definitions(-DWIN32 -DOS_WIN -D_MBCS -DWIN64 -DNOMINMAX)
if(MINGW)
diff --git a/env/fs_posix.cc b/env/fs_posix.cc
index 82fb9fb..4c83c95 100644
--- a/env/fs_posix.cc
+++ b/env/fs_posix.cc
@@ -585,8 +585,15 @@ class PosixFileSystem : public FileSystem {
while ((entry = readdir(d)) != nullptr) {
// filter out '.' and '..' directory entries
// which appear only on some platforms
+#if OS_HAIKU
+ struct stat entry_stat;
+ stat(entry->d_name, &entry_stat);
+ bool is_directory = S_ISDIR(entry_stat.st_mode);
+#else
+ bool is_directory = entry->d_type = DT_DIR;
+#endif
const bool ignore =
- entry->d_type == DT_DIR &&
+ is_directory &&
(strcmp(entry->d_name, ".") == 0 ||
strcmp(entry->d_name, "..") == 0
#ifndef ASSERT_STATUS_CHECKED
@@ -727,8 +734,12 @@ class PosixFileSystem : public FileSystem {
return IOError("stat file", second, errno);
}
+#if OS_HAIKU
+ if (statbuf[0].st_dev != statbuf[1].st_dev ||
+#else
if (major(statbuf[0].st_dev) != major(statbuf[1].st_dev) ||
minor(statbuf[0].st_dev) != minor(statbuf[1].st_dev) ||
+#endif
statbuf[0].st_ino != statbuf[1].st_ino) {
*res = false;
} else {
diff --git a/env/io_posix.cc b/env/io_posix.cc
index 231e88d..0159bca 100644
--- a/env/io_posix.cc
+++ b/env/io_posix.cc
@@ -1234,6 +1234,10 @@ IOStatus PosixMmapFile::Sync(const IOOptions& /*opts*/,
if (::fcntl(fd_, F_FULLFSYNC) < 0) {
return IOError("while fcntl(F_FULLSYNC) mmapped file", filename_, errno);
}
+#elif OS_HAIKU
+ if (fsync(fd_) < 0) {
+ return IOError("While fsync mmapped file", filename_, errno);
+ }
#else // HAVE_FULLFSYNC
if (fdatasync(fd_) < 0) {
return IOError("While fdatasync mmapped file", filename_, errno);
@@ -1453,6 +1457,10 @@ IOStatus PosixWritableFile::Sync(const IOOptions& /*opts*/,
if (::fcntl(fd_, F_FULLFSYNC) < 0) {
return IOError("while fcntl(F_FULLFSYNC)", filename_, errno);
}
+#elif OS_HAIKU
+ if (fsync(fd_) < 0) {
+ return IOError("While fsync", filename_, errno);
+ }
#else // HAVE_FULLFSYNC
if (fdatasync(fd_) < 0) {
return IOError("While fdatasync", filename_, errno);
@@ -1650,6 +1658,10 @@ IOStatus PosixRandomRWFile::Sync(const IOOptions& /*opts*/,
if (::fcntl(fd_, F_FULLFSYNC) < 0) {
return IOError("while fcntl(F_FULLFSYNC) random rw file", filename_, errno);
}
+#elif OS_HAIKU
+ if (fsync(fd_) < 0) {
+ return IOError("While fsync random read/write file", filename_, errno);
+ }
#else // HAVE_FULLFSYNC
if (fdatasync(fd_) < 0) {
return IOError("While fdatasync random read/write file", filename_, errno);
diff --git a/env/io_posix.h b/env/io_posix.h
index 60788df..e816021 100644
--- a/env/io_posix.h
+++ b/env/io_posix.h
@@ -30,7 +30,7 @@
// For non linux platform, the following macros are used only as place
// holder.
#if !(defined OS_LINUX) && !(defined OS_FREEBSD) && !(defined CYGWIN) && \
- !(defined OS_AIX) && !(defined OS_ANDROID)
+ !(defined OS_AIX) && !(defined OS_ANDROID) && !(defined OS_HAIKU)
#define POSIX_FADV_NORMAL 0 /* [MC1] no further special treatment */
#define POSIX_FADV_RANDOM 1 /* [MC1] expect random page refs */
#define POSIX_FADV_SEQUENTIAL 2 /* [MC1] expect sequential page refs */
diff --git a/port/port_posix.h b/port/port_posix.h
index 386be53..a127525 100644
--- a/port/port_posix.h
+++ b/port/port_posix.h
@@ -21,7 +21,9 @@
// in fact, we could use that one
#define ROCKSDB_PRIszt "zu"
+#ifndef OS_HAIKU
#define __declspec(S)
+#endif
#undef PLATFORM_IS_LITTLE_ENDIAN
#if defined(OS_MACOSX)
--
2.45.2