diff options
| author | Teetime <TeetimeTW@yahoo.de> | 2013-03-24 04:19:57 +0100 |
|---|---|---|
| committer | Teetime <TeetimeTW@yahoo.de> | 2013-03-24 04:19:57 +0100 |
| commit | 4affc155a906b6091aafc3f9635acc3b8b0aed8a (patch) | |
| tree | 43e4dc20b9c36599571f3caf2e9108a4bb3f5401 /src/base/tl | |
| parent | 6e73cd75bf24eb98781c68ae47d6527cc03262c8 (diff) | |
| parent | 0914490bd994185caef6bfc3038f5cec737e31f3 (diff) | |
| download | zcatch-4affc155a906b6091aafc3f9635acc3b8b0aed8a.tar.gz zcatch-4affc155a906b6091aafc3f9635acc3b8b0aed8a.zip | |
Merge branch 'master0.6' into zCatch
Conflicts: data/languages/index.txt src/game/server/entities/character.cpp
Diffstat (limited to 'src/base/tl')
| -rw-r--r-- | src/base/tl/base.h | 2 | ||||
| -rw-r--r-- | src/base/tl/range.h | 10 | ||||
| -rw-r--r-- | src/base/tl/threading.h | 24 |
3 files changed, 21 insertions, 15 deletions
diff --git a/src/base/tl/base.h b/src/base/tl/base.h index 2fcb14eb..ce77db84 100644 --- a/src/base/tl/base.h +++ b/src/base/tl/base.h @@ -5,7 +5,7 @@ #include <base/system.h> -inline void assert(bool statement) +inline void tl_assert(bool statement) { dbg_assert(statement, "assert!"); } diff --git a/src/base/tl/range.h b/src/base/tl/range.h index f05169fa..1d225f49 100644 --- a/src/base/tl/range.h +++ b/src/base/tl/range.h @@ -150,11 +150,11 @@ public: } bool empty() const { return begin >= end; } - void pop_front() { assert(!empty()); begin++; } - void pop_back() { assert(!empty()); end--; } - T& front() { assert(!empty()); return *begin; } - T& back() { assert(!empty()); return *(end-1); } - T& index(unsigned i) { assert(i >= 0 && i < (unsigned)(end-begin)); return begin[i]; } + void pop_front() { tl_assert(!empty()); begin++; } + void pop_back() { tl_assert(!empty()); end--; } + T& front() { tl_assert(!empty()); return *begin; } + T& back() { tl_assert(!empty()); return *(end-1); } + T& index(unsigned i) { tl_assert(i < (unsigned)(end-begin)); return begin[i]; } unsigned size() const { return (unsigned)(end-begin); } plain_range slice(unsigned startindex, unsigned endindex) { diff --git a/src/base/tl/threading.h b/src/base/tl/threading.h index dbf788cd..5caf8588 100644 --- a/src/base/tl/threading.h +++ b/src/base/tl/threading.h @@ -58,15 +58,21 @@ #error missing atomic implementation for this compiler #endif -class semaphore -{ - SEMAPHORE sem; -public: - semaphore() { semaphore_init(&sem); } - ~semaphore() { semaphore_destroy(&sem); } - void wait() { semaphore_wait(&sem); } - void signal() { semaphore_signal(&sem); } -}; +#if defined(CONF_PLATFORM_MACOSX) + /* + use semaphore provided by SDL on macosx + */ +#else + class semaphore + { + SEMAPHORE sem; + public: + semaphore() { semaphore_init(&sem); } + ~semaphore() { semaphore_destroy(&sem); } + void wait() { semaphore_wait(&sem); } + void signal() { semaphore_signal(&sem); } + }; +#endif class lock { |