Config.h.cmake 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. // Copyright (C) 2009-2021, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. // ====================== WARNING: THIS FILE IS AUTO-GENERATED BY THE BUILD SYSTEM. DON'T ALTER IT =====================
  6. #pragma once
  7. /// @addtogroup config
  8. /// @{
  9. #define _ANKI_STR_HELPER(x) #x
  10. #define _ANKI_STR(x) _ANKI_STR_HELPER(x)
  11. #define ANKI_VERSION_MINOR ${ANKI_VERSION_MINOR}
  12. #define ANKI_VERSION_MAJOR ${ANKI_VERSION_MAJOR}
  13. #define ANKI_REVISION ${ANKI_REVISION}
  14. #define ANKI_EXTRA_CHECKS ${_ANKI_EXTRA_CHECKS}
  15. #define ANKI_DEBUG_SYMBOLS ${ANKI_DEBUG_SYMBOLS}
  16. #define ANKI_OPTIMIZE ${ANKI_OPTIMIZE}
  17. #define ANKI_TESTS ${ANKI_TESTS}
  18. #define ANKI_ENABLE_TRACE ${_ANKI_ENABLE_TRACE}
  19. #define ANKI_SOURCE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
  20. // Compiler
  21. #if defined(__clang__)
  22. # define ANKI_COMPILER_CLANG 1
  23. # define ANKI_COMPILER_GCC 0
  24. # define ANKI_COMPILER_MSVC 0
  25. # define ANKI_COMPILER_GCC_COMPATIBLE 1
  26. # define ANKI_COMPILER_STR "clang " __VERSION__
  27. #elif defined(__GNUC__) || defined(__GNUG__)
  28. # define ANKI_COMPILER_CLANG 0
  29. # define ANKI_COMPILER_GCC 1
  30. # define ANKI_COMPILER_MSVC 0
  31. # define ANKI_COMPILER_GCC_COMPATIBLE 1
  32. # define ANKI_COMPILER_STR "gcc " __VERSION__
  33. #elif defined(_MSC_VER)
  34. # define ANKI_COMPILER_CLANG 0
  35. # define ANKI_COMPILER_GCC 0
  36. # define ANKI_COMPILER_MSVC 1
  37. # define ANKI_COMPILER_GCC_COMPATIBLE 0
  38. # define ANKI_COMPILER_STR "MSVC " _ANKI_STR(_MSC_FULL_VER)
  39. #else
  40. # error Unknown compiler
  41. #endif
  42. // Operating system
  43. #if defined(__WIN32__) || defined(_WIN32)
  44. # define ANKI_OS_LINUX 0
  45. # define ANKI_OS_ANDROID 0
  46. # define ANKI_OS_MACOS 0
  47. # define ANKI_OS_IOS 0
  48. # define ANKI_OS_WINDOWS 1
  49. # define ANKI_OS_STR "Windows"
  50. #elif defined(__APPLE_CC__)
  51. # if (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 40000) || (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 40000)
  52. # define ANKI_OS_LINUX 0
  53. # define ANKI_OS_ANDROID 0
  54. # define ANKI_OS_MACOS 0
  55. # define ANKI_OS_IOS 1
  56. # define ANKI_OS_WINDOWS 0
  57. # define ANKI_OS_STR "iOS"
  58. # else
  59. # define ANKI_OS_LINUX 0
  60. # define ANKI_OS_ANDROID 0
  61. # define ANKI_OS_MACOS 1
  62. # define ANKI_OS_IOS 0
  63. # define ANKI_OS_WINDOWS 0
  64. # define ANKI_OS_STR "MacOS"
  65. # endif
  66. #elif defined(__ANDROID__)
  67. # define ANKI_OS_LINUX 0
  68. # define ANKI_OS_ANDROID 1
  69. # define ANKI_OS_MACOS 0
  70. # define ANKI_OS_IOS 0
  71. # define ANKI_OS_WINDOWS 0
  72. # define ANKI_OS_STR "Android"
  73. #elif defined(__linux__)
  74. # define ANKI_OS_LINUX 1
  75. # define ANKI_OS_ANDROID 0
  76. # define ANKI_OS_MACOS 0
  77. # define ANKI_OS_IOS 0
  78. # define ANKI_OS_WINDOWS 0
  79. # define ANKI_OS_STR "Linux"
  80. #else
  81. # error Unknown OS
  82. #endif
  83. // POSIX system or not
  84. #if ANKI_OS_LINUX || ANKI_OS_ANDROID || ANKI_OS_MACOS || ANKI_OS_IOS
  85. # define ANKI_POSIX 1
  86. #else
  87. # define ANKI_POSIX 0
  88. #endif
  89. // CPU architecture
  90. #if ANKI_COMPILER_GCC_COMPATIBLE
  91. # if defined(__arm__)
  92. # define ANKI_CPU_ARCH_X86 0
  93. # define ANKI_CPU_ARCH_ARM 1
  94. # elif defined(__i386__) || defined(__amd64__)
  95. # define ANKI_CPU_ARCH_X86 1
  96. # define ANKI_CPU_ARCH_ARM 0
  97. # endif
  98. #elif ANKI_COMPILER_MSVC
  99. # if defined(_M_ARM)
  100. # define ANKI_CPU_ARCH_X86 0
  101. # define ANKI_CPU_ARCH_ARM 1
  102. # elif defined(_M_X64) || defined(_M_IX86)
  103. # define ANKI_CPU_ARCH_X86 1
  104. # define ANKI_CPU_ARCH_ARM 0
  105. # endif
  106. #endif
  107. #if defined(ANKI_CPU_ARCH_X86) && ANKI_CPU_ARCH_X86
  108. # define ANKI_GPU_ARCH_STR "x86"
  109. #elif defined(ANKI_CPU_ARCH_ARM) && ANKI_CPU_ARCH_ARM
  110. # define ANKI_GPU_ARCH_STR "arm"
  111. #else
  112. # error Unknown CPU arch
  113. #endif
  114. // SIMD
  115. #define ANKI_ENABLE_SIMD ${_ANKI_ENABLE_SIMD}
  116. #if !ANKI_ENABLE_SIMD
  117. # define ANKI_SIMD_NONE 1
  118. # define ANKI_SIMD_SSE 0
  119. # define ANKI_SIMD_NEON 0
  120. #elif ANKI_CPU_ARCH_X86
  121. # define ANKI_SIMD_NONE 0
  122. # define ANKI_SIMD_SSE 1
  123. # define ANKI_SIMD_NEON 0
  124. #else
  125. # define ANKI_SIMD_NONE 0
  126. # define ANKI_SIMD_SSE 0
  127. # define ANKI_SIMD_NEON 1
  128. #endif
  129. // Graphics backend
  130. #define ANKI_GR_BACKEND_GL 0
  131. #define ANKI_GR_BACKEND_VULKAN 1
  132. // Some compiler attributes
  133. #if ANKI_COMPILER_GCC_COMPATIBLE
  134. # define ANKI_LIKELY(x) __builtin_expect(!!(x), 1)
  135. # define ANKI_UNLIKELY(x) __builtin_expect(!!(x), 0)
  136. # define ANKI_RESTRICT __restrict
  137. # define ANKI_USE_RESULT __attribute__((warn_unused_result))
  138. # define ANKI_FORCE_INLINE __attribute__((always_inline))
  139. # define ANKI_DONT_INLINE __attribute__((noinline))
  140. # define ANKI_UNUSED __attribute__((__unused__))
  141. # define ANKI_COLD __attribute__((cold, optimize("Os")))
  142. # define ANKI_HOT __attribute__ ((hot))
  143. # define ANKI_UNREACHABLE() __builtin_unreachable()
  144. # define ANKI_PREFETCH_MEMORY(addr) __builtin_prefetch(addr)
  145. # define ANKI_CHECK_FORMAT(fmtArgIdx, firstArgIdx) __attribute__((format(printf, fmtArgIdx + 1, firstArgIdx + 1))) // On methods need to include "this"
  146. #else
  147. # define ANKI_LIKELY(x) ((x) == 1)
  148. # define ANKI_UNLIKELY(x) ((x) == 1)
  149. # define ANKI_RESTRICT
  150. # define ANKI_USE_RESULT
  151. # define ANKI_FORCE_INLINE
  152. # define ANKI_DONT_INLINE
  153. # define ANKI_UNUSED
  154. # define ANKI_COLD
  155. # define ANKI_HOT
  156. # define ANKI_UNREACHABLE() __assume(false)
  157. # define ANKI_PREFETCH_MEMORY(addr) (void)(addr)
  158. # define ANKI_CHECK_FORMAT(fmtArgIdx, firstArgIdx)
  159. #endif
  160. // Pack structs
  161. #if ANKI_COMPILER_MSVC
  162. # define ANKI_BEGIN_PACKED_STRUCT __pragma(pack (push, 1))
  163. # define ANKI_END_PACKED_STRUCT __pragma(pack (pop))
  164. #else
  165. # define ANKI_BEGIN_PACKED_STRUCT _Pragma("pack (push, 1)")
  166. # define ANKI_END_PACKED_STRUCT _Pragma("pack (pop)")
  167. #endif
  168. // Builtins
  169. #if ANKI_COMPILER_MSVC
  170. # include <intrin.h>
  171. # define __builtin_popcount __popcnt
  172. # define __builtin_popcountl __popcnt64
  173. # define __builtin_clzll(x) ((int)__lzcnt64(x))
  174. #endif
  175. // Constants
  176. #define ANKI_SAFE_ALIGNMENT 16
  177. #define ANKI_CACHE_LINE_SIZE 64
  178. // Misc
  179. #define ANKI_FILE __FILE__
  180. #define ANKI_FUNC __func__
  181. // A macro used to mark some functions or variables as AnKi internal.
  182. #ifdef ANKI_SOURCE_FILE
  183. # define ANKI_INTERNAL
  184. #else
  185. # define ANKI_INTERNAL [[deprecated("This is an AnKi internal interface. Don't use it")]]
  186. #endif
  187. /// @}