krillplayer-plugin 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +2 -1
- package/README.md +1 -0
- package/dist/cli.js +351 -73
- package/dist/crypto.js +37 -11
- package/dist/engine/engine.c +6 -3
- package/kernel/Sources/CQuickJS/include/kernel_qjs.h +8 -1
- package/kernel/Sources/CQuickJS/kernel_internal.h +54 -0
- package/kernel/Sources/CQuickJS/kernel_qjs.c +17 -29
- package/kernel/Sources/CQuickJS/kernel_wasm.c +1155 -0
- package/kernel/Sources/CWAMR/include/kernel_wamr.h +151 -0
- package/kernel/Sources/CWAMR/include/kernel_wamr_config.h +66 -0
- package/kernel/Sources/CWAMR/vendor/LICENSE +219 -0
- package/kernel/Sources/CWAMR/vendor/core/config.h +727 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/aot/aot_runtime.h +899 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/common/arch/invokeNative_general.c +123 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_application.c +933 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_blocking_op.c +92 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_c_api.c +5391 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_c_api_internal.h +246 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_exec_env.c +336 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_exec_env.h +328 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_loader_common.c +242 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_loader_common.h +62 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_memory.c +1999 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_memory.h +154 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_native.c +1532 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_native.h +117 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_runtime_common.c +8070 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_runtime_common.h +1396 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_shared_memory.c +477 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_shared_memory.h +63 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/common/wasm_suspend_flags.h +52 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/compilation/aot.h +366 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/include/lib_export.h +60 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/include/wasm_c_api.h +910 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/include/wasm_export.h +2440 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/interpreter/wasm.h +1492 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/interpreter/wasm_interp.h +122 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/interpreter/wasm_interp_fast.c +7998 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/interpreter/wasm_loader.c +16909 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/interpreter/wasm_loader.h +80 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/interpreter/wasm_opcode.h +1043 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/interpreter/wasm_runtime.c +5174 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/interpreter/wasm_runtime.h +912 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/libraries/thread-mgr/thread_manager.c +1569 -0
- package/kernel/Sources/CWAMR/vendor/core/iwasm/libraries/thread-mgr/thread_manager.h +256 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/mem-alloc/ems/ems_alloc.c +1169 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/mem-alloc/ems/ems_gc.c +497 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/mem-alloc/ems/ems_gc.h +350 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/mem-alloc/ems/ems_gc_internal.h +384 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/mem-alloc/ems/ems_hmu.c +95 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/mem-alloc/ems/ems_kfc.c +547 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/mem-alloc/mem_alloc.c +252 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/mem-alloc/mem_alloc.h +96 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/platform/common/memory/mremap.c +12 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/platform/common/posix/posix_blocking_op.c +70 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/platform/common/posix/posix_malloc.c +72 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/platform/common/posix/posix_memmap.c +302 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/platform/common/posix/posix_sleep.c +20 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/platform/common/posix/posix_thread.c +784 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/platform/common/posix/posix_time.c +28 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/platform/darwin/platform_init.c +43 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/platform/darwin/platform_internal.h +126 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/platform/include/platform_api_extension.h +1676 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/platform/include/platform_api_vmcore.h +192 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/platform/include/platform_common.h +204 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/platform/include/platform_wasi_types.h +610 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/platform/linux/platform_init.c +43 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/platform/linux/platform_internal.h +139 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_assert.c +25 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_assert.h +42 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_atomic.h +300 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_bitmap.c +27 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_bitmap.h +114 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_common.c +217 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_common.h +83 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_hashmap.c +339 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_hashmap.h +168 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_leb128.c +77 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_leb128.h +30 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_list.c +111 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_list.h +109 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_log.c +111 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_log.h +94 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_platform.h +38 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_queue.c +256 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_queue.h +80 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_vector.c +279 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/bh_vector.h +126 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/gnuc.h +14 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/runtime_timer.c +469 -0
- package/kernel/Sources/CWAMR/vendor/core/shared/utils/runtime_timer.h +51 -0
- package/kernel/Sources/CWAMR/vendor/core/version.h +24 -0
- package/kernel/Sources/CWAMR/wamr_bh_assert.c +98 -0
- package/kernel/Sources/CWAMR/wamr_bh_bitmap.c +98 -0
- package/kernel/Sources/CWAMR/wamr_bh_common.c +98 -0
- package/kernel/Sources/CWAMR/wamr_bh_hashmap.c +98 -0
- package/kernel/Sources/CWAMR/wamr_bh_leb128.c +98 -0
- package/kernel/Sources/CWAMR/wamr_bh_list.c +98 -0
- package/kernel/Sources/CWAMR/wamr_bh_log.c +98 -0
- package/kernel/Sources/CWAMR/wamr_bh_queue.c +98 -0
- package/kernel/Sources/CWAMR/wamr_bh_vector.c +98 -0
- package/kernel/Sources/CWAMR/wamr_ems_alloc.c +98 -0
- package/kernel/Sources/CWAMR/wamr_ems_gc.c +98 -0
- package/kernel/Sources/CWAMR/wamr_ems_hmu.c +98 -0
- package/kernel/Sources/CWAMR/wamr_ems_kfc.c +98 -0
- package/kernel/Sources/CWAMR/wamr_invokeNative_general.c +98 -0
- package/kernel/Sources/CWAMR/wamr_mem_alloc.c +98 -0
- package/kernel/Sources/CWAMR/wamr_mremap.c +98 -0
- package/kernel/Sources/CWAMR/wamr_platform_init_darwin.c +100 -0
- package/kernel/Sources/CWAMR/wamr_platform_init_linux.c +100 -0
- package/kernel/Sources/CWAMR/wamr_posix_blocking_op.c +98 -0
- package/kernel/Sources/CWAMR/wamr_posix_malloc.c +98 -0
- package/kernel/Sources/CWAMR/wamr_posix_memmap.c +98 -0
- package/kernel/Sources/CWAMR/wamr_posix_sleep.c +98 -0
- package/kernel/Sources/CWAMR/wamr_posix_thread.c +98 -0
- package/kernel/Sources/CWAMR/wamr_posix_time.c +98 -0
- package/kernel/Sources/CWAMR/wamr_runtime_timer.c +98 -0
- package/kernel/Sources/CWAMR/wamr_thread_manager.c +98 -0
- package/kernel/Sources/CWAMR/wamr_wasm_application.c +98 -0
- package/kernel/Sources/CWAMR/wamr_wasm_blocking_op.c +98 -0
- package/kernel/Sources/CWAMR/wamr_wasm_c_api.c +98 -0
- package/kernel/Sources/CWAMR/wamr_wasm_exec_env.c +98 -0
- package/kernel/Sources/CWAMR/wamr_wasm_interp_fast.c +98 -0
- package/kernel/Sources/CWAMR/wamr_wasm_loader.c +98 -0
- package/kernel/Sources/CWAMR/wamr_wasm_loader_common.c +98 -0
- package/kernel/Sources/CWAMR/wamr_wasm_memory.c +98 -0
- package/kernel/Sources/CWAMR/wamr_wasm_native.c +98 -0
- package/kernel/Sources/CWAMR/wamr_wasm_runtime.c +98 -0
- package/kernel/Sources/CWAMR/wamr_wasm_runtime_common.c +98 -0
- package/kernel/Sources/CWAMR/wamr_wasm_shared_memory.c +98 -0
- package/kernel/Sources/Kernel/PluginPrelude.js +5 -2
- package/kernel/Tests/KernelTests/CasePins.js +50 -0
- package/package.json +2 -2
- package/skill/krillplayer-plugin/SKILL.md +2 -0
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/danmaku-send-content-rejected.json +8 -4
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/danmaku-send-login-expired.json +8 -4
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/danmaku-send-muted.json +8 -4
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/danmaku-send-other.json +8 -4
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/danmaku-send-rate-limited.json +8 -4
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/danmaku-send-sent.json +8 -4
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/play-live-logged-in.json +39 -0
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/play-live-selected-backup-line.json +8 -0
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/play-live-selected-line-gone.json +8 -0
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/play-live.json +8 -0
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/plugin.ts +26 -9
- package/skill/krillplayer-plugin/references/cases.md +19 -1
- package/skill/krillplayer-plugin/references/contract.d.ts +104 -11
- package/skill/krillplayer-plugin/references/crypto-tools.md +104 -0
- package/skill/krillplayer-plugin/references/errors-and-fixes.md +5 -1
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
#ifndef _PLATFORM_API_VMCORE_H
|
|
7
|
+
#define _PLATFORM_API_VMCORE_H
|
|
8
|
+
|
|
9
|
+
#include "platform_common.h"
|
|
10
|
+
#include "platform_internal.h"
|
|
11
|
+
|
|
12
|
+
#ifdef __cplusplus
|
|
13
|
+
extern "C" {
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
/****************************************************
|
|
17
|
+
* Section 1 *
|
|
18
|
+
* Interfaces required by the runtime *
|
|
19
|
+
****************************************************/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Initialize the platform internal resources if needed,
|
|
23
|
+
* this function is called by wasm_runtime_init() and
|
|
24
|
+
* wasm_runtime_full_init()
|
|
25
|
+
*
|
|
26
|
+
* @return 0 if success
|
|
27
|
+
*/
|
|
28
|
+
int
|
|
29
|
+
bh_platform_init(void);
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Destroy the platform internal resources if needed,
|
|
33
|
+
* this function is called by wasm_runtime_destroy()
|
|
34
|
+
*/
|
|
35
|
+
void
|
|
36
|
+
bh_platform_destroy(void);
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
******** memory allocator APIs **********
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
void *
|
|
43
|
+
os_malloc(unsigned size);
|
|
44
|
+
|
|
45
|
+
void *
|
|
46
|
+
os_realloc(void *ptr, unsigned size);
|
|
47
|
+
|
|
48
|
+
void
|
|
49
|
+
os_free(void *ptr);
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Note: the above APIs can simply return NULL if wasm runtime
|
|
53
|
+
* isn't initialized with Alloc_With_System_Allocator.
|
|
54
|
+
* Refer to wasm_runtime_full_init().
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
int
|
|
58
|
+
os_printf(const char *format, ...);
|
|
59
|
+
|
|
60
|
+
int
|
|
61
|
+
os_vprintf(const char *format, va_list ap);
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Get microseconds after boot.
|
|
65
|
+
*/
|
|
66
|
+
uint64
|
|
67
|
+
os_time_get_boot_us(void);
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Get thread-specific CPU-time clock in microseconds
|
|
71
|
+
*/
|
|
72
|
+
uint64
|
|
73
|
+
os_time_thread_cputime_us(void);
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Get current thread id.
|
|
77
|
+
* Implementation optional: Used by runtime for logging only.
|
|
78
|
+
*/
|
|
79
|
+
korp_tid
|
|
80
|
+
os_self_thread(void);
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Get current thread's stack boundary address, used for runtime
|
|
84
|
+
* to check the native stack overflow. Return NULL if it is not
|
|
85
|
+
* easy to implement, but may have potential issue.
|
|
86
|
+
*/
|
|
87
|
+
uint8 *
|
|
88
|
+
os_thread_get_stack_boundary(void);
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Set whether the MAP_JIT region write protection is enabled for this thread.
|
|
92
|
+
* Pass true to make the region executable, false to make it writable.
|
|
93
|
+
*/
|
|
94
|
+
void
|
|
95
|
+
os_thread_jit_write_protect_np(bool enabled);
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
************** mutext APIs ***********
|
|
99
|
+
* vmcore: Not required until pthread is supported by runtime
|
|
100
|
+
* app-mgr: Must be implemented
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
int
|
|
104
|
+
os_mutex_init(korp_mutex *mutex);
|
|
105
|
+
|
|
106
|
+
int
|
|
107
|
+
os_mutex_destroy(korp_mutex *mutex);
|
|
108
|
+
|
|
109
|
+
int
|
|
110
|
+
os_mutex_lock(korp_mutex *mutex);
|
|
111
|
+
|
|
112
|
+
int
|
|
113
|
+
os_mutex_unlock(korp_mutex *mutex);
|
|
114
|
+
|
|
115
|
+
/**************************************************
|
|
116
|
+
* Section 2 *
|
|
117
|
+
* APIs required by WAMR AOT *
|
|
118
|
+
**************************************************/
|
|
119
|
+
|
|
120
|
+
/* Memory map modes */
|
|
121
|
+
enum {
|
|
122
|
+
MMAP_PROT_NONE = 0,
|
|
123
|
+
MMAP_PROT_READ = 1,
|
|
124
|
+
MMAP_PROT_WRITE = 2,
|
|
125
|
+
MMAP_PROT_EXEC = 4
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
/* Memory map flags */
|
|
129
|
+
enum {
|
|
130
|
+
MMAP_MAP_NONE = 0,
|
|
131
|
+
/* Put the mapping into 0 to 2 G, supported only on x86_64 */
|
|
132
|
+
MMAP_MAP_32BIT = 1,
|
|
133
|
+
/* Don't interpret addr as a hint: place the mapping at exactly
|
|
134
|
+
that address. */
|
|
135
|
+
MMAP_MAP_FIXED = 2,
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
void *
|
|
139
|
+
os_mmap(void *hint, size_t size, int prot, int flags, os_file_handle file);
|
|
140
|
+
void
|
|
141
|
+
os_munmap(void *addr, size_t size);
|
|
142
|
+
int
|
|
143
|
+
os_mprotect(void *addr, size_t size, int prot);
|
|
144
|
+
|
|
145
|
+
static inline void *
|
|
146
|
+
os_mremap_slow(void *old_addr, size_t old_size, size_t new_size)
|
|
147
|
+
{
|
|
148
|
+
void *new_memory = os_mmap(NULL, new_size, MMAP_PROT_WRITE | MMAP_PROT_READ,
|
|
149
|
+
0, os_get_invalid_handle());
|
|
150
|
+
if (!new_memory) {
|
|
151
|
+
return NULL;
|
|
152
|
+
}
|
|
153
|
+
/*
|
|
154
|
+
* bh_memcpy_s can't be used as it doesn't support values bigger than
|
|
155
|
+
* UINT32_MAX
|
|
156
|
+
*/
|
|
157
|
+
memcpy(new_memory, old_addr, new_size < old_size ? new_size : old_size);
|
|
158
|
+
os_munmap(old_addr, old_size);
|
|
159
|
+
|
|
160
|
+
return new_memory;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/* Doesn't guarantee that protection flags will be preserved.
|
|
164
|
+
os_mprotect() must be called after remapping. */
|
|
165
|
+
void *
|
|
166
|
+
os_mremap(void *old_addr, size_t old_size, size_t new_size);
|
|
167
|
+
|
|
168
|
+
#if (WASM_MEM_DUAL_BUS_MIRROR != 0)
|
|
169
|
+
void *
|
|
170
|
+
os_get_dbus_mirror(void *ibus);
|
|
171
|
+
#endif
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Flush cpu data cache, in some CPUs, after applying relocation to the
|
|
175
|
+
* AOT code, the code may haven't been written back to the cpu data cache,
|
|
176
|
+
* which may cause unexpected behaviour when executing the AOT code.
|
|
177
|
+
* Implement this function if required, or just leave it empty.
|
|
178
|
+
*/
|
|
179
|
+
void
|
|
180
|
+
os_dcache_flush(void);
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Flush instruction cache.
|
|
184
|
+
*/
|
|
185
|
+
void
|
|
186
|
+
os_icache_flush(void *start, size_t len);
|
|
187
|
+
|
|
188
|
+
#ifdef __cplusplus
|
|
189
|
+
}
|
|
190
|
+
#endif
|
|
191
|
+
|
|
192
|
+
#endif /* #ifndef _PLATFORM_API_VMCORE_H */
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
#ifndef _PLATFORM_COMMON_H
|
|
7
|
+
#define _PLATFORM_COMMON_H
|
|
8
|
+
|
|
9
|
+
#ifdef __cplusplus
|
|
10
|
+
extern "C" {
|
|
11
|
+
#endif
|
|
12
|
+
|
|
13
|
+
#include "platform_internal.h"
|
|
14
|
+
#include "../../../config.h"
|
|
15
|
+
|
|
16
|
+
#define BH_MAX_THREAD 32
|
|
17
|
+
|
|
18
|
+
#define BHT_ERROR (-1)
|
|
19
|
+
#define BHT_TIMED_OUT (1)
|
|
20
|
+
#define BHT_OK (0)
|
|
21
|
+
|
|
22
|
+
#define BHT_WAIT_FOREVER ((uint64)-1LL)
|
|
23
|
+
|
|
24
|
+
#define BH_KB (1024)
|
|
25
|
+
#define BH_MB ((BH_KB)*1024)
|
|
26
|
+
#define BH_GB ((BH_MB)*1024)
|
|
27
|
+
|
|
28
|
+
#ifndef BH_MALLOC
|
|
29
|
+
#define BH_MALLOC os_malloc
|
|
30
|
+
#endif
|
|
31
|
+
|
|
32
|
+
#ifndef BH_FREE
|
|
33
|
+
#define BH_FREE os_free
|
|
34
|
+
#endif
|
|
35
|
+
|
|
36
|
+
#ifndef BH_TIME_T_MAX
|
|
37
|
+
#define BH_TIME_T_MAX LONG_MAX
|
|
38
|
+
#endif
|
|
39
|
+
|
|
40
|
+
#if defined(_MSC_BUILD)
|
|
41
|
+
#if defined(COMPILING_WASM_RUNTIME_API)
|
|
42
|
+
__declspec(dllexport) void *BH_MALLOC(unsigned int size);
|
|
43
|
+
__declspec(dllexport) void BH_FREE(void *ptr);
|
|
44
|
+
#else
|
|
45
|
+
__declspec(dllimport) void *BH_MALLOC(unsigned int size);
|
|
46
|
+
__declspec(dllimport) void BH_FREE(void *ptr);
|
|
47
|
+
#endif
|
|
48
|
+
#else
|
|
49
|
+
void *
|
|
50
|
+
BH_MALLOC(unsigned int size);
|
|
51
|
+
void
|
|
52
|
+
BH_FREE(void *ptr);
|
|
53
|
+
#endif
|
|
54
|
+
|
|
55
|
+
#if defined(BH_VPRINTF)
|
|
56
|
+
#if defined(MSVC)
|
|
57
|
+
__declspec(dllimport) int BH_VPRINTF(const char *format, va_list ap);
|
|
58
|
+
#else
|
|
59
|
+
int
|
|
60
|
+
BH_VPRINTF(const char *format, va_list ap);
|
|
61
|
+
#endif
|
|
62
|
+
#endif
|
|
63
|
+
|
|
64
|
+
#ifndef NULL
|
|
65
|
+
#define NULL (void *)0
|
|
66
|
+
#endif
|
|
67
|
+
|
|
68
|
+
#if !defined(BH_HAS_DLFCN)
|
|
69
|
+
#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE)
|
|
70
|
+
#define BH_HAS_DLFCN 1
|
|
71
|
+
#else
|
|
72
|
+
#define BH_HAS_DLFCN 0
|
|
73
|
+
#endif
|
|
74
|
+
#endif
|
|
75
|
+
|
|
76
|
+
#ifndef __cplusplus
|
|
77
|
+
|
|
78
|
+
#ifndef true
|
|
79
|
+
#define true 1
|
|
80
|
+
#endif
|
|
81
|
+
|
|
82
|
+
#ifndef false
|
|
83
|
+
#define false 0
|
|
84
|
+
#endif
|
|
85
|
+
|
|
86
|
+
#ifndef inline
|
|
87
|
+
#define inline __inline
|
|
88
|
+
#endif
|
|
89
|
+
|
|
90
|
+
#endif
|
|
91
|
+
|
|
92
|
+
/* Return the offset of the given field in the given type */
|
|
93
|
+
#ifndef offsetof
|
|
94
|
+
/* GCC 4.0 and later has the builtin. */
|
|
95
|
+
#if defined(__GNUC__) && __GNUC__ >= 4
|
|
96
|
+
#define offsetof(Type, field) __builtin_offsetof(Type, field)
|
|
97
|
+
#else
|
|
98
|
+
#define offsetof(Type, field) ((size_t)(&((Type *)0)->field))
|
|
99
|
+
#endif
|
|
100
|
+
#endif
|
|
101
|
+
|
|
102
|
+
typedef uint8_t uint8;
|
|
103
|
+
typedef int8_t int8;
|
|
104
|
+
typedef uint16_t uint16;
|
|
105
|
+
typedef int16_t int16;
|
|
106
|
+
typedef uint32_t uint32;
|
|
107
|
+
typedef int32_t int32;
|
|
108
|
+
typedef float float32;
|
|
109
|
+
typedef double float64;
|
|
110
|
+
typedef uint64_t uint64;
|
|
111
|
+
typedef int64_t int64;
|
|
112
|
+
|
|
113
|
+
typedef void *(*thread_start_routine_t)(void *);
|
|
114
|
+
|
|
115
|
+
#ifndef bh_socket_t
|
|
116
|
+
/* If no socket defined on current platform,
|
|
117
|
+
give a fake definition to make the compiler happy */
|
|
118
|
+
#define bh_socket_t int
|
|
119
|
+
#endif
|
|
120
|
+
|
|
121
|
+
/* Format specifiers macros in case
|
|
122
|
+
they are not provided by compiler */
|
|
123
|
+
#ifndef __PRI64_PREFIX
|
|
124
|
+
#if UINTPTR_MAX == UINT64_MAX
|
|
125
|
+
#define __PRI64_PREFIX "l"
|
|
126
|
+
#define __PRIPTR_PREFIX "l"
|
|
127
|
+
#else
|
|
128
|
+
#define __PRI64_PREFIX "ll"
|
|
129
|
+
#define __PRIPTR_PREFIX
|
|
130
|
+
#endif
|
|
131
|
+
#endif /* #ifndef __PRI64_PREFIX */
|
|
132
|
+
|
|
133
|
+
/* Macros for printing format specifiers */
|
|
134
|
+
#ifndef PRId32
|
|
135
|
+
#define PRId32 "d"
|
|
136
|
+
#endif
|
|
137
|
+
#ifndef PRIi32
|
|
138
|
+
#define PRIi32 "i"
|
|
139
|
+
#endif
|
|
140
|
+
#ifndef PRIu32
|
|
141
|
+
#define PRIu32 "u"
|
|
142
|
+
#endif
|
|
143
|
+
#ifndef PRIx32
|
|
144
|
+
#define PRIx32 "x"
|
|
145
|
+
#endif
|
|
146
|
+
#ifndef PRIX32
|
|
147
|
+
#define PRIX32 "X"
|
|
148
|
+
#endif
|
|
149
|
+
|
|
150
|
+
#ifndef PRId64
|
|
151
|
+
#define PRId64 __PRI64_PREFIX "d"
|
|
152
|
+
#endif
|
|
153
|
+
#ifndef PRIu64
|
|
154
|
+
#define PRIu64 __PRI64_PREFIX "u"
|
|
155
|
+
#endif
|
|
156
|
+
#ifndef PRIx64
|
|
157
|
+
#define PRIx64 __PRI64_PREFIX "x"
|
|
158
|
+
#endif
|
|
159
|
+
#ifndef PRIX64
|
|
160
|
+
#define PRIX64 __PRI64_PREFIX "X"
|
|
161
|
+
#endif
|
|
162
|
+
#ifndef PRIxPTR
|
|
163
|
+
#define PRIxPTR __PRIPTR_PREFIX "x"
|
|
164
|
+
#endif
|
|
165
|
+
#ifndef PRIXPTR
|
|
166
|
+
#define PRIXPTR __PRIPTR_PREFIX "X"
|
|
167
|
+
#endif
|
|
168
|
+
|
|
169
|
+
/* Macros for scanning format specifiers */
|
|
170
|
+
#ifndef SCNd32
|
|
171
|
+
#define SCNd32 "d"
|
|
172
|
+
#endif
|
|
173
|
+
#ifndef SCNi32
|
|
174
|
+
#define SCNi32 "i"
|
|
175
|
+
#endif
|
|
176
|
+
#ifndef SCNu32
|
|
177
|
+
#define SCNu32 "u"
|
|
178
|
+
#endif
|
|
179
|
+
#ifndef SCNx32
|
|
180
|
+
#define SCNx32 "x"
|
|
181
|
+
#endif
|
|
182
|
+
|
|
183
|
+
#ifndef SCNd64
|
|
184
|
+
#define SCNd64 __PRI64_PREFIX "d"
|
|
185
|
+
#endif
|
|
186
|
+
#ifndef SCNu64
|
|
187
|
+
#define SCNu64 __PRI64_PREFIX "u"
|
|
188
|
+
#endif
|
|
189
|
+
#ifndef SCNx64
|
|
190
|
+
#define SCNx64 __PRI64_PREFIX "x"
|
|
191
|
+
#endif
|
|
192
|
+
#ifndef SCNxPTR
|
|
193
|
+
#define SCNxPTR __PRIPTR_PREFIX "x"
|
|
194
|
+
#endif
|
|
195
|
+
|
|
196
|
+
#ifndef NAN
|
|
197
|
+
#define NAN (0.0 / 0.0)
|
|
198
|
+
#endif
|
|
199
|
+
|
|
200
|
+
#ifdef __cplusplus
|
|
201
|
+
}
|
|
202
|
+
#endif
|
|
203
|
+
|
|
204
|
+
#endif /* #ifndef _PLATFORM_COMMON_H */
|