diff options
Diffstat (limited to 'src/common/common.h')
| -rw-r--r-- | src/common/common.h | 171 |
1 files changed, 171 insertions, 0 deletions
diff --git a/src/common/common.h b/src/common/common.h new file mode 100644 index 000000000..3b71d9b3d --- /dev/null +++ b/src/common/common.h | |||
| @@ -0,0 +1,171 @@ | |||
| 1 | // Copyright 2013 Dolphin Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #ifndef _COMMON_H_ | ||
| 6 | #define _COMMON_H_ | ||
| 7 | |||
| 8 | // DO NOT EVER INCLUDE <windows.h> directly _or indirectly_ from this file | ||
| 9 | // since it slows down the build a lot. | ||
| 10 | |||
| 11 | #include <stdlib.h> | ||
| 12 | #include <stdio.h> | ||
| 13 | #include <string.h> | ||
| 14 | |||
| 15 | // SVN version number | ||
| 16 | extern const char *scm_rev_str; | ||
| 17 | extern const char *netplay_dolphin_ver; | ||
| 18 | |||
| 19 | // Force enable logging in the right modes. For some reason, something had changed | ||
| 20 | // so that debugfast no longer logged. | ||
| 21 | #if defined(_DEBUG) || defined(DEBUGFAST) | ||
| 22 | #undef LOGGING | ||
| 23 | #define LOGGING 1 | ||
| 24 | #endif | ||
| 25 | |||
| 26 | #define STACKALIGN | ||
| 27 | |||
| 28 | #if __cplusplus >= 201103 || defined(_MSC_VER) || defined(__GXX_EXPERIMENTAL_CXX0X__) | ||
| 29 | #define HAVE_CXX11_SYNTAX 1 | ||
| 30 | #endif | ||
| 31 | |||
| 32 | #if HAVE_CXX11_SYNTAX | ||
| 33 | // An inheritable class to disallow the copy constructor and operator= functions | ||
| 34 | class NonCopyable | ||
| 35 | { | ||
| 36 | protected: | ||
| 37 | NonCopyable() {} | ||
| 38 | NonCopyable(const NonCopyable&&) {} | ||
| 39 | void operator=(const NonCopyable&&) {} | ||
| 40 | private: | ||
| 41 | NonCopyable(NonCopyable&); | ||
| 42 | NonCopyable& operator=(NonCopyable& other); | ||
| 43 | }; | ||
| 44 | #endif | ||
| 45 | |||
| 46 | #include "log.h" | ||
| 47 | #include "common_types.h" | ||
| 48 | #include "msg_handler.h" | ||
| 49 | #include "common_funcs.h" | ||
| 50 | #include "common_paths.h" | ||
| 51 | #include "platform.h" | ||
| 52 | |||
| 53 | #ifdef __APPLE__ | ||
| 54 | // The Darwin ABI requires that stack frames be aligned to 16-byte boundaries. | ||
| 55 | // This is only needed on i386 gcc - x86_64 already aligns to 16 bytes. | ||
| 56 | #if defined __i386__ && defined __GNUC__ | ||
| 57 | #undef STACKALIGN | ||
| 58 | #define STACKALIGN __attribute__((__force_align_arg_pointer__)) | ||
| 59 | #endif | ||
| 60 | |||
| 61 | #elif defined _WIN32 | ||
| 62 | |||
| 63 | // Check MSC ver | ||
| 64 | #if !defined _MSC_VER || _MSC_VER <= 1000 | ||
| 65 | #error needs at least version 1000 of MSC | ||
| 66 | #endif | ||
| 67 | |||
| 68 | #define NOMINMAX | ||
| 69 | |||
| 70 | // Memory leak checks | ||
| 71 | #define CHECK_HEAP_INTEGRITY() | ||
| 72 | |||
| 73 | // Alignment | ||
| 74 | #define MEMORY_ALIGNED16(x) __declspec(align(16)) x | ||
| 75 | #define MEMORY_ALIGNED32(x) __declspec(align(32)) x | ||
| 76 | #define MEMORY_ALIGNED64(x) __declspec(align(64)) x | ||
| 77 | #define MEMORY_ALIGNED128(x) __declspec(align(128)) x | ||
| 78 | #define MEMORY_ALIGNED16_DECL(x) __declspec(align(16)) x | ||
| 79 | #define MEMORY_ALIGNED64_DECL(x) __declspec(align(64)) x | ||
| 80 | |||
| 81 | // Since they are always around on windows | ||
| 82 | #define HAVE_WX 1 | ||
| 83 | #define HAVE_OPENAL 1 | ||
| 84 | |||
| 85 | #define HAVE_PORTAUDIO 1 | ||
| 86 | |||
| 87 | // Debug definitions | ||
| 88 | #if defined(_DEBUG) | ||
| 89 | #include <crtdbg.h> | ||
| 90 | #undef CHECK_HEAP_INTEGRITY | ||
| 91 | #define CHECK_HEAP_INTEGRITY() {if (!_CrtCheckMemory()) PanicAlert("memory corruption detected. see log.");} | ||
| 92 | // If you want to see how much a pain in the ass singletons are, for example: | ||
| 93 | // {614} normal block at 0x030C5310, 188 bytes long. | ||
| 94 | // Data: <Master Log > 4D 61 73 74 65 72 20 4C 6F 67 00 00 00 00 00 00 | ||
| 95 | struct CrtDebugBreak { CrtDebugBreak(int spot) { _CrtSetBreakAlloc(spot); } }; | ||
| 96 | //CrtDebugBreak breakAt(614); | ||
| 97 | #endif // end DEBUG/FAST | ||
| 98 | |||
| 99 | #endif | ||
| 100 | |||
| 101 | // Windows compatibility | ||
| 102 | #ifndef _WIN32 | ||
| 103 | #include <limits.h> | ||
| 104 | #define MAX_PATH PATH_MAX | ||
| 105 | #ifdef _LP64 | ||
| 106 | #define _M_X64 1 | ||
| 107 | #else | ||
| 108 | #define _M_IX86 1 | ||
| 109 | #endif | ||
| 110 | #define __forceinline inline __attribute__((always_inline)) | ||
| 111 | #define MEMORY_ALIGNED16(x) __attribute__((aligned(16))) x | ||
| 112 | #define MEMORY_ALIGNED32(x) __attribute__((aligned(32))) x | ||
| 113 | #define MEMORY_ALIGNED64(x) __attribute__((aligned(64))) x | ||
| 114 | #define MEMORY_ALIGNED128(x) __attribute__((aligned(128))) x | ||
| 115 | #define MEMORY_ALIGNED16_DECL(x) __attribute__((aligned(16))) x | ||
| 116 | #define MEMORY_ALIGNED64_DECL(x) __attribute__((aligned(64))) x | ||
| 117 | #endif | ||
| 118 | |||
| 119 | #ifdef _MSC_VER | ||
| 120 | #define __strdup _strdup | ||
| 121 | #define __getcwd _getcwd | ||
| 122 | #define __chdir _chdir | ||
| 123 | #else | ||
| 124 | #define __strdup strdup | ||
| 125 | #define __getcwd getcwd | ||
| 126 | #define __chdir chdir | ||
| 127 | #endif | ||
| 128 | |||
| 129 | // Dummy macro for marking translatable strings that can not be immediately translated. | ||
| 130 | // wxWidgets does not have a true dummy macro for this. | ||
| 131 | #define _trans(a) a | ||
| 132 | |||
| 133 | #if defined _M_GENERIC | ||
| 134 | # define _M_SSE 0x0 | ||
| 135 | #elif defined __GNUC__ | ||
| 136 | # if defined __SSE4_2__ | ||
| 137 | # define _M_SSE 0x402 | ||
| 138 | # elif defined __SSE4_1__ | ||
| 139 | # define _M_SSE 0x401 | ||
| 140 | # elif defined __SSSE3__ | ||
| 141 | # define _M_SSE 0x301 | ||
| 142 | # elif defined __SSE3__ | ||
| 143 | # define _M_SSE 0x300 | ||
| 144 | # endif | ||
| 145 | #elif (_MSC_VER >= 1500) || __INTEL_COMPILER // Visual Studio 2008 | ||
| 146 | # define _M_SSE 0x402 | ||
| 147 | #endif | ||
| 148 | |||
| 149 | // Host communication. | ||
| 150 | enum HOST_COMM | ||
| 151 | { | ||
| 152 | // Begin at 10 in case there is already messages with wParam = 0, 1, 2 and so on | ||
| 153 | WM_USER_STOP = 10, | ||
| 154 | WM_USER_CREATE, | ||
| 155 | WM_USER_SETCURSOR, | ||
| 156 | }; | ||
| 157 | |||
| 158 | // Used for notification on emulation state | ||
| 159 | enum EMUSTATE_CHANGE | ||
| 160 | { | ||
| 161 | EMUSTATE_CHANGE_PLAY = 1, | ||
| 162 | EMUSTATE_CHANGE_PAUSE, | ||
| 163 | EMUSTATE_CHANGE_STOP | ||
| 164 | }; | ||
| 165 | |||
| 166 | // This should be used in the private: declarations for a class | ||
| 167 | #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ | ||
| 168 | TypeName(const TypeName&); \ | ||
| 169 | void operator=(const TypeName&) | ||
| 170 | |||
| 171 | #endif // _COMMON_H_ | ||