Skip to content

Commit c707414

Browse files
committed
(Partially) fix compilation for OpenBSD
1 parent 4ce466d commit c707414

File tree

10 files changed

+1000
-11
lines changed

10 files changed

+1000
-11
lines changed

core/variant/variant.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@
6161
#include "core/variant/callable.h"
6262
#include "core/variant/dictionary.h"
6363

64+
#include <type_traits>
65+
6466
class Object;
6567
class RefCounted;
6668

@@ -488,6 +490,20 @@ class Variant {
488490
Object *get_validated_object() const;
489491
Object *get_validated_object_with_check(bool &r_previously_freed) const;
490492

493+
// Template constructor for integral types.
494+
// _should_ maintain platform compatibility _and_ fix
495+
// OpenBSD's "ambiguous" conversion errors.
496+
template <typename T, typename = typename std::enable_if<std::is_integral<T>::value>::type>
497+
Variant(T p_val) {
498+
if constexpr (std::is_same<T, bool>::value) {
499+
type = BOOL;
500+
_data._bool = p_val;
501+
} else {
502+
type = INT;
503+
_data._int = static_cast<int64_t>(p_val);
504+
}
505+
}
506+
491507
Variant(bool p_bool);
492508
Variant(int64_t p_int64);
493509
Variant(int32_t p_int32);

modules/camera/config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
def can_build(env, platform):
22
import sys
33

4-
if sys.platform.startswith("freebsd"):
4+
# Camera module not supported on BSDs
5+
if "bsd" in sys.platform.lower():
56
return False
67
return platform == "macos" or platform == "windows" or platform == "linuxbsd"
78

modules/openxr/SCsub

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ elif env["platform"] == "linuxbsd":
3131
env_openxr.AppendUnique(CPPDEFINES=["XR_USE_PLATFORM_EGL"])
3232

3333
# FIXME: Review what needs to be set for Android and macOS.
34-
# FreeBSD uses non-standard getenv functions.
35-
if not sys.platform.startswith("freebsd"):
34+
# BSDs use non-standard getenv functions.
35+
if "bsd" not in sys.platform.lower():
3636
env_openxr.AppendUnique(CPPDEFINES=["HAVE_SECURE_GETENV"])
3737
elif env["platform"] == "windows":
3838
env_openxr.AppendUnique(CPPDEFINES=["XR_OS_WINDOWS", "NOMINMAX", "XR_USE_PLATFORM_WIN32"])

modules/raycast/config.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
def can_build(env, platform):
2+
import sys
3+
24
# Supported architectures and platforms depend on the Embree library.
35
if env["arch"] == "arm64" and platform == "windows" and env.msvc:
46
return False
7+
# OpenBSD doesn't have the required headers.
8+
if sys.platform.startswith("openbsd"):
9+
return False
510
if env["arch"] in ["x86_64", "arm64", "wasm32"]:
611
return True
712
if env["arch"] == "x86_32" and platform == "windows":

platform/linuxbsd/wayland/detect_prime_egl.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@
3838

3939
#include <stdlib.h>
4040

41+
#ifdef __OpenBSD__
42+
// Map `quick_exit` to `_Exit`
43+
// See reason in: GH-92130#issuecomment-2127135908
44+
#define quick_exit _Exit
45+
#endif
46+
4147
#include <cstring>
4248

4349
#include <sys/types.h>

platform/linuxbsd/wayland/wayland_thread.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,7 @@
3232

3333
#ifdef WAYLAND_ENABLED
3434

35-
#ifdef __FreeBSD__
36-
#include <dev/evdev/input-event-codes.h>
37-
#else
38-
// Assume Linux.
39-
#include <linux/input-event-codes.h>
40-
#endif
35+
#include "thirdparty/linuxbsd_headers/linux/input-event-codes.h"
4136

4237
// For the actual polling thread.
4338
#include <poll.h>

platform/linuxbsd/x11/detect_prime_x11.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@
4747
#endif
4848

4949
#include <stdlib.h>
50+
51+
#ifdef __OpenBSD__
52+
// Map `quick_exit` to `_Exit`
53+
// See reason in: GH-92130#issuecomment-2127135908
54+
#define quick_exit _Exit
55+
#endif
56+
5057
#include <string.h>
5158
#include <sys/types.h>
5259
#include <sys/wait.h>

thirdparty/jolt_physics/Jolt/Core/Core.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@
8585
#define JPH_PLATFORM_LINUX
8686
#elif defined(__FreeBSD__)
8787
#define JPH_PLATFORM_FREEBSD
88+
#elif defined(__OpenBSD__)
89+
#define JPH_PLATFORM_OPENBSD
8890
#elif defined(__APPLE__)
8991
#include <TargetConditionals.h>
9092
#if defined(TARGET_OS_IPHONE) && !TARGET_OS_IPHONE
@@ -390,7 +392,7 @@
390392
// Creating one should only be a couple of minutes of work if you have the documentation for the platform
391393
// (you only need to define JPH_BREAKPOINT, JPH_PLATFORM_BLUE_GET_TICKS, JPH_PLATFORM_BLUE_MUTEX*, JPH_PLATFORM_BLUE_RWLOCK* and include the right header).
392394
#include <Jolt/Core/PlatformBlue.h>
393-
#elif defined(JPH_PLATFORM_LINUX) || defined(JPH_PLATFORM_ANDROID) || defined(JPH_PLATFORM_MACOS) || defined(JPH_PLATFORM_IOS) || defined(JPH_PLATFORM_FREEBSD)
395+
#elif defined(JPH_PLATFORM_LINUX) || defined(JPH_PLATFORM_ANDROID) || defined(JPH_PLATFORM_MACOS) || defined(JPH_PLATFORM_IOS) || defined(JPH_PLATFORM_FREEBSD) || defined(JPH_PLATFORM_OPENBSD)
394396
#if defined(JPH_CPU_X86)
395397
#define JPH_BREAKPOINT __asm volatile ("int $0x3")
396398
#elif defined(JPH_CPU_ARM) || defined(JPH_CPU_RISCV) || defined(JPH_CPU_E2K) || defined(JPH_CPU_PPC) || defined(JPH_CPU_LOONGARCH)

thirdparty/linuxbsd_headers/README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ Patches in the `patches` directory should be re-applied after updates.
3535
- License: MIT
3636

3737

38+
## linux
39+
40+
- Upstream: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
41+
- Version: 5.15
42+
- License: GPL-2
43+
44+
3845
## pulse
3946

4047
- Upstream: http://pulseaudio.org/
@@ -66,7 +73,7 @@ Patches in the `patches` directory should be re-applied after updates.
6673
## X11
6774

6875
- Upstream: https://x.org/wiki/
69-
- Version:
76+
- Version:
7077
* Xcursor: 1.2.0
7178
* Xext: 1.3.5
7279
* Xinerama: 1.1.4

0 commit comments

Comments
 (0)