Add GIT_STDLIB_CALL This removes the one-off GIT_CDECL and adds a new standard way of doing this named GIT_STDLIB_CALL with a src/win32 specific def when on the Windows platform.
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
diff --git a/src/common.h b/src/common.h
index ca203ee..48c4b54 100644
--- a/src/common.h
+++ b/src/common.h
@@ -41,6 +41,8 @@
# ifdef GIT_THREADS
# include <pthread.h>
# endif
+#define GIT_STDLIB_CALL
+
#endif
#include "git2/types.h"
diff --git a/src/hashsig.c b/src/hashsig.c
index b6020e7..e9c5164 100644
--- a/src/hashsig.c
+++ b/src/hashsig.c
@@ -19,14 +19,7 @@ typedef uint64_t hashsig_state;
#define HASHSIG_HEAP_SIZE ((1 << 7) - 1)
-/* going to use qsort so jump through some Windows hoops */
-#ifdef GIT_WIN32
-#define GIT_CDECL __cdecl
-#else
-#define GIT_CDECL
-#endif
-
-typedef int (GIT_CDECL *hashsig_cmp)(const void *a, const void *b);
+typedef int (GIT_STDLIB_CALL *hashsig_cmp)(const void *a, const void *b);
typedef struct {
int size, asize;
@@ -60,13 +53,13 @@ static void hashsig_heap_init(hashsig_heap *h, hashsig_cmp cmp)
h->cmp = cmp;
}
-static int GIT_CDECL hashsig_cmp_max(const void *a, const void *b)
+static int GIT_STDLIB_CALL hashsig_cmp_max(const void *a, const void *b)
{
hashsig_t av = *(const hashsig_t *)a, bv = *(const hashsig_t *)b;
return (av < bv) ? -1 : (av > bv) ? 1 : 0;
}
-static int GIT_CDECL hashsig_cmp_min(const void *a, const void *b)
+static int GIT_STDLIB_CALL hashsig_cmp_min(const void *a, const void *b)
{
hashsig_t av = *(const hashsig_t *)a, bv = *(const hashsig_t *)b;
return (av > bv) ? -1 : (av < bv) ? 1 : 0;
diff --git a/src/win32/msvc-compat.h b/src/win32/msvc-compat.h
index 714a85e..df2111d 100644
--- a/src/win32/msvc-compat.h
+++ b/src/win32/msvc-compat.h
@@ -39,4 +39,6 @@ typedef SSIZE_T ssize_t;
#endif
+#define GIT_STDLIB_CALL __cdecl
+
#endif /* INCLUDE_msvc_compat__ */