From b9b53b6ca17662fbc71d9f632c4db859bf12c408 Mon Sep 17 00:00:00 2001 From: Araq Date: Mon, 16 Mar 2020 16:24:50 +0100 Subject: [PATCH] fixes #13645 --- lib/nimbase.h | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/lib/nimbase.h b/lib/nimbase.h index d25c4dad070e8..8c1c3d8a5512c 100644 --- a/lib/nimbase.h +++ b/lib/nimbase.h @@ -549,22 +549,24 @@ typedef int Nim_and_C_compiler_disagree_on_target_architecture[sizeof(NI) == siz #define nimModInt(a, b, res) (((*res) = (a) % (b)), 0) #define nimModInt64(a, b, res) (((*res) = (a) % (b)), 0) -/* these exist because we cannot have .compilerProcs that are importc'ed - by a different name */ - -#define nimAddInt64(a, b, res) __builtin_saddll_overflow(a, b, (long long int*)res) -#define nimSubInt64(a, b, res) __builtin_ssubll_overflow(a, b, (long long int*)res) -#define nimMulInt64(a, b, res) __builtin_smulll_overflow(a, b, (long long int*)res) - -#if NIM_INTBITS == 32 - #define nimAddInt(a, b, res) __builtin_sadd_overflow(a, b, res) - #define nimSubInt(a, b, res) __builtin_ssub_overflow(a, b, res) - #define nimMulInt(a, b, res) __builtin_smul_overflow(a, b, res) -#else - /* map it to the 'long long' variant */ - #define nimAddInt(a, b, res) __builtin_saddll_overflow(a, b, (long long int*)res) - #define nimSubInt(a, b, res) __builtin_ssubll_overflow(a, b, (long long int*)res) - #define nimMulInt(a, b, res) __builtin_smulll_overflow(a, b, (long long int*)res) +#if !defined(_MSC_VER) + /* these exist because we cannot have .compilerProcs that are importc'ed + by a different name */ + + #define nimAddInt64(a, b, res) __builtin_saddll_overflow(a, b, (long long int*)res) + #define nimSubInt64(a, b, res) __builtin_ssubll_overflow(a, b, (long long int*)res) + #define nimMulInt64(a, b, res) __builtin_smulll_overflow(a, b, (long long int*)res) + + #if NIM_INTBITS == 32 + #define nimAddInt(a, b, res) __builtin_sadd_overflow(a, b, res) + #define nimSubInt(a, b, res) __builtin_ssub_overflow(a, b, res) + #define nimMulInt(a, b, res) __builtin_smul_overflow(a, b, res) + #else + /* map it to the 'long long' variant */ + #define nimAddInt(a, b, res) __builtin_saddll_overflow(a, b, (long long int*)res) + #define nimSubInt(a, b, res) __builtin_ssubll_overflow(a, b, (long long int*)res) + #define nimMulInt(a, b, res) __builtin_smulll_overflow(a, b, (long long int*)res) + #endif #endif #endif /* NIMBASE_H */