Attempt at fixing the MingW64 compilation It seems like MingW64's size_t is defined differently than in Linux.
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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
diff --git a/deps/zlib/CMakeLists.txt b/deps/zlib/CMakeLists.txt
index b0cb7f7..afa5a19 100644
--- a/deps/zlib/CMakeLists.txt
+++ b/deps/zlib/CMakeLists.txt
@@ -1,3 +1,4 @@
+DISABLE_WARNINGS(implicit-fallthrough)
ADD_DEFINITIONS(-DNO_VIZ -DSTDC -DNO_GZIP)
FILE(GLOB SRC_ZLIB "*.c" "*.h")
INCLUDE_DIRECTORIES(".")
diff --git a/src/cc-compat.h b/src/cc-compat.h
index 0f05cd2..5d3e652 100644
--- a/src/cc-compat.h
+++ b/src/cc-compat.h
@@ -47,9 +47,17 @@
/* Define the printf format specifer to use for size_t output */
#if defined(_MSC_VER) || defined(__MINGW32__)
-# define PRIuZ "Iu"
-# define PRIxZ "Ix"
-# define PRIdZ "Id"
+
+# if (SIZE_MAX == ULLONG_MAX)
+# define PRIuZ "I64u"
+# define PRIxZ "I64x"
+# define PRIdZ "I64d"
+# else
+# define PRIuZ "Iu"
+# define PRIxZ "Ix"
+# define PRIdZ "Id"
+# endif
+
#else
# define PRIuZ "zu"
# define PRIxZ "zx"
diff --git a/src/integer.h b/src/integer.h
index d56b19d..a10ee99 100644
--- a/src/integer.h
+++ b/src/integer.h
@@ -55,18 +55,26 @@ GIT_INLINE(bool) git__add_uint64_overflow(uint64_t *out, uint64_t one, uint64_t
}
/* Use clang/gcc compiler intrinsics whenever possible */
-#if (SIZE_MAX == ULLONG_MAX) && (__has_builtin(__builtin_uaddl_overflow) || \
- (defined(__GNUC__) && (__GNUC__ >= 5)))
-# define git__add_sizet_overflow(out, one, two) \
- __builtin_uaddl_overflow(one, two, out)
-# define git__multiply_sizet_overflow(out, one, two) \
- __builtin_umull_overflow(one, two, out)
-#elif (__has_builtin(__builtin_add_overflow) || \
- (defined(__GNUC__) && (__GNUC__ >= 5)))
-# define git__add_sizet_overflow(out, one, two) \
- __builtin_add_overflow(one, two, out)
-# define git__multiply_sizet_overflow(out, one, two) \
- __builtin_mul_overflow(one, two, out)
+#if (__has_builtin(__builtin_add_overflow) || \
+ (defined(__GNUC__) && (__GNUC__ >= 5)))
+
+# if (ULONG_MAX == ULLONG_MAX) && defined(_WIN64)
+# define git__add_sizet_overflow(out, one, two) \
+ __builtin_uaddll_overflow(one, two, out)
+# define git__multiply_sizet_overflow(out, one, two) \
+ __builtin_umulll_overflow(one, two, out)
+# elif (ULONG_MAX == ULLONG_MAX)
+# define git__add_sizet_overflow(out, one, two) \
+ __builtin_uaddl_overflow(one, two, out)
+# define git__multiply_sizet_overflow(out, one, two) \
+ __builtin_umull_overflow(one, two, out)
+# else
+# define git__add_sizet_overflow(out, one, two) \
+ __builtin_add_overflow(one, two, out)
+# define git__multiply_sizet_overflow(out, one, two) \
+ __builtin_mul_overflow(one, two, out)
+# endif
+
#else
/**
diff --git a/tests/core/vector.c b/tests/core/vector.c
index 2be7e86..a7e1a03 100644
--- a/tests/core/vector.c
+++ b/tests/core/vector.c
@@ -1,3 +1,5 @@
+#include <stdint.h>
+
#include "clar_libgit2.h"
#include "vector.h"
@@ -66,14 +68,14 @@ void test_core_vector__2(void)
static int compare_them(const void *a, const void *b)
{
- return (int)((long)a - (long)b);
+ return (int)((intptr_t)a - (intptr_t)b);
}
/* insert_sorted */
void test_core_vector__3(void)
{
git_vector x;
- long i;
+ intptr_t i;
git_vector_init(&x, 1, &compare_them);
for (i = 0; i < 10; i += 2) {
@@ -96,7 +98,7 @@ void test_core_vector__3(void)
void test_core_vector__4(void)
{
git_vector x;
- long i;
+ intptr_t i;
git_vector_init(&x, 1, &compare_them);
for (i = 0; i < 10; i += 2) {
diff --git a/tests/index/addall.c b/tests/index/addall.c
index 49e5079..12b05a7 100644
--- a/tests/index/addall.c
+++ b/tests/index/addall.c
@@ -123,8 +123,8 @@ static void check_stat_data(git_index *index, const char *path, bool match)
cl_assert(st.st_ctime == entry->ctime.seconds);
cl_assert(st.st_mtime == entry->mtime.seconds);
cl_assert(st.st_size == entry->file_size);
- cl_assert(st.st_uid == entry->uid);
- cl_assert(st.st_gid == entry->gid);
+ cl_assert(st.st_uid == (uid_t)entry->uid);
+ cl_assert(st.st_gid == (gid_t)entry->gid);
cl_assert_equal_i_fmt(
GIT_MODE_TYPE(st.st_mode), GIT_MODE_TYPE(entry->mode), "%07o");
if (cl_is_chmod_supported())
diff --git a/tests/path/win32.c b/tests/path/win32.c
index f45bf58..3ed7d7a 100644
--- a/tests/path/win32.c
+++ b/tests/path/win32.c
@@ -150,7 +150,7 @@ static void test_remove_namespace(const wchar_t *in, const wchar_t *expected)
cl_assert(wcslen(in) < MAX_PATH);
wcscpy(canonical, in);
- cl_must_pass(git_win32_path_remove_namespace(canonical, wcslen(in)));
+ git_win32_path_remove_namespace(canonical, wcslen(in));
cl_assert_equal_wcs(expected, canonical);
#else
GIT_UNUSED(in);