config.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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_X86_32) \
  10. && !defined(BUILD_TARGET_ARM) \
  11. && !defined(BUILD_TARGET_ARM_VFP) \
  12. && !defined(BUILD_TARGET_THUMB) \
  13. && !defined(BUILD_TARGET_THUMB_VFP) \
  14. && !defined(BUILD_TARGET_MIPS) \
  15. && !defined(BUILD_TARGET_XTENSA)
  16. #if defined(__x86_64__) || defined(__x86_64)
  17. #define BUILD_TARGET_X86_64
  18. #elif defined(__amd64__) || defined(__amd64)
  19. #define BUILD_TARGET_AMD_64
  20. #elif defined(__i386__) || defined(__i386) || defined(i386)
  21. #define BUILD_TARGET_X86_32
  22. #elif defined(__thumb__)
  23. #define BUILD_TARGET_THUMB
  24. #define BUILD_TARGET "THUMBV4T"
  25. #elif defined(__arm__)
  26. #define BUILD_TARGET_ARM
  27. #define BUILD_TARGET "ARMV4T"
  28. #elif defined(__mips__) || defined(__mips) || defined(mips)
  29. #define BUILD_TARGET_MIPS
  30. #elif defined(__XTENSA__)
  31. #define BUILD_TARGET_XTENSA
  32. #else
  33. #error "Build target isn't set"
  34. #endif
  35. #endif
  36. enum {
  37. /* Memory allocator ems */
  38. MEM_ALLOCATOR_EMS = 0,
  39. /* Memory allocator tlsf */
  40. MEM_ALLOCATOR_TLSF
  41. };
  42. /* Default memory allocator */
  43. #define DEFAULT_MEM_ALLOCATOR MEM_ALLOCATOR_EMS
  44. #ifndef WASM_ENABLE_INTERP
  45. #define WASM_ENABLE_INTERP 0
  46. #endif
  47. #ifndef WASM_ENABLE_AOT
  48. #define WASM_ENABLE_AOT 0
  49. #endif
  50. #ifndef WASM_ENABLE_JIT
  51. #define WASM_ENABLE_JIT 0
  52. #endif
  53. #if (WASM_ENABLE_AOT == 0) && (WASM_ENABLE_JIT != 0)
  54. /* JIT can only be enabled when AOT is enabled */
  55. #undef WASM_ENABLE_JIT
  56. #define WASM_ENABLE_JIT 0
  57. #endif
  58. #ifndef WASM_ENABLE_WAMR_COMPILER
  59. #define WASM_ENABLE_WAMR_COMPILER 0
  60. #endif
  61. #ifndef WASM_ENABLE_LIBC_BUILTIN
  62. #define WASM_ENABLE_LIBC_BUILTIN 0
  63. #endif
  64. #ifndef WASM_ENABLE_LIBC_WASI
  65. #define WASM_ENABLE_LIBC_WASI 0
  66. #endif
  67. #ifndef WASM_ENABLE_BASE_LIB
  68. #define WASM_ENABLE_BASE_LIB 0
  69. #endif
  70. #ifndef WASM_ENABLE_APP_FRAMEWORK
  71. #define WASM_ENABLE_APP_FRAMEWORK 0
  72. #endif
  73. /* WASM log system */
  74. #ifndef WASM_ENABLE_LOG
  75. #define WASM_ENABLE_LOG 1
  76. #endif
  77. #if defined(BUILD_TARGET_X86_32) || defined(BUILD_TARGET_X86_64)
  78. #define WASM_CPU_SUPPORTS_UNALIGNED_64BIT_ACCESS 1
  79. #else
  80. #define WASM_CPU_SUPPORTS_UNALIGNED_64BIT_ACCESS 0
  81. #endif
  82. /* WASM Interpreter labels-as-values feature */
  83. #define WASM_ENABLE_LABELS_AS_VALUES 1
  84. #if WASM_ENABLE_FAST_INTERP != 0
  85. #define WASM_ENABLE_ABS_LABEL_ADDR 1
  86. #define WASM_DEBUG_PREPROCESSOR 0
  87. #else
  88. #define WASM_ENABLE_ABS_LABEL_ADDR 0
  89. #endif
  90. /* Heap and stack profiling */
  91. #define BEIHAI_ENABLE_MEMORY_PROFILING 0
  92. /* Max app number of all modules */
  93. #define MAX_APP_INSTALLATIONS 3
  94. /* Default timer number in one app */
  95. #define DEFAULT_TIMERS_PER_APP 20
  96. /* Max timer number in one app */
  97. #define MAX_TIMERS_PER_APP 30
  98. /* Max connection number in one app */
  99. #define MAX_CONNECTION_PER_APP 20
  100. /* Max resource registration number in one app */
  101. #define RESOURCE_REGISTRATION_NUM_MAX 16
  102. /* Max length of resource/event url */
  103. #define RESOUCE_EVENT_URL_LEN_MAX 256
  104. /* Default length of queue */
  105. #define DEFAULT_QUEUE_LENGTH 50
  106. /* Default watchdog interval in ms */
  107. #define DEFAULT_WATCHDOG_INTERVAL (3 * 60 * 1000)
  108. /* Support memory.grow opcode and enlargeMemory function */
  109. #define WASM_ENABLE_MEMORY_GROW 1
  110. /* The max percentage of global heap that app memory space can grow */
  111. #define APP_MEMORY_MAX_GLOBAL_HEAP_PERCENT 1 / 3
  112. /* Default base offset of app heap space */
  113. #define DEFAULT_APP_HEAP_BASE_OFFSET (1 * BH_GB)
  114. /* Default min/max heap size of each app */
  115. #define APP_HEAP_SIZE_DEFAULT (8 * 1024)
  116. #define APP_HEAP_SIZE_MIN (2 * 1024)
  117. #define APP_HEAP_SIZE_MAX (1024 * 1024)
  118. /* Default wasm stack size of each app */
  119. #if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_AMD_64)
  120. #define DEFAULT_WASM_STACK_SIZE (16 * 1024)
  121. #else
  122. #define DEFAULT_WASM_STACK_SIZE (12 * 1024)
  123. #endif
  124. /* Default/min/max stack size of each app thread */
  125. #if !defined(BH_PLATFORM_ZEPHYR) && !defined(BH_PLATFORM_ALIOS_THINGS)
  126. #define APP_THREAD_STACK_SIZE_DEFAULT (20 * 1024)
  127. #define APP_THREAD_STACK_SIZE_MIN (16 * 1024)
  128. #define APP_THREAD_STACK_SIZE_MAX (256 * 1024)
  129. #else
  130. #define APP_THREAD_STACK_SIZE_DEFAULT (6 * 1024)
  131. #define APP_THREAD_STACK_SIZE_MIN (4 * 1024)
  132. #define APP_THREAD_STACK_SIZE_MAX (256 * 1024)
  133. #endif
  134. /* Default wasm block address cache size and conflict list size */
  135. #define BLOCK_ADDR_CACHE_SIZE 64
  136. #define BLOCK_ADDR_CONFLICT_SIZE 2
  137. #endif /* end of _CONFIG_H_ */