diff options
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/CMakeLists.txt | 41 | ||||
| -rw-r--r-- | src/common/chunk_file.h | 5 | ||||
| -rw-r--r-- | src/common/common.h | 46 | ||||
| -rw-r--r-- | src/common/common_types.h | 4 |
4 files changed, 91 insertions, 5 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 5eaf67365..aae183393 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt | |||
| @@ -19,4 +19,43 @@ set(SRCS break_points.cpp | |||
| 19 | timer.cpp | 19 | timer.cpp |
| 20 | utf8.cpp) | 20 | utf8.cpp) |
| 21 | 21 | ||
| 22 | add_library(common STATIC ${SRCS}) | 22 | set(HEADERS atomic.h |
| 23 | atomic_gcc.h | ||
| 24 | atomic_win32.h | ||
| 25 | bit_field.h | ||
| 26 | break_points.h | ||
| 27 | chunk_file.h | ||
| 28 | common_funcs.h | ||
| 29 | common_paths.h | ||
| 30 | common_types.h | ||
| 31 | common.h | ||
| 32 | console_listener.h | ||
| 33 | cpu_detect.h | ||
| 34 | debug_interface.h | ||
| 35 | emu_window.h | ||
| 36 | extended_trace.h | ||
| 37 | fifo_queue.h | ||
| 38 | file_search.h | ||
| 39 | file_util.h | ||
| 40 | hash.h | ||
| 41 | linear_disk_cache.h | ||
| 42 | log_manager.h | ||
| 43 | log.h | ||
| 44 | math_util.h | ||
| 45 | mem_arena.h | ||
| 46 | memory_util.h | ||
| 47 | msg_handler.h | ||
| 48 | platform.h | ||
| 49 | scm_rev.h | ||
| 50 | std_condition_variable.h | ||
| 51 | std_mutex.h | ||
| 52 | std_thread.h | ||
| 53 | string_util.h | ||
| 54 | swap.h | ||
| 55 | symbols.h | ||
| 56 | thread.h | ||
| 57 | thunk.h | ||
| 58 | timer.h | ||
| 59 | utf8.h) | ||
| 60 | |||
| 61 | add_library(common STATIC ${SRCS} ${HEADERS}) | ||
diff --git a/src/common/chunk_file.h b/src/common/chunk_file.h index a41205857..8c9f839da 100644 --- a/src/common/chunk_file.h +++ b/src/common/chunk_file.h | |||
| @@ -654,7 +654,8 @@ inline PointerWrapSection::~PointerWrapSection() { | |||
| 654 | } | 654 | } |
| 655 | 655 | ||
| 656 | 656 | ||
| 657 | class CChunkFileReader | 657 | // Commented out because it is currently unused, and breaks builds on OSX |
| 658 | /*class CChunkFileReader | ||
| 658 | { | 659 | { |
| 659 | public: | 660 | public: |
| 660 | enum Error { | 661 | enum Error { |
| @@ -869,6 +870,6 @@ private: | |||
| 869 | int UncompressedSize; | 870 | int UncompressedSize; |
| 870 | char GitVersion[32]; | 871 | char GitVersion[32]; |
| 871 | }; | 872 | }; |
| 872 | }; | 873 | }; */ |
| 873 | 874 | ||
| 874 | #endif // _POINTERWRAP_H_ | 875 | #endif // _POINTERWRAP_H_ |
diff --git a/src/common/common.h b/src/common/common.h index 418757855..2578d0010 100644 --- a/src/common/common.h +++ b/src/common/common.h | |||
| @@ -21,7 +21,7 @@ | |||
| 21 | 21 | ||
| 22 | #define STACKALIGN | 22 | #define STACKALIGN |
| 23 | 23 | ||
| 24 | #if __cplusplus >= 201103 || defined(_MSC_VER) || defined(__GXX_EXPERIMENTAL_CXX0X__) | 24 | #if __cplusplus >= 201103L || defined(_MSC_VER) || defined(__GXX_EXPERIMENTAL_CXX0X__) |
| 25 | #define HAVE_CXX11_SYNTAX 1 | 25 | #define HAVE_CXX11_SYNTAX 1 |
| 26 | #endif | 26 | #endif |
| 27 | 27 | ||
| @@ -159,4 +159,48 @@ enum EMUSTATE_CHANGE | |||
| 159 | EMUSTATE_CHANGE_STOP | 159 | EMUSTATE_CHANGE_STOP |
| 160 | }; | 160 | }; |
| 161 | 161 | ||
| 162 | |||
| 163 | #ifdef _MSC_VER | ||
| 164 | #ifndef _XBOX | ||
| 165 | inline unsigned long long bswap64(unsigned long long x) { return _byteswap_uint64(x); } | ||
| 166 | inline unsigned int bswap32(unsigned int x) { return _byteswap_ulong(x); } | ||
| 167 | inline unsigned short bswap16(unsigned short x) { return _byteswap_ushort(x); } | ||
| 168 | #else | ||
| 169 | inline unsigned long long bswap64(unsigned long long x) { return __loaddoublewordbytereverse(0, &x); } | ||
| 170 | inline unsigned int bswap32(unsigned int x) { return __loadwordbytereverse(0, &x); } | ||
| 171 | inline unsigned short bswap16(unsigned short x) { return __loadshortbytereverse(0, &x); } | ||
| 172 | #endif | ||
| 173 | #else | ||
| 174 | // TODO: speedup | ||
| 175 | inline unsigned short bswap16(unsigned short x) { return (x << 8) | (x >> 8); } | ||
| 176 | inline unsigned int bswap32(unsigned int x) { return (x >> 24) | ((x & 0xFF0000) >> 8) | ((x & 0xFF00) << 8) | (x << 24);} | ||
| 177 | inline unsigned long long bswap64(unsigned long long x) {return ((unsigned long long)bswap32(x) << 32) | bswap32(x >> 32); } | ||
| 178 | #endif | ||
| 179 | |||
| 180 | inline float bswapf(float f) { | ||
| 181 | union { | ||
| 182 | float f; | ||
| 183 | unsigned int u32; | ||
| 184 | } dat1, dat2; | ||
| 185 | |||
| 186 | dat1.f = f; | ||
| 187 | dat2.u32 = bswap32(dat1.u32); | ||
| 188 | |||
| 189 | return dat2.f; | ||
| 190 | } | ||
| 191 | |||
| 192 | inline double bswapd(double f) { | ||
| 193 | union { | ||
| 194 | double f; | ||
| 195 | unsigned long long u64; | ||
| 196 | } dat1, dat2; | ||
| 197 | |||
| 198 | dat1.f = f; | ||
| 199 | dat2.u64 = bswap64(dat1.u64); | ||
| 200 | |||
| 201 | return dat2.f; | ||
| 202 | } | ||
| 203 | |||
| 204 | #include "swap.h" | ||
| 205 | |||
| 162 | #endif // _COMMON_H_ | 206 | #endif // _COMMON_H_ |
diff --git a/src/common/common_types.h b/src/common/common_types.h index 4289b88d3..402410507 100644 --- a/src/common/common_types.h +++ b/src/common/common_types.h | |||
| @@ -62,7 +62,7 @@ typedef signed long long s64; ///< 64-bit signed int | |||
| 62 | typedef float f32; ///< 32-bit floating point | 62 | typedef float f32; ///< 32-bit floating point |
| 63 | typedef double f64; ///< 64-bit floating point | 63 | typedef double f64; ///< 64-bit floating point |
| 64 | 64 | ||
| 65 | #include "common/swap.h" | 65 | #include "common/common.h" |
| 66 | 66 | ||
| 67 | /// Union for fast 16-bit type casting | 67 | /// Union for fast 16-bit type casting |
| 68 | union t16 { | 68 | union t16 { |
| @@ -100,6 +100,7 @@ union t128 { | |||
| 100 | __m128 a; ///< 128-bit floating point (__m128 maps to the XMM[0-7] registers) | 100 | __m128 a; ///< 128-bit floating point (__m128 maps to the XMM[0-7] registers) |
| 101 | }; | 101 | }; |
| 102 | 102 | ||
| 103 | namespace common { | ||
| 103 | /// Rectangle data structure | 104 | /// Rectangle data structure |
| 104 | class Rect { | 105 | class Rect { |
| 105 | public: | 106 | public: |
| @@ -123,3 +124,4 @@ public: | |||
| 123 | return (x0_ == val.x0_ && y0_ == val.y0_ && x1_ == val.x1_ && y1_ == val.y1_); | 124 | return (x0_ == val.x0_ && y0_ == val.y0_ && x1_ == val.x1_ && y1_ == val.y1_); |
| 124 | } | 125 | } |
| 125 | }; | 126 | }; |
| 127 | } | ||