add isa check
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
#ifndef SN_TARGET
|
||||
#define SN_TARGET
|
||||
|
||||
typedef enum SN_OS_T {
|
||||
SN_OS_WINDOWS,
|
||||
SN_OS_LINUX,
|
||||
SN_OS_MACOS,
|
||||
SN_OS_IOS,
|
||||
SN_OS_ANDROID,
|
||||
SN_OS_UNKNOWN
|
||||
} SN_OS_T;
|
||||
|
||||
typedef enum SN_ARCH_T {
|
||||
SN_ARCH_X86_64,
|
||||
SN_ARCH_ARM64,
|
||||
SN_ARCH_RISCV64,
|
||||
SN_ARCH_PPC64le,
|
||||
} SN_ARCH_T;
|
||||
|
||||
/*
|
||||
* Target selection policy:
|
||||
* - Default (no SN_EXTERN_TARGET): fixed Windows + x86_64.
|
||||
* - External (SN_EXTERN_TARGET): build system must provide SN_OS and SN_ARCH.
|
||||
*/
|
||||
#ifndef SN_EXTERN_TARGET
|
||||
|
||||
#define SN_OS_TARGET SN_OS_WINDOWS
|
||||
#define SN_ARCH_TARGET SN_ARCH_X86_64
|
||||
|
||||
#else
|
||||
|
||||
#ifndef SN_OS_TARGET
|
||||
#error "SN_EXTERN_TARGET is defined but SN_OS is not provided."
|
||||
#endif
|
||||
|
||||
#ifndef SN_ARCH_TARGET
|
||||
#error "SN_EXTERN_TARGET is defined but SN_ARCH is not provided."
|
||||
#endif
|
||||
|
||||
/* Validate externally supplied values are within known enum constants. */
|
||||
#if (SN_OS_TARGET != SN_OS_WINDOWS) && (SN_OS_TARGET != SN_OS_LINUX) && (SN_OS_TARGET != SN_OS_MACOS) && \
|
||||
(SN_OS_TARGET != SN_OS_IOS) && (SN_OS_TARGET != SN_OS_ANDROID) && (SN_OS_TARGET != SN_OS_UNKNOWN)
|
||||
#error "SN_OS has an invalid value. Use SN_OS_<...> enum constants."
|
||||
#endif
|
||||
|
||||
#if (SN_ARCH_TARGET != SN_ARCH_X86_64) && (SN_ARCH_TARGET != SN_ARCH_ARM64) && (SN_ARCH_TARGET != SN_ARCH_RISCV64) && \
|
||||
(SN_ARCH_TARGET != SN_ARCH_PPC64le)
|
||||
#error "SN_ARCH has an invalid value. Use SN_ARCH_<...> enum constants."
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef SN_IS_OS
|
||||
#define SN_IS_OS(os) ((SN_OS_TARGET) == (os))
|
||||
#endif
|
||||
|
||||
#ifndef SN_IS_ARCH
|
||||
#define SN_IS_ARCH(arch) ((SN_ARCH_TARGET) == (arch))
|
||||
#endif
|
||||
|
||||
#endif // SN_TARGET
|
||||
Reference in New Issue
Block a user