config.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. /*
  2. * Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. */
  5. #ifndef _CONFIG_H_
  6. #define _CONFIG_H_
  7. #if !defined(BUILD_TARGET_X86_64) \
  8. && !defined(BUILD_TARGET_AMD_64) \
  9. && !defined(BUILD_TARGET_AARCH64) \
  10. && !defined(BUILD_TARGET_X86_32) \
  11. && !defined(BUILD_TARGET_ARM) \
  12. && !defined(BUILD_TARGET_ARM_VFP) \
  13. && !defined(BUILD_TARGET_THUMB) \
  14. && !defined(BUILD_TARGET_THUMB_VFP) \
  15. && !defined(BUILD_TARGET_MIPS) \
  16. && !defined(BUILD_TARGET_XTENSA) \
  17. && !defined(BUILD_TARGET_RISCV64_LP64D) \
  18. && !defined(BUILD_TARGET_RISCV64_LP64) \
  19. && !defined(BUILD_TARGET_RISCV32_ILP32D) \
  20. && !defined(BUILD_TARGET_RISCV32_ILP32) \
  21. && !defined(BUILD_TARGET_ARC)
  22. #if defined(__x86_64__) || defined(__x86_64)
  23. #define BUILD_TARGET_X86_64
  24. #elif defined(__amd64__) || defined(__amd64)
  25. #define BUILD_TARGET_AMD_64
  26. #elif defined(__aarch64__)
  27. #define BUILD_TARGET_AARCH64
  28. #elif defined(__i386__) || defined(__i386) || defined(i386)
  29. #define BUILD_TARGET_X86_32
  30. #elif defined(__thumb__)
  31. #define BUILD_TARGET_THUMB
  32. #define BUILD_TARGET "THUMBV4T"
  33. #elif defined(__arm__)
  34. #define BUILD_TARGET_ARM
  35. #define BUILD_TARGET "ARMV4T"
  36. #elif defined(__mips__) || defined(__mips) || defined(mips)
  37. #define BUILD_TARGET_MIPS
  38. #elif defined(__XTENSA__)
  39. #define BUILD_TARGET_XTENSA
  40. #elif defined(__riscv) && (__riscv_xlen == 64)
  41. #define BUILD_TARGET_RISCV64_LP64D
  42. #elif defined(__riscv) && (__riscv_xlen == 32)
  43. #define BUILD_TARGET_RISCV32_ILP32D
  44. #elif defined(__arc__)
  45. #define BUILD_TARGET_ARC
  46. #else
  47. #error "Build target isn't set"
  48. #endif
  49. #endif
  50. #ifndef BH_DEBUG
  51. #define BH_DEBUG 0
  52. #endif
  53. #define MEM_ALLOCATOR_EMS 0
  54. #define MEM_ALLOCATOR_TLSF 1
  55. /* Default memory allocator */
  56. #define DEFAULT_MEM_ALLOCATOR MEM_ALLOCATOR_EMS
  57. #ifndef WASM_ENABLE_INTERP
  58. #define WASM_ENABLE_INTERP 0
  59. #endif
  60. #ifndef WASM_ENABLE_AOT
  61. #define WASM_ENABLE_AOT 0
  62. #endif
  63. #define AOT_MAGIC_NUMBER 0x746f6100
  64. #define AOT_CURRENT_VERSION 3
  65. #ifndef WASM_ENABLE_JIT
  66. #define WASM_ENABLE_JIT 0
  67. #endif
  68. #ifndef WASM_ENABLE_LAZY_JIT
  69. #define WASM_ENABLE_LAZY_JIT 0
  70. #endif
  71. #if (WASM_ENABLE_AOT == 0) && (WASM_ENABLE_JIT != 0)
  72. /* LazyJIT or MCJIT can only be enabled when AOT is enabled */
  73. #undef WASM_ENABLE_JIT
  74. #define WASM_ENABLE_JIT 0
  75. #undef WASM_ENABLE_LAZY_JIT
  76. #define WASM_ENABLE_LAZY_JIT 0
  77. #endif
  78. #ifndef WASM_ENABLE_WAMR_COMPILER
  79. #define WASM_ENABLE_WAMR_COMPILER 0
  80. #endif
  81. #ifndef WASM_ENABLE_LIBC_BUILTIN
  82. #define WASM_ENABLE_LIBC_BUILTIN 0
  83. #endif
  84. #ifndef WASM_ENABLE_LIBC_WASI
  85. #define WASM_ENABLE_LIBC_WASI 0
  86. #endif
  87. #ifndef WASM_ENABLE_UVWASI
  88. #define WASM_ENABLE_UVWASI 0
  89. #endif
  90. /* Default disable libc emcc */
  91. #ifndef WASM_ENABLE_LIBC_EMCC
  92. #define WASM_ENABLE_LIBC_EMCC 0
  93. #endif
  94. #ifndef WASM_ENABLE_LIB_PTHREAD
  95. #define WASM_ENABLE_LIB_PTHREAD 0
  96. #endif
  97. #ifndef WASM_ENABLE_BASE_LIB
  98. #define WASM_ENABLE_BASE_LIB 0
  99. #endif
  100. #ifndef WASM_ENABLE_APP_FRAMEWORK
  101. #define WASM_ENABLE_APP_FRAMEWORK 0
  102. #endif
  103. /* Bulk memory operation */
  104. #ifndef WASM_ENABLE_BULK_MEMORY
  105. #define WASM_ENABLE_BULK_MEMORY 0
  106. #endif
  107. /* Shared memory */
  108. #ifndef WASM_ENABLE_SHARED_MEMORY
  109. #define WASM_ENABLE_SHARED_MEMORY 0
  110. #endif
  111. /* Thread manager */
  112. #ifndef WASM_ENABLE_THREAD_MGR
  113. #define WASM_ENABLE_THREAD_MGR 0
  114. #endif
  115. /* WASM log system */
  116. #ifndef WASM_ENABLE_LOG
  117. #define WASM_ENABLE_LOG 1
  118. #endif
  119. #ifndef WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS
  120. #if defined(BUILD_TARGET_X86_32) || defined(BUILD_TARGET_X86_64) \
  121. || defined(BUILD_TARGET_AARCH64)
  122. #define WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS 1
  123. #else
  124. #define WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS 0
  125. #endif
  126. #endif
  127. /* WASM Interpreter labels-as-values feature */
  128. #ifndef WASM_ENABLE_LABELS_AS_VALUES
  129. #ifdef __GNUC__
  130. #define WASM_ENABLE_LABELS_AS_VALUES 1
  131. #else
  132. #define WASM_ENABLE_LABELS_AS_VALUES 0
  133. #endif
  134. #endif
  135. /* Enable fast interpreter or not */
  136. #ifndef WASM_ENABLE_FAST_INTERP
  137. #define WASM_ENABLE_FAST_INTERP 0
  138. #endif
  139. #if WASM_ENABLE_FAST_INTERP != 0
  140. #define WASM_DEBUG_PREPROCESSOR 0
  141. #endif
  142. /* Enable opcode counter or not */
  143. #ifndef WASM_ENABLE_OPCODE_COUNTER
  144. #define WASM_ENABLE_OPCODE_COUNTER 0
  145. #endif
  146. /* Support a module with dependency, other modules */
  147. #ifndef WASM_ENABLE_MULTI_MODULE
  148. #define WASM_ENABLE_MULTI_MODULE 0
  149. #endif
  150. /* Enable wasm mini loader or not */
  151. #ifndef WASM_ENABLE_MINI_LOADER
  152. #define WASM_ENABLE_MINI_LOADER 0
  153. #endif
  154. /* Disable boundary check with hardware trap or not,
  155. * enable it by default if it is supported */
  156. #ifndef WASM_DISABLE_HW_BOUND_CHECK
  157. #define WASM_DISABLE_HW_BOUND_CHECK 0
  158. #endif
  159. /* Disable SIMD unless it is manualy enabled somewhere */
  160. #ifndef WASM_ENABLE_SIMD
  161. #define WASM_ENABLE_SIMD 0
  162. #endif
  163. /* Memory profiling */
  164. #ifndef WASM_ENABLE_MEMORY_PROFILING
  165. #define WASM_ENABLE_MEMORY_PROFILING 0
  166. #endif
  167. /* Memory tracing */
  168. #ifndef WASM_ENABLE_MEMORY_TRACING
  169. #define WASM_ENABLE_MEMORY_TRACING 0
  170. #endif
  171. /* Performance profiling */
  172. #ifndef WASM_ENABLE_PERF_PROFILING
  173. #define WASM_ENABLE_PERF_PROFILING 0
  174. #endif
  175. /* Dump call stack */
  176. #ifndef WASM_ENABLE_DUMP_CALL_STACK
  177. #define WASM_ENABLE_DUMP_CALL_STACK 0
  178. #endif
  179. /* Heap verification */
  180. #ifndef BH_ENABLE_GC_VERIFY
  181. #define BH_ENABLE_GC_VERIFY 0
  182. #endif
  183. /* Max app number of all modules */
  184. #define MAX_APP_INSTALLATIONS 3
  185. /* Default timer number in one app */
  186. #define DEFAULT_TIMERS_PER_APP 20
  187. /* Max timer number in one app */
  188. #define MAX_TIMERS_PER_APP 30
  189. /* Max connection number in one app */
  190. #define MAX_CONNECTION_PER_APP 20
  191. /* Max resource registration number in one app */
  192. #define RESOURCE_REGISTRATION_NUM_MAX 16
  193. /* Max length of resource/event url */
  194. #define RESOUCE_EVENT_URL_LEN_MAX 256
  195. /* Default length of queue */
  196. #define DEFAULT_QUEUE_LENGTH 50
  197. /* Default watchdog interval in ms */
  198. #define DEFAULT_WATCHDOG_INTERVAL (3 * 60 * 1000)
  199. /* The max percentage of global heap that app memory space can grow */
  200. #define APP_MEMORY_MAX_GLOBAL_HEAP_PERCENT 1 / 3
  201. /* Default min/max heap size of each app */
  202. #ifndef APP_HEAP_SIZE_DEFAULT
  203. #define APP_HEAP_SIZE_DEFAULT (8 * 1024)
  204. #endif
  205. #define APP_HEAP_SIZE_MIN (256)
  206. #define APP_HEAP_SIZE_MAX (512 * 1024 * 1024)
  207. /* Default wasm stack size of each app */
  208. #if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_AMD_64)
  209. #define DEFAULT_WASM_STACK_SIZE (16 * 1024)
  210. #else
  211. #define DEFAULT_WASM_STACK_SIZE (12 * 1024)
  212. #endif
  213. /* Min auxilliary stack size of each wasm thread */
  214. #define WASM_THREAD_AUX_STACK_SIZE_MIN (256)
  215. /* Default/min/max stack size of each app thread */
  216. #if !defined(BH_PLATFORM_ZEPHYR) && !defined(BH_PLATFORM_ALIOS_THINGS) \
  217. && !defined(BH_PLATFORM_ESP_IDF) && !defined(BH_PLATFORM_OPENRTOS)
  218. #define APP_THREAD_STACK_SIZE_DEFAULT (32 * 1024)
  219. #define APP_THREAD_STACK_SIZE_MIN (24 * 1024)
  220. #else
  221. #define APP_THREAD_STACK_SIZE_DEFAULT (6 * 1024)
  222. #define APP_THREAD_STACK_SIZE_MIN (4 * 1024)
  223. #endif
  224. #if !defined(APP_THREAD_STACK_SIZE_MAX)
  225. #define APP_THREAD_STACK_SIZE_MAX (8 * 1024 * 1024)
  226. #endif
  227. /* Reserved bytes to the native thread stack boundary, throw native
  228. stack overflow exception if the guard boudary is reached */
  229. #define RESERVED_BYTES_TO_NATIVE_STACK_BOUNDARY (512)
  230. /* Guard page count for stack overflow check with hardware trap */
  231. #define STACK_OVERFLOW_CHECK_GUARD_PAGE_COUNT 3
  232. /* Default wasm block address cache size and conflict list size */
  233. #ifndef BLOCK_ADDR_CACHE_SIZE
  234. #define BLOCK_ADDR_CACHE_SIZE 64
  235. #endif
  236. #define BLOCK_ADDR_CONFLICT_SIZE 2
  237. #ifndef WASM_ENABLE_SPEC_TEST
  238. #define WASM_ENABLE_SPEC_TEST 0
  239. #endif
  240. /* Default max thread num per cluster. Can be overwrite by
  241. wasm_runtime_set_max_thread_num */
  242. #define CLUSTER_MAX_THREAD_NUM 4
  243. #ifndef WASM_ENABLE_TAIL_CALL
  244. #define WASM_ENABLE_TAIL_CALL 0
  245. #endif
  246. #ifndef WASM_ENABLE_CUSTOM_NAME_SECTION
  247. #define WASM_ENABLE_CUSTOM_NAME_SECTION 0
  248. #endif
  249. #ifndef WASM_ENABLE_REF_TYPES
  250. #define WASM_ENABLE_REF_TYPES 0
  251. #endif
  252. #endif /* end of _CONFIG_H_ */