From 6763201cc5747deabbc7e4dc6ae215b8823f8b88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AB=8F=E8=A8=AA=E5=AD=90?= Date: Fri, 14 Jun 2024 21:41:54 +0900 Subject: [PATCH] support openbsd --- .gitignore | 1 + ares/n64/vulkan/parallel-rdp/util/timer.cpp | 4 +++- ares/n64/vulkan/parallel-rdp/vulkan/context.cpp | 9 +++++++++ hiro/GNUmakefile | 5 +++++ nall/GNUmakefile | 2 +- nall/inode.hpp | 2 +- ruby/GNUmakefile | 5 ++++- ruby/audio/oss.cpp | 4 ++++ ruby/input/joypad/uhid.cpp | 11 +++++++++++ 9 files changed, 39 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index c69bc38ba..a7fdc7fc7 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ thirdparty/SDL/libSDL2-2.0.0.dylib macos-xcode/ .swiftpm *.xcodeproj +*.core diff --git a/ares/n64/vulkan/parallel-rdp/util/timer.cpp b/ares/n64/vulkan/parallel-rdp/util/timer.cpp index 4db8e94e8..99f240558 100644 --- a/ares/n64/vulkan/parallel-rdp/util/timer.cpp +++ b/ares/n64/vulkan/parallel-rdp/util/timer.cpp @@ -109,6 +109,8 @@ int64_t get_current_time_nsecs() struct timespec ts = {}; #ifdef ANDROID constexpr auto timebase = CLOCK_MONOTONIC; +#elif defined (__OpenBSD__) + constexpr auto timebase = CLOCK_MONOTONIC; #else constexpr auto timebase = CLOCK_MONOTONIC_RAW; #endif @@ -128,4 +130,4 @@ double Timer::end() auto nt = get_current_time_nsecs(); return double(nt - t) * 1e-9; } -} \ No newline at end of file +} diff --git a/ares/n64/vulkan/parallel-rdp/vulkan/context.cpp b/ares/n64/vulkan/parallel-rdp/vulkan/context.cpp index 6ca0b70d9..4360e62cf 100644 --- a/ares/n64/vulkan/parallel-rdp/vulkan/context.cpp +++ b/ares/n64/vulkan/parallel-rdp/vulkan/context.cpp @@ -30,6 +30,15 @@ #include #include +#ifdef __OpenBSD__ +#include +#include +#include +#ifndef VK_KHR_LOAD_STORE_OP_NONE_EXTENSION_NAME +#define VK_KHR_LOAD_STORE_OP_NONE_EXTENSION_NAME "VK_KHR_load_store_op_none" +#endif +#endif + #ifndef _WIN32 #include #elif defined(_WIN32) diff --git a/hiro/GNUmakefile b/hiro/GNUmakefile index e3186b892..5b63920e6 100644 --- a/hiro/GNUmakefile +++ b/hiro/GNUmakefile @@ -74,6 +74,11 @@ ifneq ($(filter $(platform),linux bsd),) else $(error unrecognized hiro backend $(hiro)) endif + + ifeq ($(platform),bsd) + hiro.flags += -I/usr/X11R6/include -I/usr/local/include/cairo -I/usr/local/include/gtk-3.0 -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include -I/usr/local/include/pango-1.0 -I/usr/local/include/harfbuzz -I/usr/local/include/gdk-pixbuf-2.0 -I/usr/local/include/atk-1.0 + hiro.options += -L/usr/X11R6/lib + endif endif ifeq ($(hiro.resource),) diff --git a/nall/GNUmakefile b/nall/GNUmakefile index dcc7f997e..61c52b7f6 100644 --- a/nall/GNUmakefile +++ b/nall/GNUmakefile @@ -230,7 +230,7 @@ ifeq ($(lto),true) options += -Wl,-cache_path_lto,$(object.path)/lto else ifeq ($(msvc),true) options += -Wl,-lldltocache:$(object.path)/lto - else + else ifeq ($(platform),linux) options += -Wl,--thinlto-cache-dir=$(object.path)/lto endif endif diff --git a/nall/inode.hpp b/nall/inode.hpp index 11d3fa2c8..6f691a934 100644 --- a/nall/inode.hpp +++ b/nall/inode.hpp @@ -90,7 +90,7 @@ struct inode { #if defined(PLATFORM_WINDOWS) //on Windows, the last status change time (ctime) holds the file creation time instead case time::create: return data.st_ctime; - #elif defined(PLATFORM_BSD) || defined(PLATFORM_MACOS) + #elif defined(PLATFORM_MACOS) //st_birthtime may return -1 or st_atime if it is not supported by the file system //the best that can be done in this case is to return st_mtime if it's older case time::create: return min((u32)data.st_birthtime, (u32)data.st_mtime); diff --git a/ruby/GNUmakefile b/ruby/GNUmakefile index 7b81e6fc9..2ed9e781e 100644 --- a/ruby/GNUmakefile +++ b/ruby/GNUmakefile @@ -70,6 +70,9 @@ ifeq ($(platform),macos) endif else ruby.flags := $(flags.cpp) + ifeq ($(platform),bsd) + ruby.flags += -I/usr/X11R6/include + endif endif ruby.flags += -I../thirdparty @@ -134,7 +137,7 @@ ifeq ($(platform),linux) endif ifeq ($(platform),bsd) - ruby.options += -lX11 -lXext -lXrandr + ruby.options += -L/usr/X11R6/lib -lX11 -lXext -lXrandr ruby.options += $(if $(findstring audio.openal,$(ruby)),-lopenal -fuse-ld=bfd) # -fuse-ld=bfd: see FreeBSD bug 219089 endif diff --git a/ruby/audio/oss.cpp b/ruby/audio/oss.cpp index 4ac98abaf..ec36fad3c 100644 --- a/ruby/audio/oss.cpp +++ b/ruby/audio/oss.cpp @@ -1,7 +1,11 @@ #include #include #include +#ifdef __OpenBSD__ +#include +#else #include +#endif //OSSv4 features: define fallbacks for OSSv3 (where these ioctls are ignored) diff --git a/ruby/input/joypad/uhid.cpp b/ruby/input/joypad/uhid.cpp index 7201381b3..72e36e457 100644 --- a/ruby/input/joypad/uhid.cpp +++ b/ruby/input/joypad/uhid.cpp @@ -1,8 +1,15 @@ #pragma once #include +#ifdef __OpenBSD__ +#include +#include +#include +typedef uint8_t uByte; +#else #include #include +#endif struct InputJoypadUHID { Input& input; @@ -119,7 +126,11 @@ struct InputJoypadUHID { } joypad.report = hid_get_report_desc(joypad.fd); +#ifdef __OpenBSD__ + joypad.reportID = 0; +#else joypad.reportID = hid_get_report_id(joypad.fd); +#endif joypad.reportSize = hid_report_size(joypad.report, hid_input, joypad.reportID); joypad.buffer = new u8[joypad.reportSize]; auto parse = hid_start_parse(joypad.report, 1 << hid_input, joypad.reportID);