config.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /*
  2. * Copyright (C) 2024 Xiaomi Corporation. All rights reserved.
  3. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. */
  5. #ifndef CONFIG_H_
  6. #define CONFIG_H_
  7. #include <stdint.h>
  8. #include <stdlib.h>
  9. #define ANALYZER_VERSION_STRING "1.0.0"
  10. #define WASM_MAGIC_NUMBER 0x6d736100
  11. #define WASM_CURRENT_VERSION 1
  12. #define AOT_MAGIC_NUMBER 0x746f6100
  13. #define AOT_CURRENT_VERSION 3
  14. /* Legal values for bin_type */
  15. #define BIN_TYPE_ELF32L 0 /* 32-bit little endian */
  16. #define BIN_TYPE_ELF32B 1 /* 32-bit big endian */
  17. #define BIN_TYPE_ELF64L 2 /* 64-bit little endian */
  18. #define BIN_TYPE_ELF64B 3 /* 64-bit big endian */
  19. #define BIN_TYPE_COFF32 4 /* 32-bit little endian */
  20. #define BIN_TYPE_COFF64 6 /* 64-bit little endian */
  21. /* Legal values for e_type (object file type). */
  22. #define E_TYPE_NONE 0 /* No file type */
  23. #define E_TYPE_REL 1 /* Relocatable file */
  24. #define E_TYPE_EXEC 2 /* Executable file */
  25. #define E_TYPE_DYN 3 /* Shared object file */
  26. #define E_TYPE_XIP 4 /* eXecute In Place file */
  27. /* Legal values for e_machine (architecture). */
  28. #define E_MACHINE_386 3 /* Intel 80386 */
  29. #define E_MACHINE_MIPS 8 /* MIPS R3000 big-endian */
  30. #define E_MACHINE_MIPS_RS3_LE 10 /* MIPS R3000 little-endian */
  31. #define E_MACHINE_ARM 40 /* ARM/Thumb */
  32. #define E_MACHINE_AARCH64 183 /* AArch64 */
  33. #define E_MACHINE_ARC 45 /* Argonaut RISC Core */
  34. #define E_MACHINE_IA_64 50 /* Intel Merced */
  35. #define E_MACHINE_MIPS_X 51 /* Stanford MIPS-X */
  36. #define E_MACHINE_X86_64 62 /* AMD x86-64 architecture */
  37. #define E_MACHINE_ARC_COMPACT 93 /* ARC International ARCompact */
  38. #define E_MACHINE_ARC_COMPACT2 195 /* Synopsys ARCompact V2 */
  39. #define E_MACHINE_XTENSA 94 /* Tensilica Xtensa Architecture */
  40. #define E_MACHINE_RISCV 243 /* RISC-V 32/64 */
  41. #define E_MACHINE_WIN_I386 0x14c /* Windows i386 architecture */
  42. #define E_MACHINE_WIN_X86_64 0x8664 /* Windows x86-64 architecture */
  43. /* Whether <alloca.h> is available */
  44. #define HAVE_ALLOCA_H 1
  45. /* Whether snprintf is defined by stdio.h */
  46. #define HAVE_SNPRINTF 1
  47. /* Whether ssize_t is defined by stddef.h */
  48. #define HAVE_SSIZE_T 1
  49. /* Whether strcasecmp is defined by strings.h */
  50. #define HAVE_STRCASECMP 1
  51. #define COMPILER_IS_CLANG 0
  52. #define COMPILER_IS_GNU 1
  53. #define COMPILER_IS_MSVC 0
  54. #define WITH_EXCEPTIONS 0
  55. #define SIZEOF_SIZE_T 8
  56. #if HAVE_ALLOCA_H
  57. #include <alloca.h>
  58. #elif COMPILER_IS_MSVC
  59. #include <malloc.h>
  60. #define alloca _alloca
  61. #elif defined(__MINGW32__)
  62. #include <malloc.h>
  63. #endif
  64. #if COMPILER_IS_CLANG || COMPILER_IS_GNU
  65. #if __MINGW32__
  66. #define ANALYZER_PRINTF_FORMAT(format_arg, first_arg) \
  67. __attribute__((format(gnu_printf, (format_arg), (first_arg))))
  68. #else
  69. #define ANALYZER_PRINTF_FORMAT(format_arg, first_arg) \
  70. __attribute__((format(printf, (format_arg), (first_arg))))
  71. #endif
  72. #ifdef __cplusplus
  73. #define ANALYZER_STATIC_ASSERT(x) static_assert((x), #x)
  74. #else
  75. #define ANALYZER_STATIC_ASSERT(x) _Static_assert((x), #x)
  76. #endif
  77. #elif COMPILER_IS_MSVC
  78. #include <intrin.h>
  79. #include <string.h>
  80. #define ANALYZER_STATIC_ASSERT(x) _STATIC_ASSERT(x)
  81. #define ANALYZER_PRINTF_FORMAT(format_arg, first_arg)
  82. #else
  83. #error unknown compiler
  84. #endif
  85. #define ANALYZER_UNREACHABLE abort()
  86. #ifdef __cplusplus
  87. #if COMPILER_IS_MSVC
  88. #elif COMPILER_IS_CLANG || COMPILER_IS_GNU
  89. /* print format specifier for size_t */
  90. #define PRIzd "zd"
  91. #define PRIzx "zx"
  92. #else
  93. #error unknown compiler
  94. #endif
  95. #if HAVE_SNPRINTF
  96. #define analyzer_snprintf snprintf
  97. #elif COMPILER_IS_MSVC
  98. #include <cstdarg>
  99. int
  100. analyzer_snprintf(char *str, size_t size, const char *format, ...);
  101. #else
  102. #error no snprintf
  103. #endif
  104. #if COMPILER_IS_MSVC
  105. int
  106. analyzer_vsnprintf(char *str, size_t size, const char *format, va_list ap);
  107. #else
  108. #define analyzer_vsnprintf vsnprintf
  109. #endif
  110. #if !HAVE_SSIZE_T
  111. #if COMPILER_IS_MSVC
  112. #if defined(_WIN64)
  113. typedef signed __int64 ssize_t;
  114. #else
  115. typedef signed int ssize_t;
  116. #endif
  117. #else
  118. typedef long ssize_t;
  119. #endif
  120. #endif
  121. #if !HAVE_STRCASECMP
  122. #if COMPILER_IS_MSVC
  123. #define strcasecmp _stricmp
  124. #else
  125. #error no strcasecmp
  126. #endif
  127. #endif
  128. #endif
  129. #endif