Skip to content

Commit 8c7d630

Browse files
authored
Merge pull request #1825 from ligurio/ligurio/gh-xxxx-openbsd-port
Fixes for OpenBSD port
2 parents 0bd3bc7 + 6bad51e commit 8c7d630

5 files changed

Lines changed: 31 additions & 8 deletions

File tree

‎buildsystem/cpp.cmake‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,14 @@ function(declare_binary target_name output_name type)
2323
endif()
2424

2525
if(NOT "${CMAKE_CXX_FLAGS}" MATCHES "-fsanitize" AND NOT MSVC)
26-
if(APPLE)
27-
set(link_flag "-undefined,error")
28-
else()
29-
set(link_flag "--no-undefined")
30-
endif()
3126
set_target_properties("${target_name}" PROPERTIES
3227
COMPILE_FLAGS "${EXTRA_FLAGS}"
33-
LINK_FLAGS "-Wl,${link_flag}"
3428
)
29+
if(APPLE)
30+
set_target_properties("${target_name}" PROPERTIES LINK_FLAGS "-Wl,-undefined,error")
31+
elseif(NOT CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
32+
set_target_properties("${target_name}" PROPERTIES LINK_FLAGS "-Wl,--no-undefined")
33+
endif()
3534
endif()
3635
else()
3736
message(FATAL_ERROR "declare_binary encountered unknown flag: ${flag}")

‎copying.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ _the openage authors_ are:
173173
| Luca Pizzagalli | lucapizzagalli | web à lucapizzagalli dawt com |
174174
| Erwan Billard | iacker | 82095453+iacker à users dawt noreply dawt github dawt com |
175175
| Deniz Kökden | denizkoekden | koekdendeniz à gmail dawt com |
176+
| Sergey Bronnikov | ligurio | estetus à gmail dawt com |
176177

177178
If you're a first-time committer, add yourself to the above list. This is not
178179
just for legal reasons, but also to keep an overview of all those nicknames.

‎libopenage/error/handlers.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ namespace {
4444
bool exit_ok;
4545

4646
std::terminate_handler old_terminate_handler;
47-
#ifdef __FreeBSD__
47+
#if defined(__FreeBSD__) || defined(__OpenBSD__)
4848
typedef sig_t sighandler_t;
4949
#endif
5050
sighandler_t old_sigsegv_handler;

‎libopenage/util/os.cpp‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <mach-o/dyld.h>
1515
#endif
1616

17-
#ifdef __FreeBSD__
17+
#if defined(__FreeBSD__) || defined(__OpenBSD__)
1818
#include <sys/sysctl.h>
1919
#include <sys/types.h>
2020
#endif
@@ -89,6 +89,24 @@ std::string self_exec_filename() {
8989
return std::string{buf.get()};
9090
}
9191

92+
#elif defined(__OpenBSD__)
93+
// OpenBSD provides neither /proc/self/exe nor KERN_PROC_PATHNAME;
94+
// fall back to the argv[0] used to start this process.
95+
int mib[4] = {CTL_KERN, KERN_PROC_ARGS, getpid(), KERN_PROC_ARGV};
96+
size_t bufsize = 0;
97+
98+
if (sysctl(mib, 4, nullptr, &bufsize, nullptr, 0) < 0) {
99+
return std::string{};
100+
}
101+
102+
std::unique_ptr<char[]> buf{new char[bufsize]};
103+
104+
if (sysctl(mib, 4, buf.get(), &bufsize, nullptr, 0) < 0) {
105+
return std::string{};
106+
}
107+
108+
return std::string{buf.get()};
109+
92110
#elif _WIN32
93111
// TODO not yet implemented
94112
return std::string("openage.exe"); // FIXME: wild guess though

‎libopenage/util/pty.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
#ifdef __APPLE__
66
#include <util.h>
7+
#elif defined(__OpenBSD__)
8+
#include <sys/ioctl.h>
9+
#include <sys/types.h>
10+
#include <termios.h>
11+
#include <util.h>
712
#elif defined(__FreeBSD__)
813
#include <libutil.h>
914
#include <sys/ioctl.h>

0 commit comments

Comments
 (0)