diff --git a/include/bx/bx.h b/include/bx/bx.h index 63d726e..63c5404 100644 --- a/include/bx/bx.h +++ b/include/bx/bx.h @@ -15,6 +15,7 @@ #include "platform.h" #include "config.h" #include "macros.h" +#include "debug.h" /// #define BX_COUNTOF(_x) sizeof(bx::CountOfRequireArrayArgumentT(_x) ) diff --git a/include/bx/config.h b/include/bx/config.h index 9a96707..dc7a3a2 100644 --- a/include/bx/config.h +++ b/include/bx/config.h @@ -6,11 +6,13 @@ #ifndef BX_CONFIG_H_HEADER_GUARD #define BX_CONFIG_H_HEADER_GUARD -#include "bx.h" +#ifndef BX_CONFIG_DEBUG +# error "BX_CONFIG_DEBUG must be defined in build script!" +#endif // BX_CONFIG_DEBUG #ifndef BX_CONFIG_ALLOCATOR_DEBUG -# define BX_CONFIG_ALLOCATOR_DEBUG 0 -#endif // BX_CONFIG_DEBUG_ALLOC +# define BX_CONFIG_ALLOCATOR_DEBUG BX_CONFIG_DEBUG +#endif // BX_CONFIG_ALLOCATOR_DEBUG #ifndef BX_CONFIG_SUPPORTS_THREADING # define BX_CONFIG_SUPPORTS_THREADING !(0 \ diff --git a/include/bx/debug.h b/include/bx/debug.h index d8cf15e..74d456c 100644 --- a/include/bx/debug.h +++ b/include/bx/debug.h @@ -6,10 +6,12 @@ #ifndef BX_DEBUG_H_HEADER_GUARD #define BX_DEBUG_H_HEADER_GUARD -#include "string.h" +#include "bx.h" namespace bx { + class StringView; + /// void debugBreak(); diff --git a/include/bx/error.h b/include/bx/error.h index d00d8af..fb09b33 100644 --- a/include/bx/error.h +++ b/include/bx/error.h @@ -71,6 +71,36 @@ namespace bx uint32_t m_code; }; + /// Do nothing even if error is set. + class ErrorIgnore : public Error + { + public: + /// + operator Error*(); + }; + + /// In debug build assert if error is set. + class ErrorAssert : public Error + { + public: + /// + ~ErrorAssert(); + + /// + operator Error*(); + }; + + /// Exit application if error is set. + class ErrorFatal : public Error + { + public: + /// + ~ErrorFatal(); + + /// + operator Error*(); + }; + /// class ErrorScope { diff --git a/include/bx/file.h b/include/bx/file.h index e692224..8df0dda 100644 --- a/include/bx/file.h +++ b/include/bx/file.h @@ -124,19 +124,19 @@ namespace bx /// Creates a directory named `_filePath`. /// - bool make(const FilePath& _filePath, Error* _err = NULL); + bool make(const FilePath& _filePath, Error* _err = bx::ErrorIgnore{}); /// Creates a directory named `_filePath` along with all necessary parents. /// - bool makeAll(const FilePath& _filePath, Error* _err = NULL); + bool makeAll(const FilePath& _filePath, Error* _err = bx::ErrorIgnore{}); /// Removes file or directory. /// - bool remove(const FilePath& _filePath, Error* _err = NULL); + bool remove(const FilePath& _filePath, Error* _err = bx::ErrorIgnore{}); /// Removes file or directory recursivelly. /// - bool removeAll(const FilePath& _filePath, Error* _err = NULL); + bool removeAll(const FilePath& _filePath, Error* _err = bx::ErrorIgnore{}); } // namespace bx diff --git a/include/bx/inline/error.inl b/include/bx/inline/error.inl index 382c624..b4ab8df 100644 --- a/include/bx/inline/error.inl +++ b/include/bx/inline/error.inl @@ -7,6 +7,8 @@ # error "Must be included from bx/error!" #endif // BX_ERROR_H_HEADER_GUARD +#include + namespace bx { inline Error::Error() @@ -59,6 +61,42 @@ namespace bx return _rhs.code != m_code; } + inline ErrorIgnore::operator Error*() + { + return this; + } + + inline ErrorAssert::~ErrorAssert() + { + BX_ASSERT(isOk(), "Error: 0x%08x `%S`" + , get().code + , &getMessage() + ); + } + + inline ErrorFatal::operator Error*() + { + return this; + } + + inline ErrorFatal::~ErrorFatal() + { + if (!isOk() ) + { + printf("Error: 0x%08x `%S`" + , get().code + , &getMessage() + ); + + exit(kExitFailure); + } + } + + inline ErrorAssert::operator Error*() + { + return this; + } + inline ErrorScope::ErrorScope(Error* _err, const StringView& _name) : m_err(_err) , m_name(_name) @@ -70,20 +108,17 @@ namespace bx { if (m_name.isEmpty() ) { - BX_ASSERT(m_err->isOk(), "Error: 0x%08x `%.*s`" + BX_ASSERT(m_err->isOk(), "Error: 0x%08x `%S`" , m_err->get().code - , m_err->getMessage().getLength() - , m_err->getMessage().getPtr() + , &m_err->getMessage() ); } else { - BX_ASSERT(m_err->isOk(), "Error: %.*s - 0x%08x `%.*s`" - , m_name.getLength() - , m_name.getPtr() + BX_ASSERT(m_err->isOk(), "Error: %S - 0x%08x `%S`" + , &m_name , m_err->get().code - , m_err->getMessage().getLength() - , m_err->getMessage().getPtr() + , &m_err->getMessage() ); } } diff --git a/include/bx/macros.h b/include/bx/macros.h index 0d13cc9..341ab03 100644 --- a/include/bx/macros.h +++ b/include/bx/macros.h @@ -229,17 +229,51 @@ #endif // BX_COMPILER_MSVC #ifndef BX_ASSERT -# define BX_ASSERT(_condition, ...) BX_NOOP() +# if BX_CONFIG_DEBUG +# define BX_ASSERT _BX_ASSERT +# else +# define BX_ASSERT(_condition, ...) BX_NOOP() +# endif // BX_CONFIG_DEBUG #endif // BX_ASSERT #ifndef BX_TRACE -# define BX_TRACE(...) BX_NOOP() +# if BX_CONFIG_DEBUG +# define BX_TRACE _BX_TRACE +# else +# define BX_TRACE(...) BX_NOOP() +# endif // BX_CONFIG_DEBUG #endif // BX_TRACE #ifndef BX_WARN -# define BX_WARN(_condition, ...) BX_NOOP() +# if BX_CONFIG_DEBUG +# define BX_WARN _BX_WARN +# else +# define BX_WARN(_condition, ...) BX_NOOP() +# endif // BX_CONFIG_DEBUG #endif // BX_ASSERT +#define _BX_TRACE(_format, ...) \ + BX_MACRO_BLOCK_BEGIN \ + bx::debugPrintf(__FILE__ "(" BX_STRINGIZE(__LINE__) "): BX " _format "\n", ##__VA_ARGS__); \ + BX_MACRO_BLOCK_END + +#define _BX_WARN(_condition, _format, ...) \ + BX_MACRO_BLOCK_BEGIN \ + if (!BX_IGNORE_C4127(_condition) ) \ + { \ + BX_TRACE("WARN " _format, ##__VA_ARGS__); \ + } \ + BX_MACRO_BLOCK_END + +#define _BX_ASSERT(_condition, _format, ...) \ + BX_MACRO_BLOCK_BEGIN \ + if (!BX_IGNORE_C4127(_condition) ) \ + { \ + BX_TRACE("ASSERT " _format, ##__VA_ARGS__); \ + bx::debugBreak(); \ + } \ + BX_MACRO_BLOCK_END + // static_assert sometimes causes unused-local-typedef... BX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG("-Wunused-local-typedef") diff --git a/include/bx/os.h b/include/bx/os.h index f210281..95b56b0 100644 --- a/include/bx/os.h +++ b/include/bx/os.h @@ -6,7 +6,6 @@ #ifndef BX_OS_H_HEADER_GUARD #define BX_OS_H_HEADER_GUARD -#include "debug.h" #include "filepath.h" #if BX_PLATFORM_OSX @@ -56,6 +55,9 @@ namespace bx /// void* exec(const char* const* _argv); + /// + BX_NO_RETURN void exit(int32_t _exitCode); + } // namespace bx #include "inline/os.inl" diff --git a/include/bx/readerwriter.h b/include/bx/readerwriter.h index 45265b2..4b078d3 100644 --- a/include/bx/readerwriter.h +++ b/include/bx/readerwriter.h @@ -81,7 +81,7 @@ namespace bx virtual ~ReaderOpenI() = 0; /// - virtual bool open(const FilePath& _filePath, Error* _err) = 0; + virtual bool open(const FilePath& _filePath, Error* _err = ErrorIgnore{}) = 0; }; /// Open for writing interface. @@ -91,7 +91,7 @@ namespace bx virtual ~WriterOpenI() = 0; /// - virtual bool open(const FilePath& _filePath, bool _append, Error* _err) = 0; + virtual bool open(const FilePath& _filePath, bool _append = false, Error* _err = ErrorIgnore{}) = 0; }; /// Open process interface. @@ -101,7 +101,7 @@ namespace bx virtual ~ProcessOpenI() = 0; /// - virtual bool open(const FilePath& _filePath, const StringView& _args, Error* _err) = 0; + virtual bool open(const FilePath& _filePath, const StringView& _args, Error* _err = ErrorIgnore{}) = 0; }; /// Closer interface. @@ -265,25 +265,25 @@ namespace bx }; /// Read data. - int32_t read(ReaderI* _reader, void* _data, int32_t _size, Error* _err = NULL); + int32_t read(ReaderI* _reader, void* _data, int32_t _size, Error* _err); /// Read value. template - int32_t read(ReaderI* _reader, Ty& _value, Error* _err = NULL); + int32_t read(ReaderI* _reader, Ty& _value, Error* _err); /// Read value and converts it to host endianess. _fromLittleEndian specifies /// underlying stream endianess. template - int32_t readHE(ReaderI* _reader, Ty& _value, bool _fromLittleEndian, Error* _err = NULL); + int32_t readHE(ReaderI* _reader, Ty& _value, bool _fromLittleEndian, Error* _err); /// Write data. - int32_t write(WriterI* _writer, const void* _data, int32_t _size, Error* _err = NULL); + int32_t write(WriterI* _writer, const void* _data, int32_t _size, Error* _err); /// Write C string. - int32_t write(WriterI* _writer, const char* _str, Error* _err = NULL); + int32_t write(WriterI* _writer, const char* _str, Error* _err); /// Write string view. - int32_t write(WriterI* _writer, const StringView& _str, Error* _err = NULL); + int32_t write(WriterI* _writer, const StringView& _str, Error* _err); /// Write formatted string. int32_t write(WriterI* _writer, const StringView& _format, va_list _argList, Error* _err); @@ -295,19 +295,19 @@ namespace bx int32_t write(WriterI* _writer, Error* _err, const char* _format, ...); /// Write repeat the same value. - int32_t writeRep(WriterI* _writer, uint8_t _byte, int32_t _size, Error* _err = NULL); + int32_t writeRep(WriterI* _writer, uint8_t _byte, int32_t _size, Error* _err); /// Write value. template - int32_t write(WriterI* _writer, const Ty& _value, Error* _err = NULL); + int32_t write(WriterI* _writer, const Ty& _value, Error* _err); /// Write value as little endian. template - int32_t writeLE(WriterI* _writer, const Ty& _value, Error* _err = NULL); + int32_t writeLE(WriterI* _writer, const Ty& _value, Error* _err); /// Write value as big endian. template - int32_t writeBE(WriterI* _writer, const Ty& _value, Error* _err = NULL); + int32_t writeBE(WriterI* _writer, const Ty& _value, Error* _err); /// Skip _offset bytes forward. int64_t skip(SeekerI* _seeker, int64_t _offset); @@ -322,26 +322,26 @@ namespace bx int64_t getRemain(SeekerI* _seeker); /// Peek data. - int32_t peek(ReaderSeekerI* _reader, void* _data, int32_t _size, Error* _err = NULL); + int32_t peek(ReaderSeekerI* _reader, void* _data, int32_t _size, Error* _err); /// Peek value. template - int32_t peek(ReaderSeekerI* _reader, Ty& _value, Error* _err = NULL); + int32_t peek(ReaderSeekerI* _reader, Ty& _value, Error* _err); /// Align reader stream. - int32_t align(ReaderSeekerI* _reader, uint32_t _alignment, Error* _err = NULL); + int32_t align(ReaderSeekerI* _reader, uint32_t _alignment, Error* _err); /// Align writer stream (pads stream with zeros). - int32_t align(WriterSeekerI* _writer, uint32_t _alignment, Error* _err = NULL); + int32_t align(WriterSeekerI* _writer, uint32_t _alignment, Error* _err); /// Open for read. - bool open(ReaderOpenI* _reader, const FilePath& _filePath, Error* _err = NULL); + bool open(ReaderOpenI* _reader, const FilePath& _filePath, Error* _err = ErrorIgnore{}); /// Open for write. - bool open(WriterOpenI* _writer, const FilePath& _filePath, bool _append = false, Error* _err = NULL); + bool open(WriterOpenI* _writer, const FilePath& _filePath, bool _append = false, Error* _err = ErrorIgnore{}); /// Open process. - bool open(ProcessOpenI* _process, const FilePath& _filePath, const StringView& _args, Error* _err = NULL); + bool open(ProcessOpenI* _process, const FilePath& _filePath, const StringView& _args, Error* _err = ErrorIgnore{}); /// Close. void close(CloserI* _reader); diff --git a/include/bx/settings.h b/include/bx/settings.h index e5dbc8a..ca5d030 100644 --- a/include/bx/settings.h +++ b/include/bx/settings.h @@ -51,10 +51,10 @@ namespace bx }; /// - int32_t read(ReaderSeekerI* _reader, Settings& _settings, Error* _err = NULL); + int32_t read(ReaderSeekerI* _reader, Settings& _settings, Error* _err); /// - int32_t write(WriterI* _writer, const Settings& _settings, Error* _err = NULL); + int32_t write(WriterI* _writer, const Settings& _settings, Error* _err); } // namespace bx diff --git a/include/bx/string.h b/include/bx/string.h index 5360e12..82dcec0 100644 --- a/include/bx/string.h +++ b/include/bx/string.h @@ -372,7 +372,7 @@ namespace bx { public: /// - LineReader(const bx::StringView& _str); + LineReader(const StringView& _str); /// void reset(); @@ -387,8 +387,8 @@ namespace bx uint32_t getLine() const; private: - const bx::StringView m_str; - bx::StringView m_curr; + const StringView m_str; + StringView m_curr; uint32_t m_line; }; diff --git a/scripts/bin2c.lua b/scripts/bin2c.lua index 3ebc001..86d48a2 100644 --- a/scripts/bin2c.lua +++ b/scripts/bin2c.lua @@ -6,18 +6,12 @@ project "bin2c" kind "ConsoleApp" - includedirs { - "../include", - } - files { "../tools/bin2c/**.cpp", "../tools/bin2c/**.h", } - links { - "bx", - } + using_bx() configuration { "mingw-*" } targetextension ".exe" diff --git a/scripts/bx.lua b/scripts/bx.lua index ed0fcbd..f1c5f39 100644 --- a/scripts/bx.lua +++ b/scripts/bx.lua @@ -15,6 +15,28 @@ local function userdefines() return defines end +function using_bx() + includedirs { + path.join(BX_DIR, "include"), + } + + links { + "bx", + } + + configuration { "Debug" } + defines { + "BX_CONFIG_DEBUG=1", + } + + configuration { "Release" } + defines { + "BX_CONFIG_DEBUG=0", + } + + configuration {} +end + project "bx" kind "StaticLib" @@ -32,11 +54,6 @@ project "bx" defines (userdefines()) - configuration { "Debug" } - defines { - "BX_CONFIG_DEBUG=1", - } - configuration { "linux-*" } buildoptions { "-fPIC", @@ -75,4 +92,14 @@ project "bx" } end + configuration { "Debug" } + defines { + "BX_CONFIG_DEBUG=1", + } + + configuration { "Release" } + defines { + "BX_CONFIG_DEBUG=0", + } + configuration {} diff --git a/scripts/genie.lua b/scripts/genie.lua index 8801b22..39f32aa 100644 --- a/scripts/genie.lua +++ b/scripts/genie.lua @@ -51,7 +51,6 @@ project "bx.test" } includedirs { - path.join(BX_DIR, "include"), BX_THIRD_PARTY_DIR, } @@ -61,9 +60,7 @@ project "bx.test" path.join(BX_DIR, "tests/dbg.*"), } - links { - "bx", - } + using_bx() configuration { "vs* or mingw*" } links { @@ -131,6 +128,16 @@ project "bx.bench" "Cocoa.framework", } + configuration { "Debug" } + defines { + "BX_CONFIG_DEBUG=1", + } + + configuration { "Release" } + defines { + "BX_CONFIG_DEBUG=0", + } + configuration {} strip() diff --git a/src/allocator.cpp b/src/allocator.cpp index 0bcf2cd..8b3883b 100644 --- a/src/allocator.cpp +++ b/src/allocator.cpp @@ -3,7 +3,6 @@ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ -#include "bx_p.h" #include #include @@ -38,7 +37,7 @@ namespace bx BX_UNUSED(_file, _line); _aligned_free(_ptr); # else - bx::alignedFree(this, _ptr, _align, _file, _line); + alignedFree(this, _ptr, _align, _file, _line); # endif // BX_ } @@ -55,7 +54,7 @@ namespace bx BX_UNUSED(_file, _line); return _aligned_malloc(_size, _align); # else - return bx::alignedAlloc(this, _size, _align, _file, _line); + return alignedAlloc(this, _size, _align, _file, _line); # endif // BX_ } @@ -68,7 +67,7 @@ namespace bx BX_UNUSED(_file, _line); return _aligned_realloc(_ptr, _size, _align); # else - return bx::alignedRealloc(this, _ptr, _size, _align, _file, _line); + return alignedRealloc(this, _ptr, _size, _align, _file, _line); # endif // BX_ } diff --git a/src/bounds.cpp b/src/bounds.cpp index 68c6efe..2005b12 100644 --- a/src/bounds.cpp +++ b/src/bounds.cpp @@ -3,7 +3,6 @@ * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause */ -#include "bx_p.h" #include #include #include diff --git a/src/bx.cpp b/src/bx.cpp index 3329d20..43b1238 100644 --- a/src/bx.cpp +++ b/src/bx.cpp @@ -3,7 +3,6 @@ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ -#include "bx_p.h" #include #include diff --git a/src/bx_p.h b/src/bx_p.h deleted file mode 100644 index d44901c..0000000 --- a/src/bx_p.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2010-2021 Branimir Karadzic. All rights reserved. - * License: https://github.com/bkaradzic/bx#license-bsd-2-clause - */ - -#ifndef BX_P_H_HEADER_GUARD -#define BX_P_H_HEADER_GUARD - -#ifndef BX_CONFIG_DEBUG -# define BX_CONFIG_DEBUG 0 -#endif // BX_CONFIG_DEBUG - -#if BX_CONFIG_DEBUG -# define BX_TRACE _BX_TRACE -# define BX_WARN _BX_WARN -# define BX_ASSERT _BX_ASSERT -# define BX_CONFIG_ALLOCATOR_DEBUG 1 -#endif // BX_CONFIG_DEBUG - -#define _BX_TRACE(_format, ...) \ - BX_MACRO_BLOCK_BEGIN \ - bx::debugPrintf(__FILE__ "(" BX_STRINGIZE(__LINE__) "): BX " _format "\n", ##__VA_ARGS__); \ - BX_MACRO_BLOCK_END - -#define _BX_WARN(_condition, _format, ...) \ - BX_MACRO_BLOCK_BEGIN \ - if (!BX_IGNORE_C4127(_condition) ) \ - { \ - BX_TRACE("WARN " _format, ##__VA_ARGS__); \ - } \ - BX_MACRO_BLOCK_END - -#define _BX_ASSERT(_condition, _format, ...) \ - BX_MACRO_BLOCK_BEGIN \ - if (!BX_IGNORE_C4127(_condition) ) \ - { \ - BX_TRACE("CHECK " _format, ##__VA_ARGS__); \ - bx::debugBreak(); \ - } \ - BX_MACRO_BLOCK_END - -#include -#include - -#endif // BX_P_H_HEADER_GUARD diff --git a/src/commandline.cpp b/src/commandline.cpp index 2ff57f6..758b3e0 100644 --- a/src/commandline.cpp +++ b/src/commandline.cpp @@ -3,7 +3,6 @@ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ -#include "bx_p.h" #include #include diff --git a/src/crtnone.cpp b/src/crtnone.cpp index 7852f37..3b00ee3 100644 --- a/src/crtnone.cpp +++ b/src/crtnone.cpp @@ -3,7 +3,6 @@ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ -#include "bx_p.h" #include #include #include diff --git a/src/debug.cpp b/src/debug.cpp index b02e53f..59e12a3 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -3,7 +3,6 @@ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ -#include "bx_p.h" #include #include // isPrint #include // WriterI diff --git a/src/dtoa.cpp b/src/dtoa.cpp index 99b27a5..5ae5ad9 100644 --- a/src/dtoa.cpp +++ b/src/dtoa.cpp @@ -3,7 +3,6 @@ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ -#include "bx_p.h" #include #include #include @@ -1120,7 +1119,7 @@ namespace bx bool fromString(int32_t* _out, const StringView& _str) { - StringView str = bx::strLTrimSpace(_str); + StringView str = strLTrimSpace(_str); const char* ptr = str.getPtr(); const char* term = str.getTerm(); diff --git a/src/easing.cpp b/src/easing.cpp index ec4c451..1de7a95 100644 --- a/src/easing.cpp +++ b/src/easing.cpp @@ -3,7 +3,6 @@ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ -#include "bx_p.h" #include namespace bx diff --git a/src/file.cpp b/src/file.cpp index c47eb37..f3d6534 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -3,7 +3,6 @@ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ -#include "bx_p.h" #include #ifndef BX_CONFIG_CRT_FILE_READER_WRITER @@ -923,7 +922,7 @@ namespace bx Error err; DirectoryReader dr; - if (!bx::open(&dr, _filePath) ) + if (!open(&dr, _filePath, &err) ) { BX_ERROR_SET(_err, kErrorNotDirectory, "File already exist, and is not directory."); return false; @@ -931,7 +930,7 @@ namespace bx while (err.isOk() ) { - bx::read(&dr, fi, &err); + read(&dr, fi, &err); if (err.isOk() ) { @@ -951,7 +950,7 @@ namespace bx } } - bx::close(&dr); + close(&dr); return remove(_filePath, _err); } diff --git a/src/filepath.cpp b/src/filepath.cpp index 14b3478..6bc1a02 100644 --- a/src/filepath.cpp +++ b/src/filepath.cpp @@ -3,7 +3,6 @@ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ -#include "bx_p.h" #include #include #include diff --git a/src/hash.cpp b/src/hash.cpp index bdef607..a76e483 100644 --- a/src/hash.cpp +++ b/src/hash.cpp @@ -3,7 +3,6 @@ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ -#include "bx_p.h" #include namespace bx diff --git a/src/math.cpp b/src/math.cpp index 71f96c5..b572fc0 100644 --- a/src/math.cpp +++ b/src/math.cpp @@ -3,7 +3,6 @@ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ -#include "bx_p.h" #include #include diff --git a/src/mutex.cpp b/src/mutex.cpp index 6f6da64..d04d85e 100644 --- a/src/mutex.cpp +++ b/src/mutex.cpp @@ -3,7 +3,6 @@ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ -#include "bx_p.h" #include #if BX_CONFIG_SUPPORTS_THREADING @@ -59,12 +58,12 @@ namespace bx { uint32_t* futex = (uint32_t*)m_internal; - if (State::Unlocked == bx::atomicCompareAndSwap(futex, State::Unlocked, State::Locked) ) + if (State::Unlocked == atomicCompareAndSwap(futex, State::Unlocked, State::Locked) ) { return; } - while (State::Unlocked != bx::atomicCompareAndSwap(futex, State::Locked, State::Contested) ) + while (State::Unlocked != atomicCompareAndSwap(futex, State::Locked, State::Contested) ) { crt0::futexWait(futex, State::Contested); } @@ -74,7 +73,7 @@ namespace bx { uint32_t* futex = (uint32_t*)m_internal; - if (State::Contested == bx::atomicCompareAndSwap(futex, State::Locked, State::Unlocked) ) + if (State::Contested == atomicCompareAndSwap(futex, State::Locked, State::Unlocked) ) { crt0::futexWake(futex, State::Locked); } diff --git a/src/os.cpp b/src/os.cpp index 65ce48a..e1e85be 100644 --- a/src/os.cpp +++ b/src/os.cpp @@ -3,7 +3,6 @@ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ -#include "bx_p.h" #include #include #include @@ -209,7 +208,7 @@ namespace bx { const int32_t symbolMax = _symbol.getLength()+1; char* symbol = (char*)alloca(symbolMax); - bx::strCopy(symbol, symbolMax, _symbol); + strCopy(symbol, symbolMax, _symbol); #if BX_PLATFORM_WINDOWS return (void*)::GetProcAddress( (HMODULE)_handle, symbol); @@ -229,7 +228,7 @@ namespace bx { const int32_t nameMax = _name.getLength()+1; char* name = (char*)alloca(nameMax); - bx::strCopy(name, nameMax, _name); + strCopy(name, nameMax, _name); #if BX_PLATFORM_WINDOWS DWORD len = ::GetEnvironmentVariableA(name, _out, *_inOutSize); @@ -267,14 +266,14 @@ namespace bx { const int32_t nameMax = _name.getLength()+1; char* name = (char*)alloca(nameMax); - bx::strCopy(name, nameMax, _name); + strCopy(name, nameMax, _name); char* value = NULL; if (!_value.isEmpty() ) { int32_t valueMax = _value.getLength()+1; value = (char*)alloca(valueMax); - bx::strCopy(value, valueMax, _value); + strCopy(value, valueMax, _value); } #if BX_PLATFORM_WINDOWS @@ -344,7 +343,7 @@ namespace bx int32_t len = 0; for(uint32_t ii = 0; NULL != _argv[ii]; ++ii) { - len += snprintf(&temp[len], bx::uint32_imax(0, total-len) + len += snprintf(&temp[len], uint32_imax(0, total-len) , "%s " , _argv[ii] ); @@ -373,4 +372,9 @@ namespace bx #endif // BX_PLATFORM_LINUX || BX_PLATFORM_HURD } + void exit(int32_t _exitCode) + { + ::exit(_exitCode); + } + } // namespace bx diff --git a/src/process.cpp b/src/process.cpp index 8dc2a6b..9fe2636 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -3,7 +3,6 @@ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ -#include "bx_p.h" #include #include diff --git a/src/semaphore.cpp b/src/semaphore.cpp index 4b62d08..f61071c 100644 --- a/src/semaphore.cpp +++ b/src/semaphore.cpp @@ -3,7 +3,6 @@ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ -#include "bx_p.h" #include #if BX_CONFIG_SUPPORTS_THREADING diff --git a/src/settings.cpp b/src/settings.cpp index daed2f1..a536781 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -3,7 +3,6 @@ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ -#include "bx_p.h" #include namespace diff --git a/src/sort.cpp b/src/sort.cpp index ce1b3e3..670c3bc 100644 --- a/src/sort.cpp +++ b/src/sort.cpp @@ -3,7 +3,6 @@ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ -#include "bx_p.h" #include namespace bx diff --git a/src/string.cpp b/src/string.cpp index 9cfd948..b95c69c 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -3,7 +3,6 @@ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ -#include "bx_p.h" #include #include #include diff --git a/src/thread.cpp b/src/thread.cpp index c53aa87..87cbc9a 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -3,7 +3,6 @@ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ -#include "bx_p.h" #include #include @@ -267,7 +266,7 @@ namespace bx if (NULL != SetThreadDescription) { - uint32_t length = (uint32_t)bx::strLen(_name)+1; + uint32_t length = (uint32_t)strLen(_name)+1; uint32_t size = length*sizeof(wchar_t); wchar_t* name = (wchar_t*)alloca(size); mbstowcs(name, _name, size-2); diff --git a/src/timer.cpp b/src/timer.cpp index b6ef62e..664939b 100644 --- a/src/timer.cpp +++ b/src/timer.cpp @@ -3,7 +3,6 @@ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ -#include "bx_p.h" #include #if BX_CRT_NONE diff --git a/src/url.cpp b/src/url.cpp index ce02bd3..0a3f615 100644 --- a/src/url.cpp +++ b/src/url.cpp @@ -3,7 +3,6 @@ * License: https://github.com/bkaradzic/bnet#license-bsd-2-clause */ -#include "bx_p.h" #include namespace bx diff --git a/tests/easing_test.cpp b/tests/easing_test.cpp index ff0a819..1c0448a 100644 --- a/tests/easing_test.cpp +++ b/tests/easing_test.cpp @@ -42,7 +42,7 @@ TEST_CASE("easing", "") if (vv >= ys && vv < ye) { - bx::write(writer, "*"); + bx::write(writer, &err, "*"); break; } } diff --git a/tests/settings_test.cpp b/tests/settings_test.cpp index 85b72c4..b1f1824 100644 --- a/tests/settings_test.cpp +++ b/tests/settings_test.cpp @@ -21,9 +21,9 @@ TEST_CASE("Settings", "") settings.set("test/foo/bar/abvgd", "1389"); bx::FileWriter writer; - if (bx::open(&writer, filePath) ) + if (bx::open(&writer, filePath, false, bx::ErrorIgnore{}) ) { - bx::write(&writer, settings); + bx::write(&writer, settings, bx::ErrorIgnore{}); bx::close(&writer); } @@ -37,9 +37,9 @@ TEST_CASE("Settings", "") settings.clear(); bx::FileReader reader; - if (bx::open(&reader, filePath) ) + if (bx::open(&reader, filePath, bx::ErrorIgnore{}) ) { - bx::read(&reader, settings); + bx::read(&reader, settings, bx::ErrorIgnore{}); bx::close(&reader); } diff --git a/tests/test.h b/tests/test.h index 88c39f8..cb7fd05 100644 --- a/tests/test.h +++ b/tests/test.h @@ -3,8 +3,8 @@ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ -#ifndef __TEST_H__ -#define __TEST_H__ +#ifndef BX_TEST_H_HEADER_GUARD +#define BX_TEST_H_HEADER_GUARD #include @@ -18,4 +18,4 @@ BX_PRAGMA_DIAGNOSTIC_POP(); #include "dbg.h" -#endif // __TEST_H__ +#endif // BX_TEST_H_HEADER_GUARD diff --git a/tools/bin/linux/bin2c b/tools/bin/linux/bin2c index 2b8fca8..a79a17d 100755 Binary files a/tools/bin/linux/bin2c and b/tools/bin/linux/bin2c differ diff --git a/tools/bin2c/bin2c.cpp b/tools/bin2c/bin2c.cpp index 066d9e2..40f737c 100644 --- a/tools/bin2c/bin2c.cpp +++ b/tools/bin2c/bin2c.cpp @@ -252,14 +252,14 @@ int main(int _argc, const char* _argv[]) bx::DefaultAllocator allocator; data = BX_ALLOC(&allocator, size); - bx::read(&fr, data, size); + bx::read(&fr, data, size, bx::ErrorAssert{}); bx::close(&fr); bx::FileWriter fw; if (bx::open(&fw, outFilePath) ) { Bin2cWriter writer(&allocator, name); - bx::write(&writer, data, size); + bx::write(&writer, data, size, bx::ErrorAssert{}); writer.output(&fw); bx::close(&fw);