diff --git a/vlib/v/gen/cgen.v b/vlib/v/gen/cgen.v index f3b59fe7ae..647b35b16d 100644 --- a/vlib/v/gen/cgen.v +++ b/vlib/v/gen/cgen.v @@ -4355,12 +4355,21 @@ fn (mut g Gen) comp_if_to_ifdef(name string, is_comptime_optional bool) string { 'no_bounds_checking' { return 'CUSTOM_DEFINE_no_bounds_checking' } + // architectures: + 'amd64' { + return '__V_amd64' + } + 'aarch64' { + return '__V_aarch64' + } + // bitness: 'x64' { return 'TARGET_IS_64BIT' } 'x32' { return 'TARGET_IS_32BIT' } + // endianness: 'little_endian' { return 'TARGET_ORDER_IS_LITTLE' } diff --git a/vlib/v/gen/cheaders.v b/vlib/v/gen/cheaders.v index 2fc0735947..ec31f8433b 100644 --- a/vlib/v/gen/cheaders.v +++ b/vlib/v/gen/cheaders.v @@ -28,6 +28,13 @@ const ( #define __NOINLINE __attribute__((noinline)) #define __IRQHANDLER __attribute__((interrupt)) +#if defined(__x86_64__) +#define __V_amd64 1 +#endif +#if defined(__aarch64__) || defined(__arm64__) +#define __V_aarch64 1 +#endif + // Using just __GNUC__ for detecting gcc, is not reliable because other compilers define it too: #ifdef __GNUC__ #define __V_GCC__