Index: compiler-rt/lib/builtins/int_types.h =================================================================== --- compiler-rt/lib/builtins/int_types.h +++ compiler-rt/lib/builtins/int_types.h @@ -60,10 +60,19 @@ }s; } udwords; -#if (defined(__LP64__) || defined(__wasm__) || defined(__mips64)) || defined(__riscv) +#if defined(__LP64__) || defined(__wasm__) || defined(__mips64) || \ + defined(__riscv) || defined(_WIN64) #define CRT_HAS_128BIT #endif +/* MSVC doesn't have a working 128bit integer type. Users should really compile + * compiler-rt with clang, but if they happen to be doing a standalone build for + * asan or something else, disable the 128 bit parts so things sort of work. + */ +#if defined(_MSC_VER) && !defined(__clang__) +#undef CRT_HAS_128BIT +#endif + #ifdef CRT_HAS_128BIT typedef int ti_int __attribute__ ((mode (TI))); typedef unsigned tu_int __attribute__ ((mode (TI))); Index: compiler-rt/test/builtins/Unit/fixunsdfti_test.c =================================================================== --- compiler-rt/test/builtins/Unit/fixunsdfti_test.c +++ compiler-rt/test/builtins/Unit/fixunsdfti_test.c @@ -99,25 +99,25 @@ return 1; #endif - if (test__fixunsdfti(0x1.FFFFFFFFFFFFFp+63, 0xFFFFFFFFFFFFF800LL)) + if (test__fixunsdfti(0x1.FFFFFFFFFFFFFp+63, 0xFFFFFFFFFFFFF800ULL)) return 1; - if (test__fixunsdfti(0x1.0000000000000p+63, 0x8000000000000000LL)) + if (test__fixunsdfti(0x1.0000000000000p+63, 0x8000000000000000ULL)) return 1; - if (test__fixunsdfti(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFFFFFFFC00LL)) + if (test__fixunsdfti(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFFFFFFFC00ULL)) return 1; - if (test__fixunsdfti(0x1.FFFFFFFFFFFFEp+62, 0x7FFFFFFFFFFFF800LL)) + if (test__fixunsdfti(0x1.FFFFFFFFFFFFEp+62, 0x7FFFFFFFFFFFF800ULL)) return 1; - if (test__fixunsdfti(0x1.FFFFFFFFFFFFFp+127, make_ti(0xFFFFFFFFFFFFF800LL, 0))) + if (test__fixunsdfti(0x1.FFFFFFFFFFFFFp+127, make_ti(0xFFFFFFFFFFFFF800ULL, 0))) return 1; - if (test__fixunsdfti(0x1.0000000000000p+127, make_ti(0x8000000000000000LL, 0))) + if (test__fixunsdfti(0x1.0000000000000p+127, make_ti(0x8000000000000000ULL, 0))) return 1; - if (test__fixunsdfti(0x1.FFFFFFFFFFFFFp+126, make_ti(0x7FFFFFFFFFFFFC00LL, 0))) + if (test__fixunsdfti(0x1.FFFFFFFFFFFFFp+126, make_ti(0x7FFFFFFFFFFFFC00ULL, 0))) return 1; - if (test__fixunsdfti(0x1.FFFFFFFFFFFFEp+126, make_ti(0x7FFFFFFFFFFFF800LL, 0))) + if (test__fixunsdfti(0x1.FFFFFFFFFFFFEp+126, make_ti(0x7FFFFFFFFFFFF800ULL, 0))) return 1; - if (test__fixunsdfti(0x1.0000000000000p+128, make_ti(0xFFFFFFFFFFFFFFFFLL, - 0xFFFFFFFFFFFFFFFFLL))) + if (test__fixunsdfti(0x1.0000000000000p+128, make_ti(0xFFFFFFFFFFFFFFFFULL, + 0xFFFFFFFFFFFFFFFFULL))) return 1; #if !TARGET_LIBGCC Index: compiler-rt/test/builtins/Unit/fixunssfti_test.c =================================================================== --- compiler-rt/test/builtins/Unit/fixunssfti_test.c +++ compiler-rt/test/builtins/Unit/fixunssfti_test.c @@ -87,18 +87,18 @@ return 1; #endif - if (test__fixunssfti(0x1.FFFFFEp+63F, 0xFFFFFF0000000000LL)) + if (test__fixunssfti(0x1.FFFFFEp+63F, 0xFFFFFF0000000000ULL)) return 1; - if (test__fixunssfti(0x1.000000p+63F, 0x8000000000000000LL)) + if (test__fixunssfti(0x1.000000p+63F, 0x8000000000000000ULL)) return 1; if (test__fixunssfti(0x1.FFFFFEp+62F, 0x7FFFFF8000000000LL)) return 1; if (test__fixunssfti(0x1.FFFFFCp+62F, 0x7FFFFF0000000000LL)) return 1; - if (test__fixunssfti(0x1.FFFFFEp+127F, make_ti(0xFFFFFF0000000000LL, 0))) + if (test__fixunssfti(0x1.FFFFFEp+127F, make_ti(0xFFFFFF0000000000ULL, 0))) return 1; - if (test__fixunssfti(0x1.000000p+127F, make_ti(0x8000000000000000LL, 0))) + if (test__fixunssfti(0x1.000000p+127F, make_ti(0x8000000000000000ULL, 0))) return 1; if (test__fixunssfti(0x1.FFFFFEp+126F, make_ti(0x7FFFFF8000000000LL, 0))) return 1; Index: compiler-rt/test/builtins/Unit/fixunsxfti_test.c =================================================================== --- compiler-rt/test/builtins/Unit/fixunsxfti_test.c +++ compiler-rt/test/builtins/Unit/fixunsxfti_test.c @@ -17,7 +17,7 @@ #include "int_lib.h" #include -#ifdef CRT_HAS_128BIT +#if defined(CRT_HAS_128BIT) && HAS_80_BIT_LONG_DOUBLE // Returns: convert a to a unsigned long long, rounding toward zero. // Negative values all become zero. @@ -55,7 +55,7 @@ int main() { -#ifdef CRT_HAS_128BIT +#if defined(CRT_HAS_128BIT) && HAS_80_BIT_LONG_DOUBLE if (test__fixunsxfti(0.0, 0)) return 1; Index: compiler-rt/test/builtins/Unit/fixxfti_test.c =================================================================== --- compiler-rt/test/builtins/Unit/fixxfti_test.c +++ compiler-rt/test/builtins/Unit/fixxfti_test.c @@ -17,7 +17,7 @@ #include "int_lib.h" #include -#ifdef CRT_HAS_128BIT +#if defined(CRT_HAS_128BIT) && HAS_80_BIT_LONG_DOUBLE // Returns: convert a to a signed long long, rounding toward zero. @@ -45,15 +45,15 @@ return x != expected; } -char assumption_1[sizeof(ti_int) == 2*sizeof(di_int)] = {0}; -char assumption_2[sizeof(su_int)*CHAR_BIT == 32] = {0}; -char assumption_3[sizeof(long double)*CHAR_BIT == 128] = {0}; +COMPILE_TIME_ASSERT(sizeof(ti_int) == 2*sizeof(di_int)); +COMPILE_TIME_ASSERT(sizeof(su_int)*CHAR_BIT == 32); +COMPILE_TIME_ASSERT(sizeof(long double)*CHAR_BIT == 128); #endif int main() { -#ifdef CRT_HAS_128BIT +#if defined(CRT_HAS_128BIT) && HAS_80_BIT_LONG_DOUBLE if (test__fixxfti(0.0, 0)) return 1; Index: compiler-rt/test/builtins/Unit/floattixf_test.c =================================================================== --- compiler-rt/test/builtins/Unit/floattixf_test.c +++ compiler-rt/test/builtins/Unit/floattixf_test.c @@ -18,7 +18,7 @@ #include #include -#ifdef CRT_HAS_128BIT +#if defined(CRT_HAS_128BIT) && HAS_80_BIT_LONG_DOUBLE // Returns: convert a to a long double, rounding toward even. @@ -43,15 +43,15 @@ return x != expected; } -char assumption_1[sizeof(ti_int) == 2*sizeof(di_int)] = {0}; -char assumption_2[sizeof(ti_int)*CHAR_BIT == 128] = {0}; -char assumption_3[sizeof(long double)*CHAR_BIT == 128] = {0}; +COMPILE_TIME_ASSERT(sizeof(ti_int) == 2*sizeof(di_int)); +COMPILE_TIME_ASSERT(sizeof(ti_int)*CHAR_BIT == 128); +COMPILE_TIME_ASSERT(sizeof(long double)*CHAR_BIT == 128); #endif int main() { -#ifdef CRT_HAS_128BIT +#if defined(CRT_HAS_128BIT) && HAS_80_BIT_LONG_DOUBLE if (test__floattixf(0, 0.0)) return 1; Index: compiler-rt/test/builtins/Unit/floatuntisf_test.c =================================================================== --- compiler-rt/test/builtins/Unit/floatuntisf_test.c +++ compiler-rt/test/builtins/Unit/floatuntisf_test.c @@ -16,7 +16,7 @@ #include #include -#ifdef CRT_HAS_128BIT +#if defined(CRT_HAS_128BIT) && HAS_80_BIT_LONG_DOUBLE // Returns: convert a to a float, rounding toward even. @@ -40,15 +40,15 @@ return x != expected; } -char assumption_1[sizeof(tu_int) == 2*sizeof(du_int)] = {0}; -char assumption_2[sizeof(tu_int)*CHAR_BIT == 128] = {0}; -char assumption_3[sizeof(float)*CHAR_BIT == 32] = {0}; +COMPILE_TIME_ASSERT(sizeof(tu_int) == 2*sizeof(du_int)); +COMPILE_TIME_ASSERT(sizeof(tu_int)*CHAR_BIT == 128); +COMPILE_TIME_ASSERT(sizeof(float)*CHAR_BIT == 32); #endif int main() { -#ifdef CRT_HAS_128BIT +#if defined(CRT_HAS_128BIT) && HAS_80_BIT_LONG_DOUBLE if (test__floatuntisf(0, 0.0F)) return 1; Index: compiler-rt/test/builtins/Unit/floatuntixf_test.c =================================================================== --- compiler-rt/test/builtins/Unit/floatuntixf_test.c +++ compiler-rt/test/builtins/Unit/floatuntixf_test.c @@ -18,7 +18,7 @@ #include #include -#ifdef CRT_HAS_128BIT +#if defined(CRT_HAS_128BIT) && HAS_80_BIT_LONG_DOUBLE // Returns: convert a to a long double, rounding toward even. @@ -43,15 +43,15 @@ return x != expected; } -char assumption_1[sizeof(tu_int) == 2*sizeof(du_int)] = {0}; -char assumption_2[sizeof(tu_int)*CHAR_BIT == 128] = {0}; -char assumption_3[sizeof(long double)*CHAR_BIT == 128] = {0}; +COMPILE_TIME_ASSERT(sizeof(tu_int) == 2*sizeof(du_int)); +COMPILE_TIME_ASSERT(sizeof(tu_int)*CHAR_BIT == 128); +COMPILE_TIME_ASSERT(sizeof(long double)*CHAR_BIT == 128); #endif int main() { -#ifdef CRT_HAS_128BIT +#if defined(CRT_HAS_128BIT) && HAS_80_BIT_LONG_DOUBLE if (test__floatuntixf(0, 0.0)) return 1; Index: compiler-rt/test/builtins/Unit/modti3_test.c =================================================================== --- compiler-rt/test/builtins/Unit/modti3_test.c +++ compiler-rt/test/builtins/Unit/modti3_test.c @@ -63,17 +63,17 @@ if (test__modti3(-5, -3, -2)) return 1; - if (test__modti3(0x8000000000000000LL, 1, 0x0LL)) + if (test__modti3(0x8000000000000000ULL, 1, 0x0LL)) return 1; - if (test__modti3(0x8000000000000000LL, -1, 0x0LL)) + if (test__modti3(0x8000000000000000ULL, -1, 0x0LL)) return 1; - if (test__modti3(0x8000000000000000LL, 2, 0x0LL)) + if (test__modti3(0x8000000000000000ULL, 2, 0x0LL)) return 1; - if (test__modti3(0x8000000000000000LL, -2, 0x0LL)) + if (test__modti3(0x8000000000000000ULL, -2, 0x0LL)) return 1; - if (test__modti3(0x8000000000000000LL, 3, 2)) + if (test__modti3(0x8000000000000000ULL, 3, 2)) return 1; - if (test__modti3(0x8000000000000000LL, -3, 2)) + if (test__modti3(0x8000000000000000ULL, -3, 2)) return 1; if (test__modti3(make_ti(0x8000000000000000LL, 0), 1, 0x0LL)) Index: compiler-rt/test/builtins/Unit/mulvti3_test.c =================================================================== --- compiler-rt/test/builtins/Unit/mulvti3_test.c +++ compiler-rt/test/builtins/Unit/mulvti3_test.c @@ -99,13 +99,13 @@ if (test__mulvti3(-81985529216486895LL, 1, -81985529216486895LL)) return 1; - if (test__mulvti3(3037000499LL, 3037000499LL, 9223372030926249001LL)) + if (test__mulvti3(3037000499LL, 3037000499LL, 9223372030926249001ULL)) return 1; if (test__mulvti3(-3037000499LL, 3037000499LL, -9223372030926249001LL)) return 1; if (test__mulvti3(3037000499LL, -3037000499LL, -9223372030926249001LL)) return 1; - if (test__mulvti3(-3037000499LL, -3037000499LL, 9223372030926249001LL)) + if (test__mulvti3(-3037000499LL, -3037000499LL, 9223372030926249001ULL)) return 1; if (test__mulvti3(4398046511103LL, 2097152LL, 9223372036852678656LL)) @@ -117,7 +117,7 @@ if (test__mulvti3(-4398046511103LL, -2097152LL, 9223372036852678656LL)) return 1; - if (test__mulvti3(2097152LL, 4398046511103LL, 9223372036852678656LL)) + if (test__mulvti3(2097152LL, 4398046511103LL, 9223372036852678656ULL)) return 1; if (test__mulvti3(-2097152LL, 4398046511103LL, -9223372036852678656LL)) return 1;