Fix sample littlevgl/gui build issues on zephyr platform (#588)
Fix sample littlevgl/guil build issues on zephyr platform, modify code of zephyr platform by adding some macros to control some apis to fit different zephyr version, and align to zephyr-v2.3.0 for sample littlevgl/gui as the latest zephyr version (>=v2.4.0) requires that the thread stack for the thread to create must be defined by macro but not allocating stack memory dynamically. Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
This commit is contained in:
@ -9,7 +9,12 @@
|
||||
#include <autoconf.h>
|
||||
#include <zephyr.h>
|
||||
#include <kernel.h>
|
||||
#include <version.h>
|
||||
#if KERNEL_VERSION_NUMBER >= 0x020200 /* version 2.2.0 */
|
||||
#include <sys/printk.h>
|
||||
#else
|
||||
#include <misc/printk.h>
|
||||
#endif
|
||||
#include <inttypes.h>
|
||||
#include <stdarg.h>
|
||||
#include <ctype.h>
|
||||
@ -53,7 +58,13 @@ typedef struct korp_cond {
|
||||
os_thread_wait_list thread_wait_list;
|
||||
} korp_cond;
|
||||
|
||||
#define os_printf printf
|
||||
#ifndef Z_TIMEOUT_MS
|
||||
#define Z_TIMEOUT_MS(ms) ms
|
||||
#endif
|
||||
|
||||
void abort(void);
|
||||
size_t strspn(const char *s, const char *accept);
|
||||
size_t strcspn(const char *s, const char *reject);
|
||||
|
||||
/* math functions which are not provided by os */
|
||||
double sqrt(double x);
|
||||
|
||||
@ -101,7 +101,6 @@ char_out(int c, void *ctx)
|
||||
out_ctx->count++;
|
||||
return _stdout_hook_iwasm(c);
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
os_vprintf(const char *fmt, va_list ap)
|
||||
@ -115,6 +114,59 @@ os_vprintf(const char *fmt, va_list ap)
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
#if KERNEL_VERSION_NUMBER <= 0x020400 /* version 2.4.0 */
|
||||
void
|
||||
abort(void)
|
||||
{
|
||||
int i = 0;
|
||||
os_printf("%d\n", 1 / i);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if KERNEL_VERSION_NUMBER <= 0x010E01 /* version 1.14.1 */
|
||||
size_t
|
||||
strspn(const char *s, const char *accept)
|
||||
{
|
||||
os_printf("## unimplemented function %s called", __FUNCTION__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t
|
||||
strcspn(const char *s, const char *reject)
|
||||
{
|
||||
os_printf("## unimplemented function %s called", __FUNCTION__);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
void *
|
||||
os_mmap(void *hint, size_t size, int prot, int flags)
|
||||
|
||||
@ -353,7 +353,12 @@ int os_mutex_lock(korp_mutex *mutex)
|
||||
|
||||
int os_mutex_unlock(korp_mutex *mutex)
|
||||
{
|
||||
#if KERNEL_VERSION_NUMBER >= 0x020200 /* version 2.2.0 */
|
||||
return k_mutex_unlock(mutex);
|
||||
#else
|
||||
k_mutex_unlock(mutex);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int os_cond_init(korp_cond *cond)
|
||||
|
||||
Reference in New Issue
Block a user