From 81cb80997ac3e0867c954cedcf3b43e7096d35d0 Mon Sep 17 00:00:00 2001 From: bunnei Date: Sun, 27 Apr 2014 21:49:50 -0400 Subject: add missing bswap functions --- src/common/common.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'src/common') diff --git a/src/common/common.h b/src/common/common.h index 418757855..58de0c7d9 100644 --- a/src/common/common.h +++ b/src/common/common.h @@ -159,4 +159,48 @@ enum EMUSTATE_CHANGE EMUSTATE_CHANGE_STOP }; + +#ifdef _MSC_VER +#ifndef _XBOX +inline unsigned long long bswap64(unsigned long long x) { return _byteswap_uint64(x); } +inline unsigned int bswap32(unsigned int x) { return _byteswap_ulong(x); } +inline unsigned short bswap16(unsigned short x) { return _byteswap_ushort(x); } +#else +inline unsigned long long bswap64(unsigned long long x) { return __loaddoublewordbytereverse(0, &x); } +inline unsigned int bswap32(unsigned int x) { return __loadwordbytereverse(0, &x); } +inline unsigned short bswap16(unsigned short x) { return __loadshortbytereverse(0, &x); } +#endif +#else +// TODO: speedup +inline unsigned short bswap16(unsigned short x) { return (x << 8) | (x >> 8); } +inline unsigned int bswap32(unsigned int x) { return (x >> 24) | ((x & 0xFF0000) >> 8) | ((x & 0xFF00) << 8) | (x << 24);} +inline unsigned long long bswap64(unsigned long long x) {return ((unsigned long long)bswap32(x) << 32) | bswap32(x >> 32); } +#endif + +inline float bswapf(float f) { + union { + float f; + unsigned int u32; + } dat1, dat2; + + dat1.f = f; + dat2.u32 = bswap32(dat1.u32); + + return dat2.f; +} + +inline double bswapd(double f) { + union { + double f; + unsigned long long u64; + } dat1, dat2; + + dat1.f = f; + dat2.u64 = bswap64(dat1.u64); + + return dat2.f; +} + +#include "swap.h" + #endif // _COMMON_H_ -- cgit v1.2.3 From ff48c8bed3a7329b57f3889b36492f31e6d44700 Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 27 Apr 2014 22:21:46 -0700 Subject: Rect to BasicRect Somewhere along the line an OSX header had already taken the name Rect. --- src/common/common_types.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/common') diff --git a/src/common/common_types.h b/src/common/common_types.h index 4289b88d3..50cf18738 100644 --- a/src/common/common_types.h +++ b/src/common/common_types.h @@ -101,15 +101,15 @@ union t128 { }; /// Rectangle data structure -class Rect { +class BasicRect { public: - Rect(int x0=0, int y0=0, int x1=0, int y1=0) { + BasicRect(int x0=0, int y0=0, int x1=0, int y1=0) { x0_ = x0; y0_ = y0; x1_ = x1; y1_ = y1; } - ~Rect() { } + ~BasicRect() { } int x0_; ///< Rect top left X-coordinate int y0_; ///< Rect top left Y-coordinate @@ -119,7 +119,7 @@ public: inline u32 width() const { return abs(x1_ - x0_); } inline u32 height() const { return abs(y1_ - y0_); } - inline bool operator == (const Rect& val) const { + inline bool operator == (const BasicRect& val) const { return (x0_ == val.x0_ && y0_ == val.y0_ && x1_ == val.x1_ && y1_ == val.y1_); } }; -- cgit v1.2.3 From 5741f2fb267daa7b1e8001a19bbd243bd2dc8f26 Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 27 Apr 2014 22:24:39 -0700 Subject: Problematic class with no current implementation --- src/common/chunk_file.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/common') diff --git a/src/common/chunk_file.h b/src/common/chunk_file.h index a41205857..c6a7cee35 100644 --- a/src/common/chunk_file.h +++ b/src/common/chunk_file.h @@ -654,7 +654,7 @@ inline PointerWrapSection::~PointerWrapSection() { } -class CChunkFileReader +/*class CChunkFileReader { public: enum Error { @@ -869,6 +869,6 @@ private: int UncompressedSize; char GitVersion[32]; }; -}; +}; */ #endif // _POINTERWRAP_H_ -- cgit v1.2.3 From 5749d1eabe9aa016affdc528c06b2a5f6a7f23a4 Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 27 Apr 2014 22:25:30 -0700 Subject: Fix complaints about functions that could not be found --- src/common/common_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/common') diff --git a/src/common/common_types.h b/src/common/common_types.h index 50cf18738..25dc912a9 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 typedef float f32; ///< 32-bit floating point typedef double f64; ///< 64-bit floating point -#include "common/swap.h" +#include "common/common.h" /// Union for fast 16-bit type casting union t16 { -- cgit v1.2.3 From 5a9c2ce5ea1b272d73001acaf9ec15f1c0e5e041 Mon Sep 17 00:00:00 2001 From: archshift Date: Mon, 28 Apr 2014 19:40:39 -0700 Subject: IT'S ALIVE! --- src/common/CMakeLists.txt | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'src/common') diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 5eaf67365..48f30de4c 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -19,4 +19,42 @@ set(SRCS break_points.cpp timer.cpp utf8.cpp) -add_library(common STATIC ${SRCS}) +set(HEADS atomic.h + atomic_gcc.h + atomic_win32.h + break_points.h + chunk_file.h + common_funcs.h + common_paths.h + common_types.h + common.h + console_listener.h + cpu_detect.h + debug_interface.h + emu_window.h + extended_trace.h + fifo_queue.h + file_search.h + file_util.h + hash.h + linear_disk_cache.h + log_manager.h + log.h + math_util.h + mem_arena.h + memory_util.h + msg_handler.h + platform.h + scm_rev.h + std_condition_variable.h + std_mutex.h + std_thread.h + string_util.h + swap.h + symbols.h + thread.h + thunk.h + timer.h + utf8.h) + +add_library(common STATIC ${SRCS} ${HEADS}) -- cgit v1.2.3 From 52377cf0d2e29143717898e82f09349d417da1a0 Mon Sep 17 00:00:00 2001 From: archshift Date: Tue, 29 Apr 2014 19:27:01 -0700 Subject: Some more experimentation --- src/common/common.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/common') diff --git a/src/common/common.h b/src/common/common.h index 58de0c7d9..30a6761b7 100644 --- a/src/common/common.h +++ b/src/common/common.h @@ -21,11 +21,11 @@ #define STACKALIGN -#if __cplusplus >= 201103 || defined(_MSC_VER) || defined(__GXX_EXPERIMENTAL_CXX0X__) +#if __cplusplus >= 201103L || defined(_MSC_VER) || defined(__GXX_EXPERIMENTAL_CXX0X__) #define HAVE_CXX11_SYNTAX 1 #endif -#if HAVE_CXX11_SYNTAX +//#if HAVE_CXX11_SYNTAX // An inheritable class to disallow the copy constructor and operator= functions class NonCopyable { @@ -37,7 +37,7 @@ private: NonCopyable(NonCopyable&); NonCopyable& operator=(NonCopyable& other); }; -#endif +//#endif #include "common/log.h" #include "common/common_types.h" -- cgit v1.2.3 From 704075f04a8adda82141f3c68addfd6c34a08765 Mon Sep 17 00:00:00 2001 From: archshift Date: Wed, 30 Apr 2014 20:12:01 -0700 Subject: Fixed indents --- src/common/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/common') diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 48f30de4c..ae2331070 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -45,7 +45,7 @@ set(HEADS atomic.h memory_util.h msg_handler.h platform.h - scm_rev.h + scm_rev.h std_condition_variable.h std_mutex.h std_thread.h -- cgit v1.2.3 From 7817d6c79a2c169eb90714c1a05745d208e8ad32 Mon Sep 17 00:00:00 2001 From: archshift Date: Wed, 30 Apr 2014 23:47:38 -0700 Subject: Support for C++11 on OSX --- src/common/common.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/common') diff --git a/src/common/common.h b/src/common/common.h index 30a6761b7..2578d0010 100644 --- a/src/common/common.h +++ b/src/common/common.h @@ -25,7 +25,7 @@ #define HAVE_CXX11_SYNTAX 1 #endif -//#if HAVE_CXX11_SYNTAX +#if HAVE_CXX11_SYNTAX // An inheritable class to disallow the copy constructor and operator= functions class NonCopyable { @@ -37,7 +37,7 @@ private: NonCopyable(NonCopyable&); NonCopyable& operator=(NonCopyable& other); }; -//#endif +#endif #include "common/log.h" #include "common/common_types.h" -- cgit v1.2.3 From c1394650ff0ab1859b93505771e14c9afdb8aeb3 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 16 May 2014 23:39:27 -0700 Subject: Updated cmakelists --- src/common/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) (limited to 'src/common') diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index ae2331070..0027ae2b0 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -22,6 +22,7 @@ set(SRCS break_points.cpp set(HEADS atomic.h atomic_gcc.h atomic_win32.h + bit_field.h break_points.h chunk_file.h common_funcs.h -- cgit v1.2.3 From 403e4bf837c47c7e10dc006fafffea8c160c890f Mon Sep 17 00:00:00 2001 From: archshift Date: Mon, 19 May 2014 15:19:36 -0700 Subject: CMakeLists: rename HEADS, improved comments Changes for clarity of comments, removed redundant compiler flags. --- src/common/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/common') diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 0027ae2b0..aae183393 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -19,7 +19,7 @@ set(SRCS break_points.cpp timer.cpp utf8.cpp) -set(HEADS atomic.h +set(HEADERS atomic.h atomic_gcc.h atomic_win32.h bit_field.h @@ -58,4 +58,4 @@ set(HEADS atomic.h timer.h utf8.h) -add_library(common STATIC ${SRCS} ${HEADS}) +add_library(common STATIC ${SRCS} ${HEADERS}) -- cgit v1.2.3 From 034e3aabc81219ca3804bfa6483d6667c3ab5679 Mon Sep 17 00:00:00 2001 From: archshift Date: Mon, 19 May 2014 15:21:55 -0700 Subject: Improved clarity and whitespace Changed QGL version to 3,2 in order to be less restrictive, yet it should still change up to 4,1 on OSX on Qt5. --- src/common/chunk_file.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/common') diff --git a/src/common/chunk_file.h b/src/common/chunk_file.h index c6a7cee35..8c9f839da 100644 --- a/src/common/chunk_file.h +++ b/src/common/chunk_file.h @@ -654,6 +654,7 @@ inline PointerWrapSection::~PointerWrapSection() { } +// Commented out because it is currently unused, and breaks builds on OSX /*class CChunkFileReader { public: -- cgit v1.2.3 From 5a8ed196e6e9416134a85fbc7da14fed3af307e4 Mon Sep 17 00:00:00 2001 From: archshift Date: Mon, 19 May 2014 17:57:35 -0700 Subject: common_types: Changed BasicRect back to Rect, in the common namespace Only Rect is in the namespace for now; the rest of common should be added in the future --- src/common/common_types.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/common') diff --git a/src/common/common_types.h b/src/common/common_types.h index 25dc912a9..402410507 100644 --- a/src/common/common_types.h +++ b/src/common/common_types.h @@ -100,16 +100,17 @@ union t128 { __m128 a; ///< 128-bit floating point (__m128 maps to the XMM[0-7] registers) }; +namespace common { /// Rectangle data structure -class BasicRect { +class Rect { public: - BasicRect(int x0=0, int y0=0, int x1=0, int y1=0) { + Rect(int x0=0, int y0=0, int x1=0, int y1=0) { x0_ = x0; y0_ = y0; x1_ = x1; y1_ = y1; } - ~BasicRect() { } + ~Rect() { } int x0_; ///< Rect top left X-coordinate int y0_; ///< Rect top left Y-coordinate @@ -119,7 +120,8 @@ public: inline u32 width() const { return abs(x1_ - x0_); } inline u32 height() const { return abs(y1_ - y0_); } - inline bool operator == (const BasicRect& val) const { + inline bool operator == (const Rect& val) const { return (x0_ == val.x0_ && y0_ == val.y0_ && x1_ == val.x1_ && y1_ == val.y1_); } }; +} -- cgit v1.2.3