Skip to content

Commit 85e7f30

Browse files
committed
fix: add vprintf override for android and esp-idf
1 parent 12f834a commit 85e7f30

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

core/shared/platform/android/platform_init.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,15 @@ bh_platform_destroy()
2424
int
2525
os_printf(const char *fmt, ...)
2626
{
27-
int ret;
27+
int ret = 0;
2828
va_list ap;
2929

3030
va_start(ap, fmt);
31-
ret = __android_log_vprint(ANDROID_LOG_INFO, "wasm_runtime::", fmt, ap);
31+
#ifndef BH_VPRINTF
32+
ret += __android_log_vprint(ANDROID_LOG_INFO, "wasm_runtime::", fmt, ap);
33+
#else
34+
ret += BH_VPRINTF(fmt, ap);
35+
#endif
3236
va_end(ap);
3337

3438
return ret;
@@ -37,7 +41,11 @@ os_printf(const char *fmt, ...)
3741
int
3842
os_vprintf(const char *fmt, va_list ap)
3943
{
44+
#ifndef BH_VPRINTF
4045
return __android_log_vprint(ANDROID_LOG_INFO, "wasm_runtime::", fmt, ap);
46+
#else
47+
return BH_VPRINTF(fmt, ap);
48+
#endif
4149
}
4250

4351
#if __ANDROID_API__ < 19

core/shared/platform/esp-idf/espidf_platform.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ os_printf(const char *format, ...)
2323
va_list ap;
2424

2525
va_start(ap, format);
26+
#ifndef BH_VPRINTF
2627
ret += vprintf(format, ap);
28+
#else
29+
ret += BH_VPRINTF(format, ap);
30+
#endif
2731
va_end(ap);
2832

2933
return ret;
@@ -32,7 +36,11 @@ os_printf(const char *format, ...)
3236
int
3337
os_vprintf(const char *format, va_list ap)
3438
{
39+
#ifndef BH_VPRINTF
3540
return vprintf(format, ap);
41+
#else
42+
return BH_VPRINTF(format, ap);
43+
#endif
3644
}
3745

3846
uint64

0 commit comments

Comments
 (0)