1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-15 11:03:00 +01:00

Support NetBSD and simplify platform ifdefs. (#10271)

For files intended to support unixy freedesktopy systems,
reduce the ifdef down to __unix__ && !__APPLE__ && !__ANDROID__,
rather than naming linux and all the BSDs and so on by hand.

Should simplify adding support for systems like illumos in the
future.

Co-authored-by: Michael Steenbeek <m.o.steenbeek@gmail.com>
This commit is contained in:
nia
2019-12-22 16:07:40 +00:00
committed by Michael Steenbeek
parent 96ff8fe7a1
commit addd27d4dc
4 changed files with 14 additions and 7 deletions

View File

@@ -7,7 +7,7 @@
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#if (defined(__linux__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__)) && !defined(__ANDROID__)
#if (defined(__unix__) || defined(__EMSCRIPTEN__)) && !defined(__ANDROID__) && !defined(__APPLE__)
# include "UiContext.h"
@@ -393,4 +393,4 @@ namespace OpenRCT2::Ui
}
} // namespace OpenRCT2::Ui
#endif // __linux__ || __OpenBSD__
#endif // (defined(__unix__) || defined(__EMSCRIPTEN__)) && !defined(__ANDROID__) && !defined(__APPLE__)

View File

@@ -56,6 +56,9 @@
#ifdef __FreeBSD__
# define OPENRCT2_PLATFORM "FreeBSD"
#endif
#ifdef __NetBSD__
# define OPENRCT2_PLATFORM "NetBSD"
#endif
#ifdef __ANDROID__
# define OPENRCT2_PLATFORM "Android"
#endif

View File

@@ -11,7 +11,7 @@
// Despite the name, this file contains support for more OSs besides Linux, provided the necessary ifdefs remain small.
// Otherwise, they should be spun off into their own files.
#if (defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)) && !defined(__ANDROID__)
#if defined(__unix__) && !defined(__ANDROID__) && !defined(__APPLE__)
# ifdef __FreeBSD__
# include <sys/sysctl.h>

View File

@@ -7,16 +7,16 @@
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#if defined(__FreeBSD__) || defined(__OpenBSD__) || (defined(__linux__) && !defined(__ANDROID__))
#if defined(__unix__) && !defined(__ANDROID__) && !defined(__APPLE__)
# include <limits.h>
# include <pwd.h>
# include <vector>
# if defined(__FreeBSD__)
# if defined(__FreeBSD__) || defined(__NetBSD__)
# include <stddef.h>
# include <sys/param.h>
# include <sys/sysctl.h>
# endif // __FreeBSD__
# endif // __FreeBSD__ || __NetBSD__
# if defined(__linux__)
// for PATH_MAX
# include <linux/limits.h>
@@ -129,8 +129,12 @@ namespace Platform
{
log_fatal("failed to read /proc/self/exe");
}
# elif defined(__FreeBSD__)
# elif defined(__FreeBSD__) || defined(__NetBSD__)
# if defined(__FreeBSD__)
const int32_t mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
# else
const int32_t mib[] = { CTL_KERN, KERN_PROC_ARGS, -1, KERN_PROC_PATHNAME };
# endif
auto exeLen = sizeof(exePath);
if (sysctl(mib, 4, exePath, &exeLen, nullptr, 0) == -1)
{