Merge pull request #91 from libtom/fix/microsoft_build there's no __int128 on MSVC, fall back to 32bit MPI's
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
diff --git a/makefile_include.mk b/makefile_include.mk
index 3a599e8..45a4895 100644
--- a/makefile_include.mk
+++ b/makefile_include.mk
@@ -60,6 +60,9 @@ endif # COMPILE_DEBUG
ifneq ($(findstring clang,$(CC)),)
CFLAGS += -Wno-typedef-redefinition -Wno-tautological-compare -Wno-builtin-requires-header
endif
+ifneq ($(findstring mingw,$(CC)),)
+CFLAGS += -Wno-shadow
+endif
ifeq ($(PLATFORM), Darwin)
CFLAGS += -Wno-nullability-completeness
endif
diff --git a/tommath.h b/tommath.h
index 591076e..0119906 100644
--- a/tommath.h
+++ b/tommath.h
@@ -26,6 +26,11 @@
extern "C" {
#endif
+/* MS Visual C++ doesn't have a 128bit type for words, so fall back to 32bit MPI's (where words are 64bit) */
+#if defined(_MSC_VER) || defined(__LLP64__)
+# define MP_32BIT
+#endif
+
/* detect 64-bit mode if possible */
#if defined(__x86_64__) || defined(_M_X64) || defined(_M_AMD64) || \
defined(__powerpc64__) || defined(__ppc64__) || defined(__PPC64__) || \
@@ -63,9 +68,7 @@ typedef uint32_t mp_word;
#elif defined(MP_64BIT)
/* for GCC only on supported platforms */
typedef uint64_t mp_digit;
-# if defined(_WIN32)
-typedef unsigned __int128 mp_word;
-# elif defined(__GNUC__)
+# if defined(__GNUC__)
typedef unsigned long mp_word __attribute__((mode(TI)));
# else
/* it seems you have a problem