Commit b5e8272f by lhchavez

Attempt at fixing the MingW64 compilation

It seems like MingW64's size_t is defined differently than in Linux.
parent 7b453e7e
DISABLE_WARNINGS(implicit-fallthrough)
ADD_DEFINITIONS(-DNO_VIZ -DSTDC -DNO_GZIP)
FILE(GLOB SRC_ZLIB "*.c" "*.h")
INCLUDE_DIRECTORIES(".")
......
......@@ -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"
......
......@@ -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
/**
......
#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) {
......
......@@ -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())
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment