Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'osx-libcxx'
  • Loading branch information
delroth committed Apr 1, 2013
2 parents 58159a1 + 4d27315 commit 49d809a
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 38 deletions.
16 changes: 8 additions & 8 deletions CMakeLists.txt
Expand Up @@ -168,8 +168,8 @@ if(APPLE)
set(ENV{PATH} /usr/bin:/bin:/usr/sbin:/sbin)

# Some of our code contains Objective C constructs.
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -x objective-c")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -x objective-c++")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -x objective-c -stdlib=libc++")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -x objective-c++ -stdlib=libc++")
# Avoid mistaking an object file for a source file on the link command line.
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -x none")

Expand All @@ -180,10 +180,10 @@ if(APPLE)
# This is inserted into the Info.plist as well.
# Note that the SDK determines the maximum version of which optional
# features can be used, not the minimum required version to run.
set(OSX_MIN_VERSION "10.5.4")
set(OSX_MIN_VERSION "10.7")
set(TARGET_FLAGS "${TARGET_FLAGS} -mmacosx-version-min=${OSX_MIN_VERSION}")
set(SYSROOT_LEGACY_PATH "/Developer/SDKs/MacOSX10.6.sdk")
set(SYSROOT_PATH "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.6.sdk")
set(SYSROOT_LEGACY_PATH "/Developer/SDKs/MacOSX10.7.sdk")
set(SYSROOT_PATH "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk")
if(EXISTS "${SYSROOT_PATH}/")
set(TARGET_SYSROOT ${SYSROOT_PATH})
elseif(EXISTS "${SYSROOT_LEGACY_PATH}/")
Expand All @@ -197,8 +197,8 @@ if(APPLE)
# This avoids a warning when linking with QuickTime.
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-no_arch_warnings")
# Specify target CPUs.
set(TARGET_FLAGS "${TARGET_FLAGS} -Xarch_x86_64 -mssse3")
set(TARGET_FLAGS "${TARGET_FLAGS} -Xarch_x86_64 -march=core2")
set(TARGET_FLAGS "${TARGET_FLAGS} -mssse3")
set(TARGET_FLAGS "${TARGET_FLAGS} -march=core2")
# Target flags apply to both C and C++ compilation.
# CMake passes these to the compiler on the link command line as well.
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TARGET_FLAGS}")
Expand Down Expand Up @@ -247,7 +247,7 @@ if(CMAKE_BUILD_TYPE STREQUAL Debug)
set(wxWidgets_USE_DEBUG ON CACHE BOOL "Use wxWidgets Debugging")
endif(CMAKE_BUILD_TYPE STREQUAL Debug)

if(CMAKE_BUILD_TYPE STREQUAL Release)
if(CMAKE_BUILD_TYPE STREQUAL Release AND NOT APPLE)
add_definitions(-fomit-frame-pointer)
endif(CMAKE_BUILD_TYPE STREQUAL Release)

Expand Down
4 changes: 3 additions & 1 deletion Externals/wxWidgets3/build_wx.sh
Expand Up @@ -5,7 +5,9 @@ cd wxWidgets

case $OSTYPE in
darwin*)
export CC=clang CXX=clang++ CFLAGS="-stdlib=libc++" CXXFLAGS="-stdlib=libc++" CPPFLAGS="-stdlib=libc++"
BACKEND="osx_cocoa"
ADD_OPTS=--with-macosx-version-min=10.7 --enable-stl
;;
linux*)
BACKEND="gtk"
Expand All @@ -15,5 +17,5 @@ esac
mkdir build-local
cd build-local

../configure --with-$BACKEND --disable-shared --enable-unicode --disable-compat28 --disable-exceptions --disable-fswatcher --without-regex --without-expat --disable-xml --disable-ribbon --disable-propgrid --disable-stc --disable-html --disable-richtext --without-libjpeg --without-libtiff --disable-webview --disable-markup
../configure --with-$BACKEND --disable-shared --enable-unicode --disable-compat28 --disable-exceptions --disable-fswatcher --without-regex --without-expat --disable-xml --disable-ribbon --disable-propgrid --disable-stc --disable-html --disable-richtext --without-libjpeg --without-libtiff --disable-webview --disable-markup $ADD_OPTS
make
28 changes: 14 additions & 14 deletions Externals/wxWidgets3/wx/wxcocoa.h
Expand Up @@ -16,7 +16,7 @@
#endif /* __cplusplus */

/* fill in with the string wxGetOsDescription() will return */
#define WXWIN_OS_DESCRIPTION "Darwin 11.3.0 i386"
#define WXWIN_OS_DESCRIPTION "Darwin 11.4.2 x86_64"

/* the installation location prefix from configure */
#define wxINSTALL_PREFIX "/usr/local"
Expand Down Expand Up @@ -205,7 +205,7 @@



#define wxUSE_STL 0
#define wxUSE_STL 1

#if defined(__DMC__) || defined(__WATCOMC__) \
|| (defined(_MSC_VER) && _MSC_VER < 1200)
Expand All @@ -214,7 +214,7 @@
#define wxUSE_STD_DEFAULT 0
#endif

#define wxUSE_STD_CONTAINERS 0
#define wxUSE_STD_CONTAINERS 1

#define wxUSE_STD_IOSTREAM 1

Expand Down Expand Up @@ -715,7 +715,7 @@
/*
* Define if your compiler has compliant std::string::compare
*/
/* #undef HAVE_STD_STRING_COMPARE */
#define HAVE_STD_STRING_COMPARE 1
/*
* Define if your compiler has <hash_map>
*/
Expand All @@ -736,12 +736,12 @@
/*
* Define if your compiler has std::unordered_map
*/
/* #undef HAVE_STD_UNORDERED_MAP */
#define HAVE_STD_UNORDERED_MAP 1

/*
* Define if your compiler has std::unordered_set
*/
/* #undef HAVE_STD_UNORDERED_SET */
#define HAVE_STD_UNORDERED_SET 1

/*
* Define if your compiler has std::tr1::unordered_map
Expand All @@ -756,12 +756,12 @@
/*
* Define if your compiler has <tr1/type_traits>
*/
#define HAVE_TR1_TYPE_TRAITS 1
/* #undef HAVE_TR1_TYPE_TRAITS */

/*
* Define if your compiler has <type_traits>
*/
/* #undef HAVE_TYPE_TRAITS */
#define HAVE_TYPE_TRAITS 1

/*
* Define if the compiler supports simple visibility declarations.
Expand Down Expand Up @@ -830,7 +830,7 @@
/*
* Define if compiler has __thread keyword.
*/
/* #undef HAVE___THREAD_KEYWORD */
#define HAVE___THREAD_KEYWORD 1
/*
* Define if large (64 bit file offsets) files are supported.
*/
Expand Down Expand Up @@ -996,25 +996,25 @@
#define HAVE_USLEEP 1

/* Define if you have wcscasecmp() function */
/* #undef HAVE_WCSCASECMP 1 */
#define HAVE_WCSCASECMP 1

/* Define if you have wcsncasecmp() function */
/* #undef HAVE_WCSNCASECMP 1 */
#define HAVE_WCSNCASECMP 1

/* Define if you have wcslen function */
#define HAVE_WCSLEN 1

/* Define if you have wcsdup function */
/* #undef HAVE_WCSDUP 1 */
#define HAVE_WCSDUP 1

/* Define if you have wcsftime() function */
#define HAVE_WCSFTIME 1

/* Define if you have strnlen() function */
/* #undef HAVE_STRNLEN 1 */
#define HAVE_STRNLEN 1

/* Define if you have wcsnlen() function */
/* #undef HAVE_WCSNLEN 1 */
#define HAVE_WCSNLEN 1

/* Define if you have wcstoull() and wcstoll() */
/* #undef HAVE_WCSTOULL */
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Common/Src/LogManager.h
Expand Up @@ -46,7 +46,7 @@ class FileLogListener : public LogListener

void Log(LogTypes::LOG_LEVELS, const char *msg);

bool IsValid() { return (m_logfile != NULL); }
bool IsValid() { return (bool)m_logfile; }
bool IsEnabled() const { return m_enable; }
void SetEnable(bool enable) { m_enable = enable; }

Expand Down
17 changes: 17 additions & 0 deletions Source/Core/Common/Src/StdConditionVariable.h
Expand Up @@ -5,9 +5,26 @@
#define GCC_VER(x,y,z) ((x) * 10000 + (y) * 100 + (z))
#define GCC_VERSION GCC_VER(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)

#ifndef __has_include
#define __has_include(s) 0
#endif

#if GCC_VERSION >= GCC_VER(4,4,0) && __GXX_EXPERIMENTAL_CXX0X__ && !ANDROID

// GCC 4.4 provides <condition_variable>
#include <condition_variable>

#elif __has_include(<condition_variable>)

// clang and libc++ provide <condition_variable> on OSX. However, the version
// of libc++ bundled with OSX 10.7 and 10.8 is buggy: it uses _ as a variable.
//
// We work around this issue by undefining and redefining _.

#undef _
#include <condition_variable>
#define _(s) wxGetTranslation((s))

#else

// partial std::condition_variable implementation for win32/pthread
Expand Down
7 changes: 7 additions & 0 deletions Source/Core/Common/Src/StdMutex.h
Expand Up @@ -5,9 +5,16 @@
#define GCC_VER(x,y,z) ((x) * 10000 + (y) * 100 + (z))
#define GCC_VERSION GCC_VER(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)

#ifndef __has_include
#define __has_include(s) 0
#endif

#if GCC_VERSION >= GCC_VER(4,4,0) && __GXX_EXPERIMENTAL_CXX0X__ && !ANDROID
// GCC 4.4 provides <mutex>
#include <mutex>
#elif __has_include(<mutex>)
// Clang + libc++
#include <mutex>
#else

// partial <mutex> implementation for win32/pthread
Expand Down
7 changes: 7 additions & 0 deletions Source/Core/Common/Src/StdThread.h
Expand Up @@ -5,12 +5,19 @@
#define GCC_VER(x,y,z) ((x) * 10000 + (y) * 100 + (z))
#define GCC_VERSION GCC_VER(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)

#ifndef __has_include
#define __has_include(s) 0
#endif

#if GCC_VERSION >= GCC_VER(4,4,0) && __GXX_EXPERIMENTAL_CXX0X__ && !ANDROID
// GCC 4.4 provides <thread>
#ifndef _GLIBCXX_USE_SCHED_YIELD
#define _GLIBCXX_USE_SCHED_YIELD
#endif
#include <thread>
#elif __has_include(<thread>)
// Clang + libc++
#include <thread>
#else

// partial std::thread implementation for win32/pthread
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Common/Src/Thread.h
Expand Up @@ -18,9 +18,9 @@
#ifndef _THREAD_H_
#define _THREAD_H_

#include "StdThread.h"
#include "StdMutex.h"
#include "StdConditionVariable.h"
#include "StdMutex.h"
#include "StdThread.h"

// Don't include common.h here as it will break LogManager
#include "CommonTypes.h"
Expand Down
6 changes: 3 additions & 3 deletions Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_AX.h
Expand Up @@ -75,7 +75,7 @@ class CUCode_AX : public IUCode
virtual void DoState(PointerWrap& p);

// Needed because StdThread.h std::thread implem does not support member
// pointers.
// pointers. TODO(delroth): obsolete.
static void SpawnAXThread(CUCode_AX* self);

protected:
Expand Down Expand Up @@ -107,13 +107,13 @@ class CUCode_AX : public IUCode
volatile u16 m_cmdlist[512];
volatile u32 m_cmdlist_size;

std::thread m_axthread;

// Sync objects
std::mutex m_processing;
std::condition_variable m_cmdlist_cv;
std::mutex m_cmdlist_mutex;

std::thread m_axthread;

// Copy a command list from memory to our temp buffer
void CopyCmdList(u32 addr, u16 size);

Expand Down
11 changes: 2 additions & 9 deletions Source/Core/DolphinWX/Src/ConfigMain.cpp
Expand Up @@ -18,6 +18,7 @@
#include <string> // System
#include <vector>
#include <algorithm>
#include <functional>
#include <wx/spinbutt.h>

#include "Common.h"
Expand All @@ -43,14 +44,6 @@
#include "Main.h"
#include "VideoBackendBase.h"

#if defined(__APPLE__)
#include <tr1/functional>
using std::tr1::function;
#else
#include <functional>
using std::function;
#endif

#define TEXT_BOX(page, text) new wxStaticText(page, wxID_ANY, text, wxDefaultPosition, wxDefaultSize)

struct CPUCore
Expand Down Expand Up @@ -631,7 +624,7 @@ void CConfigMain::CreateGUIControls()
theme_selection->SetStringSelection(SConfig::GetInstance().m_LocalCoreStartupParameter.theme_name);

// std::function = avoid error on msvc
theme_selection->Bind(wxEVT_COMMAND_CHOICE_SELECTED, function<void(wxEvent&)>([theme_selection](wxEvent&)
theme_selection->Bind(wxEVT_COMMAND_CHOICE_SELECTED, std::function<void(wxEvent&)>([theme_selection](wxEvent&)
{
SConfig::GetInstance().m_LocalCoreStartupParameter.theme_name = theme_selection->GetStringSelection();
main_frame->InitBitmaps();
Expand Down

0 comments on commit 49d809a

Please sign in to comment.