Config.h.cmake 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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. // Mobile or not
  84. #define ANKI_PLATFORM_MOBILE (ANKI_OS_ANDROID || ANKI_OS_IOS)
  85. // POSIX system or not
  86. #if ANKI_OS_LINUX || ANKI_OS_ANDROID || ANKI_OS_MACOS || ANKI_OS_IOS
  87. # define ANKI_POSIX 1
  88. #else
  89. # define ANKI_POSIX 0
  90. #endif
  91. // CPU architecture
  92. #if ANKI_COMPILER_GCC_COMPATIBLE
  93. # if defined(__arm__) || defined(__aarch64__)
  94. # define ANKI_CPU_ARCH_X86 0
  95. # define ANKI_CPU_ARCH_ARM 1
  96. # elif defined(__i386__) || defined(__amd64__)
  97. # define ANKI_CPU_ARCH_X86 1
  98. # define ANKI_CPU_ARCH_ARM 0
  99. # endif
  100. #elif ANKI_COMPILER_MSVC
  101. # if defined(_M_ARM)
  102. # define ANKI_CPU_ARCH_X86 0
  103. # define ANKI_CPU_ARCH_ARM 1
  104. # elif defined(_M_X64) || defined(_M_IX86)
  105. # define ANKI_CPU_ARCH_X86 1
  106. # define ANKI_CPU_ARCH_ARM 0
  107. # endif
  108. #endif
  109. #if defined(ANKI_CPU_ARCH_X86) && ANKI_CPU_ARCH_X86
  110. # define ANKI_GPU_ARCH_STR "x86"
  111. #elif defined(ANKI_CPU_ARCH_ARM) && ANKI_CPU_ARCH_ARM
  112. # define ANKI_GPU_ARCH_STR "arm"
  113. #else
  114. # error Unknown CPU arch
  115. #endif
  116. // SIMD
  117. #define ANKI_ENABLE_SIMD ${_ANKI_ENABLE_SIMD}
  118. #if !ANKI_ENABLE_SIMD
  119. # define ANKI_SIMD_NONE 1
  120. # define ANKI_SIMD_SSE 0
  121. # define ANKI_SIMD_NEON 0
  122. #elif ANKI_CPU_ARCH_X86
  123. # define ANKI_SIMD_NONE 0
  124. # define ANKI_SIMD_SSE 1
  125. # define ANKI_SIMD_NEON 0
  126. #else
  127. # define ANKI_SIMD_NONE 0
  128. # define ANKI_SIMD_SSE 0
  129. # define ANKI_SIMD_NEON 1
  130. #endif
  131. // Graphics backend
  132. #define ANKI_GR_BACKEND_GL 0
  133. #define ANKI_GR_BACKEND_VULKAN 1
  134. // Some compiler attributes
  135. #if ANKI_COMPILER_GCC_COMPATIBLE
  136. # define ANKI_LIKELY(x) __builtin_expect(!!(x), 1)
  137. # define ANKI_UNLIKELY(x) __builtin_expect(!!(x), 0)
  138. # define ANKI_RESTRICT __restrict
  139. # define ANKI_USE_RESULT __attribute__((warn_unused_result))
  140. # define ANKI_FORCE_INLINE __attribute__((always_inline))
  141. # define ANKI_DONT_INLINE __attribute__((noinline))
  142. # define ANKI_UNUSED __attribute__((__unused__))
  143. # define ANKI_COLD __attribute__((cold, optimize("Os")))
  144. # define ANKI_HOT __attribute__ ((hot))
  145. # define ANKI_UNREACHABLE() __builtin_unreachable()
  146. # define ANKI_PREFETCH_MEMORY(addr) __builtin_prefetch(addr)
  147. # define ANKI_CHECK_FORMAT(fmtArgIdx, firstArgIdx) __attribute__((format(printf, fmtArgIdx + 1, firstArgIdx + 1))) // On methods need to include "this"
  148. #else
  149. # define ANKI_LIKELY(x) ((x) == 1)
  150. # define ANKI_UNLIKELY(x) ((x) == 1)
  151. # define ANKI_RESTRICT
  152. # define ANKI_USE_RESULT
  153. # define ANKI_FORCE_INLINE
  154. # define ANKI_DONT_INLINE
  155. # define ANKI_UNUSED
  156. # define ANKI_COLD
  157. # define ANKI_HOT
  158. # define ANKI_UNREACHABLE() __assume(false)
  159. # define ANKI_PREFETCH_MEMORY(addr) (void)(addr)
  160. # define ANKI_CHECK_FORMAT(fmtArgIdx, firstArgIdx)
  161. #endif
  162. // Pack structs
  163. #if ANKI_COMPILER_MSVC
  164. # define ANKI_BEGIN_PACKED_STRUCT __pragma(pack (push, 1))
  165. # define ANKI_END_PACKED_STRUCT __pragma(pack (pop))
  166. #else
  167. # define ANKI_BEGIN_PACKED_STRUCT _Pragma("pack (push, 1)")
  168. # define ANKI_END_PACKED_STRUCT _Pragma("pack (pop)")
  169. #endif
  170. // Builtins
  171. #if ANKI_COMPILER_MSVC
  172. # include <intrin.h>
  173. # define __builtin_popcount __popcnt
  174. # define __builtin_popcountl(x) int(__popcnt64(x))
  175. # define __builtin_clzll(x) int(__lzcnt64(x))
  176. #endif
  177. // Constants
  178. #define ANKI_SAFE_ALIGNMENT 16
  179. #define ANKI_CACHE_LINE_SIZE 64
  180. // Misc
  181. #define ANKI_FILE __FILE__
  182. #define ANKI_FUNC __func__
  183. // A macro used to mark some functions or variables as AnKi internal.
  184. #ifdef ANKI_SOURCE_FILE
  185. # define ANKI_INTERNAL
  186. #else
  187. # define ANKI_INTERNAL [[deprecated("This is an AnKi internal interface. Don't use it")]]
  188. #endif
  189. // Define the main() function.
  190. #if ANKI_OS_ANDROID
  191. extern "C" {
  192. struct android_app;
  193. }
  194. namespace anki {
  195. extern android_app* g_androidApp;
  196. void* getAndroidCommandLineArguments(int& argc, char**& argv);
  197. void cleanupGetAndroidCommandLineArguments(void* ptr);
  198. }
  199. # define ANKI_MAIN_FUNCTION(myMain) \
  200. int myMain(int argc, char* argv[]); \
  201. extern "C" void android_main(android_app* app) \
  202. { \
  203. anki::g_androidApp = app; \
  204. char** argv; \
  205. int argc; \
  206. void* cleanupToken = anki::getAndroidCommandLineArguments(argc, argv); \
  207. myMain(argc, argv); \
  208. anki::cleanupGetAndroidCommandLineArguments(cleanupToken); \
  209. }
  210. #else
  211. # define ANKI_MAIN_FUNCTION(myMain) \
  212. int myMain(int argc, char* argv[]); \
  213. int main(int argc, char* argv[]) \
  214. { \
  215. return myMain(argc, argv); \
  216. }
  217. #endif
  218. /// @}