From 02edf66b4990f57e253bfe1f98a2002272762713 Mon Sep 17 00:00:00 2001 From: Soren Jorvang Date: Sat, 13 Nov 2010 20:02:01 +0000 Subject: [PATCH] Simplify OpenCL compile-time detection on OS X. Turn wiiuse io_osx.m into Objective-C++. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6398 8ced0084-cf51-0410-be5f-012b33b47a6e --- CMakeLists.txt | 1 - SConstruct | 23 ++++---- Source/Core/Common/Src/OpenCL.h | 9 +++- Source/Core/DolphinWX/Src/ConfigMain.cpp | 2 +- .../Src/ControllerInterface/OSX/OSX.mm | 2 +- Source/Core/VideoCommon/CMakeLists.txt | 7 +-- Source/Core/VideoCommon/Src/SConscript | 6 +-- Source/Core/wiiuse/Src/SConscript | 3 +- Source/Core/wiiuse/Src/definitions.h | 53 ------------------- Source/Core/wiiuse/Src/io_dummy.cpp | 2 +- Source/Core/wiiuse/Src/io_nix.cpp | 2 +- .../Core/wiiuse/Src/{io_osx.m => io_osx.mm} | 6 +-- Source/Core/wiiuse/Src/io_win.cpp | 4 +- Source/Core/wiiuse/Src/ir.cpp | 2 +- Source/Core/wiiuse/Src/wiiuse.cpp | 5 +- 15 files changed, 32 insertions(+), 95 deletions(-) delete mode 100644 Source/Core/wiiuse/Src/definitions.h rename Source/Core/wiiuse/Src/{io_osx.m => io_osx.mm} (98%) diff --git a/CMakeLists.txt b/CMakeLists.txt index eb79afab6e..575ae72703 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -285,7 +285,6 @@ if(NOT APPLE) include_directories(Externals/CLRun/include) add_subdirectory(Externals/CLRun) add_definitions(-DUSE_CLRUN) - add_definitions(-DHAVE_OPENCL=1) endif(NOT APPLE) set(DISABLE_WX FALSE CACHE BOOL "Disable wxWidgets (use CLI interface)") diff --git a/SConstruct b/SConstruct index 18913e571d..08659167d6 100644 --- a/SConstruct +++ b/SConstruct @@ -122,8 +122,11 @@ rev = utils.GenerateRevFile(env['flavor'], '.', None) if sys.platform == 'darwin': ccld = ['-arch', 'x86_64', '-arch', 'i386', '-mmacosx-version-min=10.5'] ccld += ['--sysroot=/Developer/SDKs/MacOSX10.5.sdk'] + system = '/System/Library/Frameworks' env['CCFLAGS'] += ccld env['CCFLAGS'] += ['-msse3'] + env['CCFLAGS'] += ['-iframework/Developer/SDKs/MacOSX10.5.sdk' + system] + env['CCFLAGS'] += ['-iframework/Developer/SDKs/MacOSX10.6.sdk' + system] env['CC'] = "gcc-4.2 -ObjC" env['CXX'] = "g++-4.2 -ObjC++" env['FRAMEWORKS'] += ['AppKit', 'CoreFoundation', 'CoreServices'] @@ -132,19 +135,10 @@ if sys.platform == 'darwin': env['LIBPATH'] += ['/usr/lib'] env['LIBS'] = ['iconv', 'SDL'] env['LINKFLAGS'] += ccld - env['LINKFLAGS'] += ['-Wl,-search_paths_first', '-Wl,-Z'] - env['LINKFLAGS'] += ['-F/System/Library/Frameworks'] + env['LINKFLAGS'] += ['-Wl,-search_paths_first', '-Wl,-Z', '-F' + system] - if platform.mac_ver()[0] < '10.6.0': - env['HAVE_OPENCL'] = 0 - else: + if platform.mac_ver()[0] >= '10.6.0': env['CCFLAGS'] += ['-Wextra-tokens', '-Wnewline-eof'] - env['CCFLAGS'] += ['-iframework' + - '/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks'] - env['CCFLAGS'] += ['-iframework' + - '/Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks'] - env['CPPDEFINES'] += [('HAVE_OPENCL', 1)] - env['HAVE_OPENCL'] = 1 env['FRAMEWORKSFLAGS'] = ['-weak_framework', 'OpenCL'] if env['nowx']: @@ -187,14 +181,15 @@ elif sys.platform == 'win32': pass else: - env['CCFLAGS'] += ['-fPIC', '-msse2'] + env['CCFLAGS'] += ['-fPIC', '-msse2', '-pthread'] env['CPPDEFINES'] += ['HAVE_CONFIG_H'] env['CPPPATH'].insert(0, '#') # Make sure we pick up our own config.h + env['LINKFLAGS'] += ['-pthread'] + env['RPATH'] = [] if sys.platform == 'linux2': env['CPPDEFINES'] += [('_FILE_OFFSET_BITS', 64), '_LARGEFILE_SOURCE'] env['CXXFLAGS'] += ['-Wno-deprecated'] # XXX - env['LINKFLAGS'] += ['-pthread', '-ldl'] - env['RPATH'] = [] + env['LIBS'] += ['dl'] conf = env.Configure(config_h = "#config.h", custom_tests = { 'CheckPKG' : utils.CheckPKG, diff --git a/Source/Core/Common/Src/OpenCL.h b/Source/Core/Common/Src/OpenCL.h index e94579a41f..a4ac241952 100644 --- a/Source/Core/Common/Src/OpenCL.h +++ b/Source/Core/Common/Src/OpenCL.h @@ -26,10 +26,17 @@ #define HAVE_OPENCL 1 #endif +// We detect the presence of the 10.6 SDK, which has the OpenCL headers, +// by looking for the new blocks feature in the 10.6 version of gcc. +// This allows us to have the 10.5 SDK first in the search path. +#if defined __APPLE__ && defined __BLOCKS__ +#define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER WEAK_IMPORT_ATTRIBUTE +#define HAVE_OPENCL 1 +#endif + #if defined(HAVE_OPENCL) && HAVE_OPENCL #ifdef __APPLE__ -#define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER #include #else #include diff --git a/Source/Core/DolphinWX/Src/ConfigMain.cpp b/Source/Core/DolphinWX/Src/ConfigMain.cpp index 493c2da92e..7c8a755181 100644 --- a/Source/Core/DolphinWX/Src/ConfigMain.cpp +++ b/Source/Core/DolphinWX/Src/ConfigMain.cpp @@ -33,7 +33,7 @@ #include "Frame.h" #include "HotkeyDlg.h" -#include "../../Common/Src/OpenCL.h" +#include "OpenCL.h" #ifdef __APPLE__ #include diff --git a/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSX.mm b/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSX.mm index da8dc64301..5e5105515b 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSX.mm +++ b/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSX.mm @@ -211,7 +211,7 @@ void Init(std::vector& devices) // Wait while current devices are initialized while (CFRunLoopRunInMode(OurRunLoop, 0, TRUE) == - kCFRunLoopRunHandledSource); + kCFRunLoopRunHandledSource) {}; // Things should be configured now // Disable hotplugging and other scheduling diff --git a/Source/Core/VideoCommon/CMakeLists.txt b/Source/Core/VideoCommon/CMakeLists.txt index bf919090b3..f06fc2c978 100644 --- a/Source/Core/VideoCommon/CMakeLists.txt +++ b/Source/Core/VideoCommon/CMakeLists.txt @@ -31,11 +31,8 @@ set(SRCS Src/BPMemory.cpp Src/VideoState.cpp Src/XFBConvert.cpp Src/XFMemory.cpp - Src/XFStructs.cpp) - -if(NOT APPLE) - set(SRCS ${SRCS} Src/OpenCL/OCLTextureDecoder.cpp) -endif(NOT APPLE) + Src/XFStructs.cpp + Src/OpenCL/OCLTextureDecoder.cpp) add_library(videocommon STATIC ${SRCS}) if(UNIX) diff --git a/Source/Core/VideoCommon/Src/SConscript b/Source/Core/VideoCommon/Src/SConscript index 5a397d653e..fd1ffe83b4 100644 --- a/Source/Core/VideoCommon/Src/SConscript +++ b/Source/Core/VideoCommon/Src/SConscript @@ -38,11 +38,7 @@ files = [ 'OnScreenDisplay.cpp', 'HiresTextures.cpp', 'DLCache.cpp', + 'OpenCL/OCLTextureDecoder.cpp', ] -if env['HAVE_OPENCL']: - files += [ - 'OpenCL/OCLTextureDecoder.cpp', - ] - env.StaticLibrary(env['local_libs'] + "videocommon", files) diff --git a/Source/Core/wiiuse/Src/SConscript b/Source/Core/wiiuse/Src/SConscript index 263880b412..64ee74c4bb 100644 --- a/Source/Core/wiiuse/Src/SConscript +++ b/Source/Core/wiiuse/Src/SConscript @@ -9,7 +9,7 @@ files = [ ] if sys.platform == 'darwin': - files += [ "io_osx.m" ] + files += [ "io_osx.mm" ] elif sys.platform == 'linux2' and env['HAVE_BLUEZ']: files += [ "io_nix.cpp" ] elif sys.platform == 'win32': @@ -18,4 +18,3 @@ else: files += [ "io_dummy.cpp" ] env.StaticLibrary(env['local_libs'] + "wiiuse", files) -env['CPPPATH'] += ['#Source/Core/wiiuse/Src'] diff --git a/Source/Core/wiiuse/Src/definitions.h b/Source/Core/wiiuse/Src/definitions.h deleted file mode 100644 index 5ddb06fd81..0000000000 --- a/Source/Core/wiiuse/Src/definitions.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * wiiuse - * - * Written By: - * Michael Laforest < para > - * Email: < thepara (--AT--) g m a i l [--DOT--] com > - * - * Copyright 2006-2007 - * - * This file is part of wiiuse. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * $Header$ - * - */ - -/** - * @file - * @brief General definitions. - */ - -#ifndef DEFINITIONS_H_INCLUDED -#define DEFINITIONS_H_INCLUDED - -#include - -#ifndef _WIN32 -#include /* htons() */ -#else -/* disable warnings I don't care about */ -#pragma warning(disable:4244) /* possible loss of data conversion */ -#pragma warning(disable:4273) /* inconsistent dll linkage */ -#pragma warning(disable:4217) - -#endif // _WIN32 - -/* Convert to big endian */ -#define BIG_ENDIAN_LONG(i) (htonl(i)) -#define BIG_ENDIAN_SHORT(i) (htons(i)) - -#endif // DEFINITIONS_H_INCLUDED diff --git a/Source/Core/wiiuse/Src/io_dummy.cpp b/Source/Core/wiiuse/Src/io_dummy.cpp index f865a42fe4..7e4f211dab 100644 --- a/Source/Core/wiiuse/Src/io_dummy.cpp +++ b/Source/Core/wiiuse/Src/io_dummy.cpp @@ -1,4 +1,4 @@ -#include "definitions.h" +#include "Common.h" #include "wiiuse_internal.h" int wiiuse_find(struct wiimote_t **wm, int max_wiimotes, int timeout) diff --git a/Source/Core/wiiuse/Src/io_nix.cpp b/Source/Core/wiiuse/Src/io_nix.cpp index 6e7fe2bd56..f508991848 100644 --- a/Source/Core/wiiuse/Src/io_nix.cpp +++ b/Source/Core/wiiuse/Src/io_nix.cpp @@ -39,7 +39,7 @@ #include #include -#include "definitions.h" +#include "Common.h" #include "wiiuse_internal.h" static int wiiuse_connect_single(struct wiimote_t* wm, char* address); diff --git a/Source/Core/wiiuse/Src/io_osx.m b/Source/Core/wiiuse/Src/io_osx.mm similarity index 98% rename from Source/Core/wiiuse/Src/io_osx.m rename to Source/Core/wiiuse/Src/io_osx.mm index 3ad835b7ea..c63925d4c3 100644 --- a/Source/Core/wiiuse/Src/io_osx.m +++ b/Source/Core/wiiuse/Src/io_osx.mm @@ -32,14 +32,14 @@ */ #import -extern OSErr UpdateSystemActivity(UInt8 activity); +extern "C" OSErr UpdateSystemActivity(UInt8 activity); #define BLUETOOTH_VERSION_USE_CURRENT #import #import #import #import -#include "definitions.h" +#include "Common.h" #include "wiiuse_internal.h" static int wiiuse_connect_single(struct wiimote_t *wm, char *address); @@ -49,7 +49,7 @@ IOBluetoothL2CAPChannel *ichan; IOBluetoothL2CAPChannel *cchan; #define QUEUE_SIZE 64 -volatile struct buffer { +struct buffer { char data[MAX_PAYLOAD]; int len; } queue[QUEUE_SIZE]; diff --git a/Source/Core/wiiuse/Src/io_win.cpp b/Source/Core/wiiuse/Src/io_win.cpp index 4ec7a05b0f..3a318f6596 100644 --- a/Source/Core/wiiuse/Src/io_win.cpp +++ b/Source/Core/wiiuse/Src/io_win.cpp @@ -40,11 +40,9 @@ #include #include -#include "definitions.h" +#include "Common.h" #include "wiiuse_internal.h" -#include - typedef struct _HIDD_ATTRIBUTES { ULONG Size; USHORT VendorID; diff --git a/Source/Core/wiiuse/Src/ir.cpp b/Source/Core/wiiuse/Src/ir.cpp index f1bcb31bf0..1a38fcac1d 100644 --- a/Source/Core/wiiuse/Src/ir.cpp +++ b/Source/Core/wiiuse/Src/ir.cpp @@ -38,7 +38,7 @@ #include #endif -#include "definitions.h" +#include "Common.h" #include "wiiuse_internal.h" static int get_ir_sens(struct wiimote_t* wm, const char** block1, const char** block2); diff --git a/Source/Core/wiiuse/Src/wiiuse.cpp b/Source/Core/wiiuse/Src/wiiuse.cpp index cc45638b4e..c990714255 100644 --- a/Source/Core/wiiuse/Src/wiiuse.cpp +++ b/Source/Core/wiiuse/Src/wiiuse.cpp @@ -45,10 +45,9 @@ #include #endif -#include "definitions.h" +#include "Common.h" #include "wiiuse_internal.h" - static int g_banner = 1; /** @@ -301,7 +300,7 @@ int wiiuse_write_data(struct wiimote_t* wm, unsigned int addr, byte* data, byte #endif /* the offset is in big endian */ - *(int*)(buf) = BIG_ENDIAN_LONG(addr); + *(int*)(buf) = Common::swap32(addr); /* XXX only if little-endian */ /* length */ *(byte*)(buf + 4) = len;