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

@ -16,3 +16,30 @@ bh_platform_destroy()
{
}
int
os_printf(const char *format, ...)
{
int ret = 0;
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;
}
int
os_vprintf(const char *format, va_list ap)
{
#ifndef BH_VPRINTF
return vprintf(format, ap);
#else
return BH_VPRINTF(format, ap);
#endif
}

View File

@ -49,9 +49,6 @@ typedef struct {
unsigned int waiting_count;
} korp_cond;
#define os_printf printf
#define os_vprintf vprintf
static inline size_t
getpagesize()
{