summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorGuilherme Janczak <guilherme.janczak@yandex.com>2024-05-03 00:30:15 +0000
committerGuilherme Janczak <guilherme.janczak@yandex.com>2024-05-03 15:12:29 +0000
commit0859d2c4721d6f7748d60cd232f0006e0957ef2f (patch)
tree39d3ba60c352a1316ee01d306642ea2d5c430042 /Source/Core
parent5817be7bd3ac1b3f68a24410dc416d69ae2ff20f (diff)
improve NetBSD-specific code
NetBSD doesn't put packages in /usr/local like /CMakeLists.txt thought. The `#ifdef __NetBSD__` around iconv was actually breaking compilation on NetBSD when using the system libiconv (there's also a GNU iconv package) A C program included from C++ source broke on NetBSD specifically, work around it. This doesn't fix compilation on NetBSD, which is currently broken, but is closer to correct.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Common/StringUtil.cpp8
-rw-r--r--Source/Core/Core/PowerPC/Expression.cpp11
2 files changed, 11 insertions, 8 deletions
diff --git a/Source/Core/Common/StringUtil.cpp b/Source/Core/Common/StringUtil.cpp
index f960d6fcc6..4551600b4e 100644
--- a/Source/Core/Common/StringUtil.cpp
+++ b/Source/Core/Common/StringUtil.cpp
@@ -35,9 +35,6 @@
constexpr u32 CODEPAGE_SHIFT_JIS = 932;
constexpr u32 CODEPAGE_WINDOWS_1252 = 1252;
#else
-#if defined(__NetBSD__)
-#define LIBICONV_PLUG
-#endif
#include <errno.h>
#include <iconv.h>
#include <locale.h>
@@ -528,13 +525,8 @@ std::string CodeTo(const char* tocode, const char* fromcode, std::basic_string_v
while (src_bytes != 0)
{
size_t const iconv_result =
-#if defined(__NetBSD__)
- iconv(conv_desc, reinterpret_cast<const char**>(&src_buffer), &src_bytes, &dst_buffer,
- &dst_bytes);
-#else
iconv(conv_desc, const_cast<char**>(reinterpret_cast<const char**>(&src_buffer)),
&src_bytes, &dst_buffer, &dst_bytes);
-#endif
if ((size_t)-1 == iconv_result)
{
if (EILSEQ == errno || EINVAL == errno)
diff --git a/Source/Core/Core/PowerPC/Expression.cpp b/Source/Core/Core/PowerPC/Expression.cpp
index 79307f4460..023f1f5e3e 100644
--- a/Source/Core/Core/PowerPC/Expression.cpp
+++ b/Source/Core/Core/PowerPC/Expression.cpp
@@ -11,6 +11,17 @@
#include <string_view>
#include <utility>
+// https://github.com/zserge/expr/ is a C program and sorta valid C++.
+// When included in a C++ program, it's treated as a C++ code, and it may cause
+// issues: <cmath> may already be included, if so, including <math.h> may
+// not do anything. <math.h> is obligated to put its functions in the global
+// namespace, while <cmath> may or may not. The C code we're interpreting as
+// C++ won't call functions by their qualified names. The code may work anyway
+// if <cmath> puts its functions in the global namespace, or if the functions
+// are actually macros that expand inline, both of which are common.
+// NetBSD 10.0 i386 is an exception, and we need `using` there.
+using std::isinf;
+using std::isnan;
#include <expr.h>
#include "Common/BitUtils.h"