Skip to content

Commit

Permalink
common: fix cmake on linux/macos
Browse files Browse the repository at this point in the history
  • Loading branch information
tadanokojin committed Sep 4, 2021
1 parent 831c8b9 commit 0717bf7
Show file tree
Hide file tree
Showing 29 changed files with 61 additions and 41 deletions.
3 changes: 2 additions & 1 deletion common/AlignedMalloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
// This module contains implementations of _aligned_malloc for platforms that don't have
// it built into their CRT/libc.

#ifndef _WIN32
#if !defined(_WIN32)

#include "common/Assertions.h"
#include "common/ScopedAlloc.h"

void *__fastcall _aligned_malloc(size_t size, size_t align)
{
Expand Down
8 changes: 8 additions & 0 deletions common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ add_library(common)

# x86emitter sources
target_sources(common PRIVATE
AlignedMalloc.cpp
VirtualMemory.cpp
EventSource.inl
SafeArray.inl
Expand Down Expand Up @@ -45,9 +46,16 @@ target_sources(common PRIVATE
emitter/legacy_sse.cpp
emitter/movs.cpp
emitter/simd.cpp
emitter/LnxCpuDetect.cpp
emitter/WinCpuDetect.cpp
emitter/x86emitter.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/WinHostSys.cpp
Windows/WinMisc.cpp)
Expand Down
8 changes: 5 additions & 3 deletions common/Darwin/DarwinMisc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@
* If not, see <http://www.gnu.org/licenses/>.
*/

#include "../PrecompiledHeader.h"
#if defined(__APPLE__)

#include <cstring>
#include <cstdlib>

#include <sys/types.h>
#include <sys/sysctl.h>

#include <mach/mach_time.h>
#include <wx/string.h>

#include "common/Pcsx2Types.h"

#define NELEM(x) \
((sizeof(x) / sizeof(0 [x])) / ((size_t)(!(sizeof(x) % sizeof(0 [x])))))
Expand Down Expand Up @@ -148,3 +149,4 @@ void ScreensaverAllow(bool allow)
{
// no-op
}
#endif
17 changes: 7 additions & 10 deletions common/Darwin/DarwinSemaphore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,22 @@
* If not, see <http://www.gnu.org/licenses/>.
*/

#if defined(__APPLE__)

#include <cstdio>
#include <cassert> // assert

#include <pthread.h> // pthread_setcancelstate()

#include <sys/time.h> // gettimeofday()

#include <mach/mach.h>
#include <mach/task.h> // semaphore_create() and semaphore_destroy()
#include <mach/semaphore.h> // semaphore_*()
#include <mach/mach_error.h> // mach_error_string()
#include <mach/mach_time.h> // mach_absolute_time()

#include "PrecompiledHeader.h"

#include "Threading.h"
#include "ThreadingInternal.h"

#include "wxBaseTools.h"
#include "wxGuiTools.h"
#include "common/Threading.h"
#include "common/ThreadingInternal.h"
#include "common/wxBaseTools.h"
#include "common/wxGuiTools.h"

// --------------------------------------------------------------------------------------
// Semaphore Implementation for Darwin/OSX
Expand Down Expand Up @@ -242,3 +238,4 @@ int Threading::Semaphore::Count()
{
return __atomic_load_n(&m_counter, __ATOMIC_SEQ_CST);
}
#endif
11 changes: 4 additions & 7 deletions common/Darwin/DarwinThreads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,16 @@
* If not, see <http://www.gnu.org/licenses/>.
*/

#include "../PrecompiledHeader.h"
#include "PersistentThread.h"
#if defined(__APPLE__)

#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/thread_act.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
// the LOCK prefix. The prefix works on single core CPUs fine (but is slow), but not
// having the LOCK prefix is very bad indeed.
Expand Down
3 changes: 3 additions & 0 deletions common/Exceptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
* If not, see <http://www.gnu.org/licenses/>.
*/

#define WXINTL_NO_GETTEXT_MACRO

#include <wx/app.h>
#if defined(__UNIX__)
#include <signal.h>
#endif

#include "common/Dependencies.h" // _ macro
#include "common/Threading.h"
#include "common/General.h"

Expand Down
2 changes: 1 addition & 1 deletion common/Linux/LnxHostSys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _WIN32
#if !defined(_WIN32)
#include <wx/thread.h>
#include <sys/mman.h>
#include <signal.h>
Expand Down
4 changes: 3 additions & 1 deletion common/Linux/LnxMisc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
* If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _WIN32
#if !defined(_WIN32) && !defined(__APPLE__)
#include <ctype.h>
#include <time.h>
#include <unistd.h>
#include <sys/time.h>
#include <wx/utils.h>

#include "common/Pcsx2Types.h"

// Returns 0 on failure (not supported by the operating system).
u64 GetPhysicalMemory()
{
Expand Down
2 changes: 1 addition & 1 deletion common/Linux/LnxThreads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _WIN32
#if !defined(_WIN32) && !defined(__APPLE__)
#include <unistd.h>
#if defined(__linux__)
#include <sys/prctl.h>
Expand Down
1 change: 1 addition & 0 deletions common/MemcpyFast.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#pragma once

#include <cstring> // memset
#include "common/Pcsx2Types.h"
#include "common/Pcsx2Defs.h"

Expand Down
1 change: 1 addition & 0 deletions common/Perf.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#pragma once

#include <vector>
#include <cstdio>
#include "common/Pcsx2Types.h"

namespace Perf
Expand Down
3 changes: 2 additions & 1 deletion common/SafeArray.inl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@

#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
// use its own memory allocation (with an aligned memory, for example).
Expand Down
3 changes: 3 additions & 0 deletions common/Semaphore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* If not, see <http://www.gnu.org/licenses/>.
*/

#if !defined(__APPLE__)

#include "common/Threading.h"
#include "common/wxBaseTools.h"
#include "common/wxGuiTools.h"
Expand Down Expand Up @@ -160,3 +162,4 @@ int Threading::Semaphore::Count()
sem_getvalue(&m_sema, &retval);
return retval;
}
#endif
3 changes: 3 additions & 0 deletions common/Windows/WinMisc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* If not, see <http://www.gnu.org/licenses/>.
*/

#if defined(_WIN32)

#include <wx/string.h>
#include "common/Pcsx2Defs.h"
#include "common/RedtapeWindows.h"
Expand Down Expand Up @@ -114,3 +116,4 @@ void ScreensaverAllow(bool allow)
flags |= ES_DISPLAY_REQUIRED;
SetThreadExecutionState(flags);
}
#endif
1 change: 1 addition & 0 deletions common/pxTranslate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/

#include <wx/wx.h>
#include "common/Pcsx2Defs.h" // __fastcall

bool pxIsEnglish(int id)
{
Expand Down
2 changes: 1 addition & 1 deletion linux_various/hex2h.pl
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ ($)
open(OUT,">$output");
### Print the header
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 "class $wx_img_class\n{\n";
print OUT "public:\n";
Expand Down
6 changes: 3 additions & 3 deletions pcsx2/PAD/Linux/Global.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
#include <mutex>
#include <queue>

#include "Pcsx2Defs.h"
#include "common/Pcsx2Defs.h"
#include "bitwise.h"

#include "Utilities/pxStreams.h"
#include "Utilities/Console.h"
#include "common/pxStreams.h"
#include "common/Console.h"
#include "App.h"
#include "DebugTools/Debug.h"

Expand Down
2 changes: 1 addition & 1 deletion pcsx2/PAD/Linux/PAD.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#pragma once

#include "Global.h"
#include "Utilities/mt_queue.h"
#include "common/mt_queue.h"

enum PadOptions
{
Expand Down
2 changes: 1 addition & 1 deletion pcsx2/PAD/Linux/keyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "Global.h"
#include "keyboard.h"

#include "Utilities/mt_queue.h"
#include "common/mt_queue.h"
extern keyEvent event;
extern MtQueue<keyEvent> g_ev_fifo;

Expand Down
2 changes: 1 addition & 1 deletion pcsx2/PAD/Linux/keyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#pragma once

#include "Pcsx2Defs.h"
#include "common/Pcsx2Defs.h"
#include "App.h"

#if defined(__unix__) || defined(__APPLE__)
Expand Down
2 changes: 1 addition & 1 deletion pcsx2/PAD/Linux/wx_dialog/opPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include <wx/wx.h>

#include "Utilities/EmbeddedImage.h"
#include "common/EmbeddedImage.h"

enum gui_img
{
Expand Down
2 changes: 1 addition & 1 deletion pcsx2/SPU2/Linux/ConfigDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "SPU2/Global.h"
#include "Dialogs.h"
#include "Config.h"
#include "Utilities/Path.h"
#include "common/Path.h"

bool DebugEnabled = false;
bool _MsgToConsole = false;
Expand Down
2 changes: 1 addition & 1 deletion pcsx2/USB/linux/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "USB/deviceproxy.h"
#include "USB/usb-pad/padproxy.h"
#include "USB/usb-mic/audiodeviceproxy.h"
#include "Utilities/Console.h"
#include "common/Console.h"

void SysMessage_stderr(const char* fmt, ...)
{
Expand Down
2 changes: 1 addition & 1 deletion pcsx2/USB/usb-eyetoy/cam-linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "jpge.h"
#include "jo_mpeg.h"
#include "USB/gtk.h"
#include "Utilities/Console.h"
#include "common/Console.h"

#include <stdio.h>
#include <stdlib.h>
Expand Down
2 changes: 1 addition & 1 deletion pcsx2/USB/usb-hid/evdev/evdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#pragma once
#include "USB/usb-hid/usb-hid.h"
#include "USB/linux/util.h"
#include "Utilities/Console.h"
#include "common/Console.h"
#include <linux/input.h>
#include <unistd.h>
#include <dirent.h>
Expand Down
2 changes: 1 addition & 1 deletion pcsx2/USB/usb-msd/usb-msd-gtk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "USB/linux/ini.h"
#include "USB/configuration.h"
#include "USB/gtk.h"
#include "Utilities/Console.h"
#include "common/Console.h"

namespace usb_msd
{
Expand Down
2 changes: 1 addition & 1 deletion pcsx2/USB/usb-pad/evdev/evdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "shared.h"
#include "USB/linux/util.h"
#include "USB/readerwriterqueue/readerwriterqueue.h"
#include "Utilities/Console.h"
#include "common/Console.h"
//#include <dirent.h> //gtk.h pulls in?
#include <thread>
#include <array>
Expand Down
2 changes: 1 addition & 1 deletion pcsx2/USB/usb-pad/evdev/shared-gtk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include "shared.h"
#include "USB/icon_buzz_24.h"
#include "Utilities/Console.h"
#include "common/Console.h"

#include <chrono>
#include <thread>
Expand Down
2 changes: 1 addition & 1 deletion pcsx2/USB/usb-pad/evdev/shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#pragma once
#include <linux/joystick.h>
#include <unistd.h>
#include "Pcsx2Types.h"
#include "common/Pcsx2Types.h"
#include "USB/gtk.h"
#include "USB/usb-pad/padproxy.h"
#include "USB/configuration.h"
Expand Down

0 comments on commit 0717bf7

Please sign in to comment.