Enable to use BH_VPRINTF macro to redirect stdout output (#560)

Enable to use BH_VPRINTF macro for platform Linux/Windows/Darwin/VxWorks to redirect the stdout output from platform os_printf/os_vprintf, or the wasi output from wasm app to the vprintf like callback function specified by BH_VPRINTF macro of cmake WAMR_BH_VPRINTF variable.

Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
This commit is contained in:
Wenyong Huang
2021-03-06 08:29:58 -06:00
committed by GitHub
parent a4239f1ffd
commit a1568825e8
10 changed files with 132 additions and 7 deletions

View File

@ -23,7 +23,11 @@ os_printf(const char *format, ...)
va_list ap;
va_start(ap, format);
#ifndef BH_VPRINTF
ret += vprintf(format, ap);
#else
ret += BH_VPRINTF(format, ap);
#endif
va_end(ap);
return ret;
@ -32,6 +36,10 @@ os_printf(const char *format, ...)
int
os_vprintf(const char *format, va_list ap)
{
#ifndef BH_VPRINTF
return vprintf(format, ap);
#else
return BH_VPRINTF(format, ap);
#endif
}