mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-05-09 21:26:21 +00:00
Fix default vprintf on UWP (#2730)
`platform_common.h` already has a declaration for BH_VPRINTF so we can get rid of the one in `platform_internal.h`. Also add some explicit casts to avoid MSVC compiler warnings.
This commit is contained in:
parent
3c9cd40aa6
commit
fa2839a805
|
@ -183,9 +183,6 @@ typedef uint32_t os_raw_file_handle;
|
||||||
// implementation of vprintf on debug builds so output from WASI libc is sent to
|
// implementation of vprintf on debug builds so output from WASI libc is sent to
|
||||||
// the debugger and not lost completely.
|
// the debugger and not lost completely.
|
||||||
#if !defined(BH_VPRINTF) && !defined(NDEBUG) && WINAPI_PARTITION_DESKTOP == 0
|
#if !defined(BH_VPRINTF) && !defined(NDEBUG) && WINAPI_PARTITION_DESKTOP == 0
|
||||||
int
|
|
||||||
uwp_print_to_debugger(const char *format, va_list ap);
|
|
||||||
|
|
||||||
#define BH_VPRINTF uwp_print_to_debugger
|
#define BH_VPRINTF uwp_print_to_debugger
|
||||||
#define UWP_DEFAULT_VPRINTF
|
#define UWP_DEFAULT_VPRINTF
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "platform_common.h"
|
||||||
#include "win_util.h"
|
#include "win_util.h"
|
||||||
|
|
||||||
__wasi_timestamp_t
|
__wasi_timestamp_t
|
||||||
|
@ -69,17 +70,19 @@ uwp_print_to_debugger(const char *format, va_list ap)
|
||||||
char *buf = stack_buf;
|
char *buf = stack_buf;
|
||||||
int ret = vsnprintf(stack_buf, sizeof(stack_buf), format, ap);
|
int ret = vsnprintf(stack_buf, sizeof(stack_buf), format, ap);
|
||||||
|
|
||||||
if (ret >= sizeof(stack_buf)) {
|
if ((size_t)ret >= sizeof(stack_buf)) {
|
||||||
// Allocate an extra byte for the null terminator.
|
// Allocate an extra byte for the null terminator.
|
||||||
char *heap_buf = BH_MALLOC(ret + 1);
|
char *heap_buf = BH_MALLOC((unsigned int)(ret) + 1);
|
||||||
buf = heap_buf;
|
buf = heap_buf;
|
||||||
|
|
||||||
if (heap_buf == NULL) {
|
if (heap_buf == NULL) {
|
||||||
errno = ENOMEM;
|
// Output as much as we can to the debugger if allocating a buffer
|
||||||
return -1;
|
// fails.
|
||||||
|
OutputDebugStringA(stack_buf);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = vsnprintf(heap_buf, ret + 1, format, ap);
|
ret = vsnprintf(heap_buf, (size_t)ret + 1, format, ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret >= 0)
|
if (ret >= 0)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user