Darwin/OSX SysMessage stub & __POSIX__ define.

This commit is contained in:
Juha Laukkanen 2015-11-17 19:35:02 +02:00
parent f813b9e25b
commit fc3ff48777
5 changed files with 72 additions and 10 deletions

View File

@ -20,17 +20,24 @@
#include <string>
#include <cstdarg>
#ifdef _MSC_VER
#if defined(_MSC_VER)
#include <windows.h>
#include <windowsx.h>
#include <commctrl.h>
#define EXPORT_C_(type) extern "C" type CALLBACK
#else
#elif defined(GTK_MAJOR_VERSION)
#include <gtk/gtk.h>
#include <cstring>
#define EXPORT_C_(type) extern "C" __attribute__((stdcall,externally_visible,visibility("default"))) type
#else
#define EXPORT_C_(type) extern "C" __attribute__((stdcall,externally_visible,visibility("default"))) type
#endif
//#include "PS2Edefs.h"
@ -161,7 +168,7 @@ struct PluginConf
}
};
#ifdef __linux__
#if defined(GTK_MAJOR_VERSION)
static void SysMessage(const char *fmt, ...)
{
@ -221,6 +228,48 @@ static void __forceinline PluginNullAbout(const char *aboutText)
#define ENTRY_POINT /* We don't need no stinkin' entry point! */
#elif defined(__WXMAC__) || defined(__APPLE__)
static void SysMessage(const char *fmt, ...)
{
va_list list;
char msg[512];
va_start(list, fmt);
vsprintf(msg, fmt, list);
va_end(list);
if (msg[strlen(msg)-1] == '\n') msg[strlen(msg)-1] = 0;
// TODO OSX can we use WX MessageBox here or should Cocoa MessageBox used?
}
static void SysMessage(const wchar_t *fmt, ...)
{
va_list list;
wchar_t msg[512];
va_start(list, fmt);
//vsprintf(msg, fmt, list);
va_end(list);
// TODO OSX can we use WX MessageBox here or should Cocoa MessageBox used?
}
static void __forceinline PluginNullConfigure(std::string desc, int &log)
{
SysMessage("This space intentionally left blank.");
}
static void __forceinline PluginNullAbout(const char *aboutText)
{
SysMessage(aboutText);
}
#define ENTRY_POINT /* We don't need no stinkin' entry point! */ // TODO OSX WTF is this anyway?
#else
#define usleep(x) Sleep(x / 1000)

View File

@ -23,6 +23,14 @@
#define __linux__
#endif
// make sure __POSIX__ is defined for all systems where we assume POSIX
// compliance
#if defined(__linux__) || defined(__APPLE__) || defined(__unix__) || defined(__CYGWIN__) || defined(__LINUX__)
# if !defined(__POSIX__)
# define __POSIX__ 1
# endif
#endif
#include "Pcsx2Types.h"
#ifdef _MSC_VER

View File

@ -15,7 +15,7 @@
#pragma once
#ifdef __linux__
#if defined(__POSIX__)
# include "lnx_memzero.h"
#else
# include "win_memzero.h"

View File

@ -271,7 +271,7 @@ protected:
virtual void CommitBlocks( uptr page, uint blocks );
};
#ifdef __linux__
#ifdef __POSIX__
# define PCSX2_PAGEFAULT_PROTECT
# define PCSX2_PAGEFAULT_EXCEPT

View File

@ -19,6 +19,10 @@
#include <errno.h> // EBUSY
#include <pthread.h>
#ifdef __APPLE__
#include <mach/semaphore.h>
#endif
#include "Pcsx2Defs.h"
#include "ScopedPtr.h"
#include "TraceLog.h"
@ -66,11 +70,7 @@ extern ConsoleLogSource_Threading pxConLog_Thread;
//#define PCSX2_THREAD_LOCAL 0 // uncomment this line to force-disable native TLS (useful for testing TlsVariable on windows/linux)
#ifndef PCSX2_THREAD_LOCAL
# ifdef __WXMAC__
# define PCSX2_THREAD_LOCAL 0
# else
# define PCSX2_THREAD_LOCAL 1
# endif
# define PCSX2_THREAD_LOCAL 1
#endif
class wxTimeSpan;
@ -252,7 +252,12 @@ namespace Threading
class Semaphore
{
protected:
#ifdef __APPLE__
semaphore_t m_sema;
int m_counter;
#else
sem_t m_sema;
#endif
public:
Semaphore();