common: fix cmake on linux/macos

This commit is contained in:
kojin 2021-09-03 06:43:33 -04:00 committed by Kojin
parent 831c8b9189
commit 0717bf788a
29 changed files with 61 additions and 41 deletions

View File

@ -16,9 +16,10 @@
// This module contains implementations of _aligned_malloc for platforms that don't have // This module contains implementations of _aligned_malloc for platforms that don't have
// it built into their CRT/libc. // it built into their CRT/libc.
#ifndef _WIN32 #if !defined(_WIN32)
#include "common/Assertions.h" #include "common/Assertions.h"
#include "common/ScopedAlloc.h"
void *__fastcall _aligned_malloc(size_t size, size_t align) void *__fastcall _aligned_malloc(size_t size, size_t align)
{ {

View File

@ -9,6 +9,7 @@ add_library(common)
# x86emitter sources # x86emitter sources
target_sources(common PRIVATE target_sources(common PRIVATE
AlignedMalloc.cpp
VirtualMemory.cpp VirtualMemory.cpp
EventSource.inl EventSource.inl
SafeArray.inl SafeArray.inl
@ -45,9 +46,16 @@ target_sources(common PRIVATE
emitter/legacy_sse.cpp emitter/legacy_sse.cpp
emitter/movs.cpp emitter/movs.cpp
emitter/simd.cpp emitter/simd.cpp
emitter/LnxCpuDetect.cpp
emitter/WinCpuDetect.cpp emitter/WinCpuDetect.cpp
emitter/x86emitter.cpp emitter/x86emitter.cpp
x86/MemcpyFast.cpp x86/MemcpyFast.cpp
Darwin/DarwinThreads.cpp
Darwin/DarwinMisc.cpp
Darwin/DarwinSemaphore.cpp
Linux/LnxHostSys.cpp
Linux/LnxThreads.cpp
Linux/LnxMisc.cpp
Windows/WinThreads.cpp Windows/WinThreads.cpp
Windows/WinHostSys.cpp Windows/WinHostSys.cpp
Windows/WinMisc.cpp) Windows/WinMisc.cpp)

View File

@ -13,15 +13,16 @@
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "../PrecompiledHeader.h" #if defined(__APPLE__)
#include <cstring> #include <cstring>
#include <cstdlib> #include <cstdlib>
#include <sys/types.h> #include <sys/types.h>
#include <sys/sysctl.h> #include <sys/sysctl.h>
#include <mach/mach_time.h> #include <mach/mach_time.h>
#include <wx/string.h>
#include "common/Pcsx2Types.h"
#define NELEM(x) \ #define NELEM(x) \
((sizeof(x) / sizeof(0 [x])) / ((size_t)(!(sizeof(x) % sizeof(0 [x]))))) ((sizeof(x) / sizeof(0 [x])) / ((size_t)(!(sizeof(x) % sizeof(0 [x])))))
@ -148,3 +149,4 @@ void ScreensaverAllow(bool allow)
{ {
// no-op // no-op
} }
#endif

View File

@ -13,26 +13,22 @@
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
*/ */
#if defined(__APPLE__)
#include <cstdio> #include <cstdio>
#include <cassert> // assert #include <cassert> // assert
#include <pthread.h> // pthread_setcancelstate() #include <pthread.h> // pthread_setcancelstate()
#include <sys/time.h> // gettimeofday() #include <sys/time.h> // gettimeofday()
#include <mach/mach.h> #include <mach/mach.h>
#include <mach/task.h> // semaphore_create() and semaphore_destroy() #include <mach/task.h> // semaphore_create() and semaphore_destroy()
#include <mach/semaphore.h> // semaphore_*() #include <mach/semaphore.h> // semaphore_*()
#include <mach/mach_error.h> // mach_error_string() #include <mach/mach_error.h> // mach_error_string()
#include <mach/mach_time.h> // mach_absolute_time() #include <mach/mach_time.h> // mach_absolute_time()
#include "PrecompiledHeader.h" #include "common/Threading.h"
#include "common/ThreadingInternal.h"
#include "Threading.h" #include "common/wxBaseTools.h"
#include "ThreadingInternal.h" #include "common/wxGuiTools.h"
#include "wxBaseTools.h"
#include "wxGuiTools.h"
// -------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------
// Semaphore Implementation for Darwin/OSX // Semaphore Implementation for Darwin/OSX
@ -242,3 +238,4 @@ int Threading::Semaphore::Count()
{ {
return __atomic_load_n(&m_counter, __ATOMIC_SEQ_CST); return __atomic_load_n(&m_counter, __ATOMIC_SEQ_CST);
} }
#endif

View File

@ -13,19 +13,16 @@
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "../PrecompiledHeader.h" #if defined(__APPLE__)
#include "PersistentThread.h"
#include <unistd.h> #include <unistd.h>
#if !defined(__APPLE__)
#error "DarwinThreads.cpp should only be compiled by projects or makefiles targeted at OSX."
#else
#include <mach/mach_init.h> #include <mach/mach_init.h>
#include <mach/thread_act.h> #include <mach/thread_act.h>
#include <mach/mach_port.h> #include <mach/mach_port.h>
#include "common/PrecompiledHeader.h"
#include "common/PersistentThread.h"
// Note: assuming multicore is safer because it forces the interlocked routines to use // Note: assuming multicore is safer because it forces the interlocked routines to use
// the LOCK prefix. The prefix works on single core CPUs fine (but is slow), but not // the LOCK prefix. The prefix works on single core CPUs fine (but is slow), but not
// having the LOCK prefix is very bad indeed. // having the LOCK prefix is very bad indeed.

View File

@ -13,11 +13,14 @@
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
*/ */
#define WXINTL_NO_GETTEXT_MACRO
#include <wx/app.h> #include <wx/app.h>
#if defined(__UNIX__) #if defined(__UNIX__)
#include <signal.h> #include <signal.h>
#endif #endif
#include "common/Dependencies.h" // _ macro
#include "common/Threading.h" #include "common/Threading.h"
#include "common/General.h" #include "common/General.h"

View File

@ -13,7 +13,7 @@
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef _WIN32 #if !defined(_WIN32)
#include <wx/thread.h> #include <wx/thread.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <signal.h> #include <signal.h>

View File

@ -13,13 +13,15 @@
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef _WIN32 #if !defined(_WIN32) && !defined(__APPLE__)
#include <ctype.h> #include <ctype.h>
#include <time.h> #include <time.h>
#include <unistd.h> #include <unistd.h>
#include <sys/time.h> #include <sys/time.h>
#include <wx/utils.h> #include <wx/utils.h>
#include "common/Pcsx2Types.h"
// Returns 0 on failure (not supported by the operating system). // Returns 0 on failure (not supported by the operating system).
u64 GetPhysicalMemory() u64 GetPhysicalMemory()
{ {

View File

@ -13,7 +13,7 @@
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef _WIN32 #if !defined(_WIN32) && !defined(__APPLE__)
#include <unistd.h> #include <unistd.h>
#if defined(__linux__) #if defined(__linux__)
#include <sys/prctl.h> #include <sys/prctl.h>

View File

@ -15,6 +15,7 @@
#pragma once #pragma once
#include <cstring> // memset
#include "common/Pcsx2Types.h" #include "common/Pcsx2Types.h"
#include "common/Pcsx2Defs.h" #include "common/Pcsx2Defs.h"

View File

@ -16,6 +16,7 @@
#pragma once #pragma once
#include <vector> #include <vector>
#include <cstdio>
#include "common/Pcsx2Types.h" #include "common/Pcsx2Types.h"
namespace Perf namespace Perf

View File

@ -15,7 +15,8 @@
#pragma once #pragma once
#include "SafeArray.h" #include "common/SafeArray.h"
#include "common/StringHelpers.h"
// Internal constructor for use by derived classes. This allows a derived class to // Internal constructor for use by derived classes. This allows a derived class to
// use its own memory allocation (with an aligned memory, for example). // use its own memory allocation (with an aligned memory, for example).

View File

@ -13,6 +13,8 @@
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
*/ */
#if !defined(__APPLE__)
#include "common/Threading.h" #include "common/Threading.h"
#include "common/wxBaseTools.h" #include "common/wxBaseTools.h"
#include "common/wxGuiTools.h" #include "common/wxGuiTools.h"
@ -160,3 +162,4 @@ int Threading::Semaphore::Count()
sem_getvalue(&m_sema, &retval); sem_getvalue(&m_sema, &retval);
return retval; return retval;
} }
#endif

View File

@ -13,6 +13,8 @@
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
*/ */
#if defined(_WIN32)
#include <wx/string.h> #include <wx/string.h>
#include "common/Pcsx2Defs.h" #include "common/Pcsx2Defs.h"
#include "common/RedtapeWindows.h" #include "common/RedtapeWindows.h"
@ -114,3 +116,4 @@ void ScreensaverAllow(bool allow)
flags |= ES_DISPLAY_REQUIRED; flags |= ES_DISPLAY_REQUIRED;
SetThreadExecutionState(flags); SetThreadExecutionState(flags);
} }
#endif

View File

@ -14,6 +14,7 @@
*/ */
#include <wx/wx.h> #include <wx/wx.h>
#include "common/Pcsx2Defs.h" // __fastcall
bool pxIsEnglish(int id) bool pxIsEnglish(int id)
{ {

View File

@ -80,7 +80,7 @@ close(IN);
open(OUT,">$output"); open(OUT,">$output");
### Print the header ### Print the header
print OUT "#pragma once\n\n"; print OUT "#pragma once\n\n";
print OUT "#include \"Pcsx2Types.h\"\n"; print OUT "#include \"common/Pcsx2Types.h\"\n";
print OUT "#include <wx/gdicmn.h>\n\n"; print OUT "#include <wx/gdicmn.h>\n\n";
print OUT "class $wx_img_class\n{\n"; print OUT "class $wx_img_class\n{\n";
print OUT "public:\n"; print OUT "public:\n";

View File

@ -25,11 +25,11 @@
#include <mutex> #include <mutex>
#include <queue> #include <queue>
#include "Pcsx2Defs.h" #include "common/Pcsx2Defs.h"
#include "bitwise.h" #include "bitwise.h"
#include "Utilities/pxStreams.h" #include "common/pxStreams.h"
#include "Utilities/Console.h" #include "common/Console.h"
#include "App.h" #include "App.h"
#include "DebugTools/Debug.h" #include "DebugTools/Debug.h"

View File

@ -16,7 +16,7 @@
#pragma once #pragma once
#include "Global.h" #include "Global.h"
#include "Utilities/mt_queue.h" #include "common/mt_queue.h"
enum PadOptions enum PadOptions
{ {

View File

@ -21,7 +21,7 @@
#include "Global.h" #include "Global.h"
#include "keyboard.h" #include "keyboard.h"
#include "Utilities/mt_queue.h" #include "common/mt_queue.h"
extern keyEvent event; extern keyEvent event;
extern MtQueue<keyEvent> g_ev_fifo; extern MtQueue<keyEvent> g_ev_fifo;

View File

@ -15,7 +15,7 @@
#pragma once #pragma once
#include "Pcsx2Defs.h" #include "common/Pcsx2Defs.h"
#include "App.h" #include "App.h"
#if defined(__unix__) || defined(__APPLE__) #if defined(__unix__) || defined(__APPLE__)

View File

@ -17,7 +17,7 @@
#include <wx/wx.h> #include <wx/wx.h>
#include "Utilities/EmbeddedImage.h" #include "common/EmbeddedImage.h"
enum gui_img enum gui_img
{ {

View File

@ -17,7 +17,7 @@
#include "SPU2/Global.h" #include "SPU2/Global.h"
#include "Dialogs.h" #include "Dialogs.h"
#include "Config.h" #include "Config.h"
#include "Utilities/Path.h" #include "common/Path.h"
bool DebugEnabled = false; bool DebugEnabled = false;
bool _MsgToConsole = false; bool _MsgToConsole = false;

View File

@ -19,7 +19,7 @@
#include "USB/deviceproxy.h" #include "USB/deviceproxy.h"
#include "USB/usb-pad/padproxy.h" #include "USB/usb-pad/padproxy.h"
#include "USB/usb-mic/audiodeviceproxy.h" #include "USB/usb-mic/audiodeviceproxy.h"
#include "Utilities/Console.h" #include "common/Console.h"
void SysMessage_stderr(const char* fmt, ...) void SysMessage_stderr(const char* fmt, ...)
{ {

View File

@ -19,7 +19,7 @@
#include "jpge.h" #include "jpge.h"
#include "jo_mpeg.h" #include "jo_mpeg.h"
#include "USB/gtk.h" #include "USB/gtk.h"
#include "Utilities/Console.h" #include "common/Console.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>

View File

@ -16,7 +16,7 @@
#pragma once #pragma once
#include "USB/usb-hid/usb-hid.h" #include "USB/usb-hid/usb-hid.h"
#include "USB/linux/util.h" #include "USB/linux/util.h"
#include "Utilities/Console.h" #include "common/Console.h"
#include <linux/input.h> #include <linux/input.h>
#include <unistd.h> #include <unistd.h>
#include <dirent.h> #include <dirent.h>

View File

@ -17,7 +17,7 @@
#include "USB/linux/ini.h" #include "USB/linux/ini.h"
#include "USB/configuration.h" #include "USB/configuration.h"
#include "USB/gtk.h" #include "USB/gtk.h"
#include "Utilities/Console.h" #include "common/Console.h"
namespace usb_msd namespace usb_msd
{ {

View File

@ -18,7 +18,7 @@
#include "shared.h" #include "shared.h"
#include "USB/linux/util.h" #include "USB/linux/util.h"
#include "USB/readerwriterqueue/readerwriterqueue.h" #include "USB/readerwriterqueue/readerwriterqueue.h"
#include "Utilities/Console.h" #include "common/Console.h"
//#include <dirent.h> //gtk.h pulls in? //#include <dirent.h> //gtk.h pulls in?
#include <thread> #include <thread>
#include <array> #include <array>

View File

@ -15,7 +15,7 @@
#include "shared.h" #include "shared.h"
#include "USB/icon_buzz_24.h" #include "USB/icon_buzz_24.h"
#include "Utilities/Console.h" #include "common/Console.h"
#include <chrono> #include <chrono>
#include <thread> #include <thread>

View File

@ -16,7 +16,7 @@
#pragma once #pragma once
#include <linux/joystick.h> #include <linux/joystick.h>
#include <unistd.h> #include <unistd.h>
#include "Pcsx2Types.h" #include "common/Pcsx2Types.h"
#include "USB/gtk.h" #include "USB/gtk.h"
#include "USB/usb-pad/padproxy.h" #include "USB/usb-pad/padproxy.h"
#include "USB/configuration.h" #include "USB/configuration.h"