mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2024-11-26 15:32:05 +00:00
Add vprintf override for android and esp-idf (#3174)
And update document.
This commit is contained in:
parent
0fa0beba94
commit
8493ffa1cc
|
@ -24,11 +24,15 @@ bh_platform_destroy()
|
||||||
int
|
int
|
||||||
os_printf(const char *fmt, ...)
|
os_printf(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret = 0;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
ret = __android_log_vprint(ANDROID_LOG_INFO, "wasm_runtime::", fmt, ap);
|
#ifndef BH_VPRINTF
|
||||||
|
ret += __android_log_vprint(ANDROID_LOG_INFO, "wasm_runtime::", fmt, ap);
|
||||||
|
#else
|
||||||
|
ret += BH_VPRINTF(fmt, ap);
|
||||||
|
#endif
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -37,7 +41,11 @@ os_printf(const char *fmt, ...)
|
||||||
int
|
int
|
||||||
os_vprintf(const char *fmt, va_list ap)
|
os_vprintf(const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
|
#ifndef BH_VPRINTF
|
||||||
return __android_log_vprint(ANDROID_LOG_INFO, "wasm_runtime::", fmt, ap);
|
return __android_log_vprint(ANDROID_LOG_INFO, "wasm_runtime::", fmt, ap);
|
||||||
|
#else
|
||||||
|
return BH_VPRINTF(fmt, ap);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if __ANDROID_API__ < 19
|
#if __ANDROID_API__ < 19
|
||||||
|
|
|
@ -23,7 +23,11 @@ os_printf(const char *format, ...)
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
|
#ifndef BH_VPRINTF
|
||||||
ret += vprintf(format, ap);
|
ret += vprintf(format, ap);
|
||||||
|
#else
|
||||||
|
ret += BH_VPRINTF(format, ap);
|
||||||
|
#endif
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -32,7 +36,11 @@ os_printf(const char *format, ...)
|
||||||
int
|
int
|
||||||
os_vprintf(const char *format, va_list ap)
|
os_vprintf(const char *format, va_list ap)
|
||||||
{
|
{
|
||||||
|
#ifndef BH_VPRINTF
|
||||||
return vprintf(format, ap);
|
return vprintf(format, ap);
|
||||||
|
#else
|
||||||
|
return BH_VPRINTF(format, ap);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64
|
uint64
|
||||||
|
|
|
@ -176,7 +176,7 @@ Currently we only profile the memory consumption of module, module_instance and
|
||||||
|
|
||||||
#### **Set vprintf callback**
|
#### **Set vprintf callback**
|
||||||
- **WAMR_BH_VPRINTF**=<vprintf_callback>, default to disable if not set
|
- **WAMR_BH_VPRINTF**=<vprintf_callback>, default to disable if not set
|
||||||
> Note: if the vprintf_callback function is provided by developer, the os_printf() and os_vprintf() in Linux, Darwin, Windows and VxWorks platforms, besides WASI Libc output will call the callback function instead of libc vprintf() function to redirect the stdout output. For example, developer can define the callback function like below outside runtime lib:
|
> Note: if the vprintf_callback function is provided by developer, the os_printf() and os_vprintf() in Linux, Darwin, Windows, VxWorks, Android and esp-idf platforms, besides WASI Libc output will call the callback function instead of libc vprintf() function to redirect the stdout output. For example, developer can define the callback function like below outside runtime lib:
|
||||||
>
|
>
|
||||||
> ```C
|
> ```C
|
||||||
> int my_vprintf(const char *format, va_list ap)
|
> int my_vprintf(const char *format, va_list ap)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user