From 1454238f1e2ca81926c3b255e3ba1d6dd368916b Mon Sep 17 00:00:00 2001 From: mjbudd77 <44712797+mjbudd77@users.noreply.github.com> Date: Sat, 16 Jan 2021 14:40:28 -0500 Subject: [PATCH] Added #if defined(__unix__) in the appropriate places to allow for the code to compile for FreeBSD 12.2 using the clang 10.0.1 compiler. (#305) --- src/drivers/Qt/ConsoleWindow.cpp | 20 ++++++++++---------- src/drivers/Qt/ConsoleWindow.h | 6 +++--- src/drivers/Qt/HexEditor.cpp | 2 +- src/drivers/Qt/fceuWrapper.cpp | 4 ++-- src/drivers/Qt/sdl-throttle.cpp | 6 +++--- src/lua-engine.cpp | 4 ++-- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/drivers/Qt/ConsoleWindow.cpp b/src/drivers/Qt/ConsoleWindow.cpp index f5543b4d..6a3f735f 100644 --- a/src/drivers/Qt/ConsoleWindow.cpp +++ b/src/drivers/Qt/ConsoleWindow.cpp @@ -1,6 +1,6 @@ // GameApp.cpp // -#ifdef __linux__ +#if defined(__linux__) || defined(__unix__) #include #include #include @@ -1922,7 +1922,7 @@ void consoleWin_t::openMsgLogWin(void) int consoleWin_t::setNicePriority( int value ) { int ret = 0; -#if defined(__linux__) +#if defined(__linux__) || defined(__unix__) if ( value < -20 ) { @@ -1989,7 +1989,7 @@ int consoleWin_t::getSchedParam( int &policy, int &priority ) { int ret = 0; -#if defined(__linux__) +#if defined(__linux__) || defined(__unix__) struct sched_param p; policy = sched_getscheduler( getpid() ); @@ -2025,7 +2025,7 @@ int consoleWin_t::getSchedParam( int &policy, int &priority ) int consoleWin_t::setSchedParam( int policy, int priority ) { int ret = 0; -#if defined(__linux__) +#if defined(__linux__) || defined(__unix__) struct sched_param p; int minPrio, maxPrio; @@ -2131,13 +2131,13 @@ void consoleWin_t::updatePeriodic(void) emulatorThread_t::emulatorThread_t(void) { - #if defined(__linux__) || defined(__APPLE__) + #if defined(__linux__) || defined(__APPLE__) || defined(__unix__) pself = 0; #endif } -#ifdef __linux__ +#if defined(__linux__) #ifndef SYS_gettid #error "SYS_gettid unavailable on this system" #endif @@ -2150,7 +2150,7 @@ void emulatorThread_t::init(void) { int opt; - #if defined(__linux__) || defined(__APPLE__) + #if defined(__linux__) || defined(__APPLE__) || defined(__unix__) if ( pthread_self() == (pthread_t)QThread::currentThreadId() ) { pself = pthread_self(); @@ -2160,7 +2160,7 @@ void emulatorThread_t::init(void) #if defined(__linux__) pid = gettid(); - #elif defined(__APPLE__) + #elif defined(__APPLE__) || defined(__unix__) pid = getpid(); #endif @@ -2193,7 +2193,7 @@ void emulatorThread_t::setPriority( QThread::Priority priority_req ) int emulatorThread_t::setNicePriority( int value ) { int ret = 0; -#if defined(__linux__) +#if defined(__linux__) || defined(__unix__) if ( value < -20 ) { @@ -2273,7 +2273,7 @@ int emulatorThread_t::getSchedParam( int &policy, int &priority ) int emulatorThread_t::setSchedParam( int policy, int priority ) { int ret = 0; -#if defined(__linux__) +#if defined(__linux__) || defined(__unix__) struct sched_param p; int minPrio, maxPrio; diff --git a/src/drivers/Qt/ConsoleWindow.h b/src/drivers/Qt/ConsoleWindow.h index f59756e0..56077452 100644 --- a/src/drivers/Qt/ConsoleWindow.h +++ b/src/drivers/Qt/ConsoleWindow.h @@ -36,7 +36,7 @@ class emulatorThread_t : public QThread void setPriority( QThread::Priority priority ); - #if defined(__linux__) || defined(__APPLE__) + #if defined(__linux__) || defined(__APPLE__) || defined(__unix__) int setSchedParam( int policy, int priority ); int getSchedParam( int &policy, int &priority ); int setNicePriority( int value ); @@ -47,7 +47,7 @@ class emulatorThread_t : public QThread private: void init(void); - #if defined(__linux__) || defined(__APPLE__) + #if defined(__linux__) || defined(__APPLE__) || defined(__unix__) pthread_t pself; int pid; #endif @@ -77,7 +77,7 @@ class consoleWin_t : public QMainWindow int showListSelectDialog( const char *title, std::vector &l ); - #if defined(__linux__) || defined(__APPLE__) + #if defined(__linux__) || defined(__APPLE__) || defined(__unix__) int setSchedParam( int policy, int priority ); int getSchedParam( int &policy, int &priority ); int setNicePriority( int value ); diff --git a/src/drivers/Qt/HexEditor.cpp b/src/drivers/Qt/HexEditor.cpp index 8f078aca..12cc0258 100644 --- a/src/drivers/Qt/HexEditor.cpp +++ b/src/drivers/Qt/HexEditor.cpp @@ -2168,7 +2168,7 @@ void QHexEdit::keyPressEvent(QKeyEvent *event) { // Edit Area is ASCII key = (uchar)event->text()[0].toLatin1(); - if ( ::isascii( key ) ) + if ( isascii( key ) ) { int offs = (cursorPosX-32); int addr = 16*(lineOffset+cursorPosY) + offs; diff --git a/src/drivers/Qt/fceuWrapper.cpp b/src/drivers/Qt/fceuWrapper.cpp index a7ccd664..393dd5c9 100644 --- a/src/drivers/Qt/fceuWrapper.cpp +++ b/src/drivers/Qt/fceuWrapper.cpp @@ -213,7 +213,7 @@ int LoadGame(const char *path, bool silent) CloseGame(); } -#if defined(__linux) || defined(__APPLE__) +#if defined(__linux__) || defined(__APPLE__) || defined(__unix__) // Resolve absolute path to file if ( realpath( path, fullpath ) == NULL ) @@ -795,7 +795,7 @@ int fceuWrapperInit( int argc, char *argv[] ) g_config->setOption("SDL.LuaScript", ""); if (s != "") { -#if defined(__linux) || defined(__APPLE__) +#if defined(__linux__) || defined(__APPLE__) || defined(__unix__) // Resolve absolute path to file char fullpath[2048]; diff --git a/src/drivers/Qt/sdl-throttle.cpp b/src/drivers/Qt/sdl-throttle.cpp index 9729fc89..6d6cf8d4 100644 --- a/src/drivers/Qt/sdl-throttle.cpp +++ b/src/drivers/Qt/sdl-throttle.cpp @@ -4,7 +4,7 @@ #include "Qt/sdl.h" #include "Qt/throttle.h" -#if defined(__linux) || defined(__APPLE__) +#if defined(__linux__) || defined(__APPLE__) || defined(__unix__) #include #endif @@ -32,7 +32,7 @@ bool MaxSpeed = false; double getHighPrecTimeStamp(void) { -#if defined(__linux) || defined(__APPLE__) +#if defined(__linux__) || defined(__APPLE__) || defined(__unix__) struct timespec ts; double t; @@ -212,7 +212,7 @@ RefreshThrottleFPS(void) int highPrecSleep( double timeSeconds ) { int ret = 0; -#if defined(__linux) || defined(__APPLE__) +#if defined(__linux__) || defined(__APPLE__) || defined(__unix__) struct timespec req, rem; req.tv_sec = (long)timeSeconds; diff --git a/src/lua-engine.cpp b/src/lua-engine.cpp index fd422caf..93f05d6f 100644 --- a/src/lua-engine.cpp +++ b/src/lua-engine.cpp @@ -1,4 +1,4 @@ -#ifdef __linux +#if defined(__linux__) || defined(__unix__) #include #include #define SetCurrentDir chdir @@ -6206,7 +6206,7 @@ void FCEU_LuaFrameBoundary() FCEU_LuaOnStop(); } -#if defined(__linux) || defined(__APPLE__) +#if defined(__linux) || defined(__APPLE__) || defined(__unix__) if (exitScheduled) { // This function does not exit immediately, // it requests for the application to exit when next convenient.