No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ArchitectureDetection.h 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #pragma once
  2. // Detect 64/32bit if not user defined.
  3. #if !defined(PLATFORM_ARCH_64) && !defined(PLATFORM_ARCH_32)
  4. #if defined(_AMD64_) || defined(__LP64__) || defined(_WIN64) || defined(_M_ARM64)
  5. #define PLATFORM_ARCH_64 1
  6. #define PLATFORM_ARCH_32 0
  7. #else
  8. #define PLATFORM_ARCH_64 0
  9. #define PLATFORM_ARCH_32 1
  10. #endif
  11. #elif !defined(PLATFORM_ARCH_64)
  12. #define PLATFORM_ARCH_64 (PLATFORM_ARCH_32 ? 0 : 1)
  13. #elif !defined(PLATFORM_ARCH_32)
  14. #define PLATFORM_ARCH_32 (PLATFORM_ARCH_64 ? 0 : 1)
  15. #endif
  16. // Detect endianess if not user defined.
  17. #if !defined(PLATFORM_ARCH_BIG_ENDIAN) && !defined(PLATFORM_ARCH_LITTLE_ENDIAN)
  18. #if defined(__BIG_ENDIAN__)
  19. #define PLATFORM_ARCH_BIG_ENDIAN 1
  20. #define PLATFORM_ARCH_LITTLE_ENDIAN 0
  21. #else
  22. #define PLATFORM_ARCH_BIG_ENDIAN 0
  23. #define PLATFORM_ARCH_LITTLE_ENDIAN 1
  24. #endif
  25. #elif !defined(PLATFORM_ARCH_BIG_ENDIAN)
  26. #define PLATFORM_ARCH_BIG_ENDIAN (PLATFORM_ARCH_LITTLE_ENDIAN ? 0 : 1)
  27. #elif !defined(PLATFORM_ARCH_LITTLE_ENDIAN)
  28. #define PLATFORM_ARCH_LITTLE_ENDIAN (PLATFORM_ARCH_BIG_ENDIAN ? 0 : 1)
  29. #endif
  30. // Detect SIMD features.
  31. // SSE2
  32. // Naming is inherited from Unity and indicates full SSE2 support.
  33. #ifndef PLATFORM_SUPPORTS_SSE
  34. #if (defined(_M_IX86_FP) && _M_IX86_FP == 2) || defined(_M_AMD64) || defined(_M_X64) || defined(__SSE2__)
  35. #define PLATFORM_SUPPORTS_SSE 1
  36. #else
  37. #define PLATFORM_SUPPORTS_SSE 0
  38. #endif
  39. #endif
  40. // NEON
  41. // Indicates general availability. Note that there can be some differences in the exact instructions available.
  42. #ifndef PLATFORM_SUPPORTS_NEON
  43. #if defined(__ARM_NEON) || defined(__ARM_NEON__) || defined(__ARM_NEON_FP) || \
  44. (defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_ARM64)))
  45. #define PLATFORM_SUPPORTS_NEON 1
  46. #else
  47. #define PLATFORM_SUPPORTS_NEON 0
  48. #endif
  49. #endif