diff --git a/src/include/c.h b/src/include/c.h index fb0ea1bc680..c0c46ab2c8c 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -1268,11 +1268,24 @@ typedef struct PGAlignedXLogBlock PGAlignedXLogBlock; ((underlying_type) (expr)) #endif +/* + * compiler-independent macros for CPU architecture + */ +#if defined(__x86_64__) || defined(_M_X64) +#define PG_ARCH_X64 +#elif defined(__i386__) || defined(_M_IX86) +#define PG_ARCH_X32 +#elif defined(__aarch64__) || defined(_M_ARM64) +#define PG_ARCH_ARM64 +#elif defined(__arm__) || defined(__arm) || defined(_M_ARM) +#define PG_ARCH_ARM32 +#endif + /* * SSE2 instructions are part of the spec for the 64-bit x86 ISA. We assume * that compilers targeting this architecture understand SSE2 intrinsics. */ -#if (defined(__x86_64__) || defined(_M_AMD64)) +#if defined(PG_ARCH_X64) #define USE_SSE2 /* diff --git a/src/port/pg_cpu_x86.c b/src/port/pg_cpu_x86.c index 0c292c0223a..81470f0b0b5 100644 --- a/src/port/pg_cpu_x86.c +++ b/src/port/pg_cpu_x86.c @@ -20,7 +20,7 @@ #include "c.h" -#if defined(USE_SSE2) || defined(__i386__) +#if defined(PG_ARCH_X64) || defined(PG_ARCH_X32) #if defined(HAVE__GET_CPUID) || defined(HAVE__GET_CPUID_COUNT) #include @@ -114,4 +114,4 @@ pg_crc32c (*pg_comp_crc32c) (pg_crc32c crc, const void *data, size_t len) = pg_c #endif -#endif /* defined(USE_SSE2) || defined(__i386__) */ +#endif /* defined(PG_ARCH_X64) || defined(PG_ARCH_X32) */