diff options
author | 2018-12-05 19:45:08 +0100 | |
---|---|---|
committer | 2018-12-05 19:45:08 +0100 | |
commit | 0bd02131b644b61088789f52f31b750c9aecaa6d (patch) | |
tree | 811c679a1bba8b24fc7967cdfe73640254d64156 /3rdparty/bx/src/debug.cpp | |
parent | 9a81ec7eaf00d73a23db5c003dc45b55d4b76c4a (diff) |
3rdparty: Updated bgfx, bimg, and bx to latest upstream. [Ryan Holtz]
Diffstat (limited to '3rdparty/bx/src/debug.cpp')
-rw-r--r-- | 3rdparty/bx/src/debug.cpp | 58 |
1 files changed, 35 insertions, 23 deletions
diff --git a/3rdparty/bx/src/debug.cpp b/3rdparty/bx/src/debug.cpp index d08fc9903e6..8e8bae122a6 100644 --- a/3rdparty/bx/src/debug.cpp +++ b/3rdparty/bx/src/debug.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2010-2017 Branimir Karadzic. All rights reserved. + * Copyright 2010-2018 Branimir Karadzic. All rights reserved. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ @@ -9,10 +9,12 @@ #include <bx/readerwriter.h> // WriterI #include <inttypes.h> // PRIx* -#if BX_PLATFORM_ANDROID +#if BX_CRT_NONE +# include "crt0.h" +#elif BX_PLATFORM_ANDROID # include <android/log.h> #elif BX_PLATFORM_WINDOWS \ - || BX_PLATFORM_WINRT \ + || BX_PLATFORM_WINRT \ || BX_PLATFORM_XBOXONE extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA(const char* _str); #elif BX_PLATFORM_IOS || BX_PLATFORM_OSX @@ -49,16 +51,19 @@ namespace bx void debugOutput(const char* _out) { -#if BX_PLATFORM_ANDROID +#if BX_CRT_NONE + crt0::debugOutput(_out); +#elif BX_PLATFORM_ANDROID # ifndef BX_ANDROID_LOG_TAG # define BX_ANDROID_LOG_TAG "" # endif // BX_ANDROID_LOG_TAG __android_log_write(ANDROID_LOG_DEBUG, BX_ANDROID_LOG_TAG, _out); #elif BX_PLATFORM_WINDOWS \ - || BX_PLATFORM_WINRT \ + || BX_PLATFORM_WINRT \ || BX_PLATFORM_XBOXONE OutputDebugStringA(_out); -#elif BX_PLATFORM_IOS || BX_PLATFORM_OSX +#elif BX_PLATFORM_IOS \ + || BX_PLATFORM_OSX # if defined(__OBJC__) NSLog(@"%s", _out); # else @@ -66,14 +71,33 @@ namespace bx # endif // defined(__OBJC__) #elif 0 // BX_PLATFORM_EMSCRIPTEN emscripten_log(EM_LOG_CONSOLE, "%s", _out); -#elif !BX_CRT_NONE +#else fputs(_out, stdout); fflush(stdout); -#else - BX_UNUSED(_out); #endif // BX_PLATFORM_ } + void debugOutput(const StringView& _str) + { +#if BX_CRT_NONE + crt0::debugOutput(_str); +#else + const char* data = _str.getPtr(); + int32_t size = _str.getLength(); + + char temp[4096]; + while (0 != size) + { + uint32_t len = uint32_min(sizeof(temp)-1, size); + memCopy(temp, data, len); + temp[len] = '\0'; + data += len; + size -= len; + debugOutput(temp); + } +#endif // BX_CRT_NONE + } + void debugPrintfVargs(const char* _format, va_list _argList) { char temp[8192]; @@ -153,20 +177,8 @@ namespace bx virtual int32_t write(const void* _data, int32_t _size, Error* _err) override { BX_UNUSED(_err); - - int32_t total = 0; - - char temp[4096]; - while (total != _size) - { - uint32_t len = bx::uint32_min(sizeof(temp)-1, _size-total); - memCopy(temp, _data, len); - temp[len] = '\0'; - debugOutput(temp); - total += len; - } - - return total; + debugOutput(StringView( (const char*)_data, _size) ); + return _size; } }; |