config.h 7.3 KB

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