From 920cb4f81d96cb46d5ec23f69235aa71615d36d0 Mon Sep 17 00:00:00 2001 From: cxl Date: Mon, 20 Oct 2014 18:17:41 +0000 Subject: [PATCH] Core: BSD/clang patch (thanks SenderGhost) git-svn-id: svn://ultimatepp.org/upp/trunk@7803 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/Core/Core.upp | 2 +- uppsrc/Core/Mt.h | 14 +++++++++++++- uppsrc/plugin/lz4/lz4.upp | 5 ++--- uppsrc/plugin/lz4/result.txt | 3 --- 4 files changed, 16 insertions(+), 8 deletions(-) delete mode 100644 uppsrc/plugin/lz4/result.txt diff --git a/uppsrc/Core/Core.upp b/uppsrc/Core/Core.upp index 0a75f7401..c0efe015e 100644 --- a/uppsrc/Core/Core.upp +++ b/uppsrc/Core/Core.upp @@ -34,7 +34,6 @@ file config.h, Defs.h, Cpu.cpp optimize_speed, - Mt.h, Mt.cpp, OL_Set.cpp, Global.h, @@ -49,6 +48,7 @@ file StringFind.cpp, String.cpp optimize_speed, WString.cpp optimize_speed, + Mt.h, StrUtil.cpp optimize_speed, SplitMerge.h, SplitMerge.cpp optimize_speed, diff --git a/uppsrc/Core/Mt.h b/uppsrc/Core/Mt.h index 70fffc2be..239cb8b66 100644 --- a/uppsrc/Core/Mt.h +++ b/uppsrc/Core/Mt.h @@ -278,9 +278,21 @@ public: #ifdef PLATFORM_POSIX +#if !(defined(PLATFORM_BSD) && defined(__clang__)) typedef _Atomic_word Atomic; +#else +typedef int Atomic; +#endif -inline int AtomicXAdd(volatile Atomic& t, int incr) { using namespace __gnu_cxx; return __exchange_and_add(&t, incr); } +inline int AtomicXAdd(volatile Atomic& t, int incr) +{ +#if !(defined(PLATFORM_BSD) && defined(__clang__)) + using namespace __gnu_cxx; + return __exchange_and_add(&t, incr); +#else + return __sync_fetch_and_add(&t, incr); +#endif +} inline int AtomicInc(volatile Atomic& t) { return AtomicXAdd(t, +1) + 1; } inline int AtomicDec(volatile Atomic& t) { return AtomicXAdd(t, -1) - 1; } diff --git a/uppsrc/plugin/lz4/lz4.upp b/uppsrc/plugin/lz4/lz4.upp index 7d907dd18..6ef30d3f6 100644 --- a/uppsrc/plugin/lz4/lz4.upp +++ b/uppsrc/plugin/lz4/lz4.upp @@ -3,12 +3,11 @@ uses file lz4.h, - lz4upp.cpp, + lz4upp.cpp optimize_speed, util.cpp, lib\lz4.c optimize_speed, lib\lz4.h, - lib\LICENSE, - result.txt; + lib\LICENSE; mainconfig "" = "SSE2"; diff --git a/uppsrc/plugin/lz4/result.txt b/uppsrc/plugin/lz4/result.txt deleted file mode 100644 index adf1a346a..000000000 --- a/uppsrc/plugin/lz4/result.txt +++ /dev/null @@ -1,3 +0,0 @@ -Compress 2.422 -Decompress 1.672 -------------- \ No newline at end of file