config.h 6.7 KB

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