diff --git a/include/bx/macros.h b/include/bx/macros.h index bc900bd..fc1747e 100644 --- a/include/bx/macros.h +++ b/include/bx/macros.h @@ -74,7 +74,7 @@ // #define BX_STATIC_ASSERT(_condition, ...) static_assert(_condition, "" __VA_ARGS__) #define BX_STATIC_ASSERT(_condition, ...) typedef char BX_CONCATENATE(BX_STATIC_ASSERT_, __LINE__)[1][(_condition)] -#define BX_CACHE_LINE_ALIGN_MARKER() BX_ALIGN_STRUCT(BX_CACHE_LINE_SIZE, struct) {} +#define BX_CACHE_LINE_ALIGN_MARKER() BX_ALIGN_STRUCT(BX_CACHE_LINE_SIZE, struct) BX_CONCATENATE(bx_cache_line_marker_compiler_stfu, __COUNTER__) {} #define BX_CACHE_LINE_ALIGN(_def) BX_CACHE_LINE_ALIGN_MARKER(); _def; BX_CACHE_LINE_ALIGN_MARKER() #define BX_ALIGN_STRUCT_16(_struct) BX_ALIGN_STRUCT(16, _struct) diff --git a/include/bx/readerwriter.h b/include/bx/readerwriter.h index c777661..f181104 100644 --- a/include/bx/readerwriter.h +++ b/include/bx/readerwriter.h @@ -117,11 +117,19 @@ namespace bx return result; } + /// Skip _offset bytes forward. inline int64_t skip(SeekerI* _seeker, int64_t _offset) { return _seeker->seek(_offset, Whence::Current); } + /// Seek to any position in file. + inline int64_t seek(SeekerI* _seeker, int64_t _offset = 0, Whence::Enum _whence = Whence::Current) + { + return _seeker->seek(_offset, _whence); + } + + /// Returns size of file. inline int64_t getSize(SeekerI* _seeker) { int64_t offset = _seeker->seek(); diff --git a/include/bx/thread.h b/include/bx/thread.h index 0a17446..79afb46 100644 --- a/include/bx/thread.h +++ b/include/bx/thread.h @@ -117,6 +117,11 @@ namespace bx return m_running; } + int32_t getExitCode() const + { + return m_exitCode; + } + private: int32_t entry() { diff --git a/tests/thread.cpp b/tests/thread.cpp new file mode 100644 index 0000000..d0bb100 --- /dev/null +++ b/tests/thread.cpp @@ -0,0 +1,38 @@ +/* + * Copyright 2010-2013 Branimir Karadzic. All rights reserved. + * License: http://www.opensource.org/licenses/BSD-2-Clause + */ + +#include "test.h" +#include + +int32_t threadExit0(void*) +{ + return 0; +} + +int32_t threadExit1(void*) +{ + return 1; +} + +TEST(thread) +{ + bx::Thread th; + + CHECK_EQUAL(th.isRunning(), false); + + th.init(threadExit0); + CHECK_EQUAL(th.isRunning(), true); + th.shutdown(); + + CHECK_EQUAL(th.isRunning(), false); + CHECK_EQUAL(th.getExitCode(), 0); + + th.init(threadExit1); + CHECK_EQUAL(th.isRunning(), true); + th.shutdown(); + + CHECK_EQUAL(th.isRunning(), false); + CHECK_EQUAL(th.getExitCode(), 1); +}