config.h 7.9 KB

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