summaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/CMakeLists.txt41
-rw-r--r--src/common/chunk_file.h5
-rw-r--r--src/common/common.h46
-rw-r--r--src/common/common_types.h4
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
timer.cpp
utf8.cpp)
-add_library(common STATIC ${SRCS})
+set(HEADERS atomic.h
+ atomic_gcc.h
+ atomic_win32.h
+ bit_field.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} ${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() {
}
-class CChunkFileReader
+// Commented out because it is currently unused, and breaks builds on OSX
+/*class CChunkFileReader
{
public:
enum Error {
@@ -869,6 +870,6 @@ private:
int UncompressedSize;
char GitVersion[32];
};
-};
+}; */
#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 @@
#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
@@ -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_
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
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 {
@@ -100,6 +100,7 @@ union t128 {
__m128 a; ///< 128-bit floating point (__m128 maps to the XMM[0-7] registers)
};
+namespace common {
/// Rectangle data structure
class Rect {
public:
@@ -123,3 +124,4 @@ public:
return (x0_ == val.x0_ && y0_ == val.y0_ && x1_ == val.x1_ && y1_ == val.y1_);
}
};
+}