Merge pull request #357 from carlosmn/calling-convention Use __stdcall by default on Windows
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
diff --git a/CMakeLists.txt b/CMakeLists.txt
index cc77f7b..0e516ca 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -45,10 +45,14 @@ SET(INSTALL_INC include CACHE PATH "Where to install headers to.")
OPTION (BUILD_SHARED_LIBS "Build Shared Library (OFF for Static)" ON)
OPTION (BUILD_TESTS "Build Tests" ON)
OPTION (THREADSAFE "Build libgit2 as threadsafe" OFF)
+OPTION (STDCALL "Buildl libgit2 with the __stdcall convention (Windows)" ON)
# Platform specific compilation flags
IF (MSVC)
SET(CMAKE_C_FLAGS "/W4 /WX /nologo /Zi")
+ IF (STDCALL)
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Gz")
+ ENDIF ()
# TODO: bring back /RTC1 /RTCc
SET(CMAKE_C_FLAGS_DEBUG "/Od /DEBUG /MTd")
SET(CMAKE_C_FLAGS_RELEASE "/MT /O2")
diff --git a/src/transport_local.c b/src/transport_local.c
index 64ac183..bb3b10e 100644
--- a/src/transport_local.c
+++ b/src/transport_local.c
@@ -14,14 +14,6 @@ typedef struct {
git_vector *refs;
} transport_local;
-static int cmp_refs(const void *a, const void *b)
-{
- const char *stra = *(const char * const *) a;
- const char *strb = *(const char * const *) b;
-
- return strcmp(stra, strb);
-}
-
/*
* Try to open the url as a git directory. The direction doesn't
* matter in this case because we're calulating the heads ourselves.
@@ -148,7 +140,7 @@ static int local_ls(git_transport *transport, git_headarray *array)
return error;
/* Sort the references first */
- qsort(refs.strings, refs.count, sizeof(char *), cmp_refs);
+ git__tsort((void **)refs.strings, refs.count, (git_vector_cmp) strcmp);
/* Add HEAD */
error = add_ref(GIT_HEAD_FILE, repo, vec);
diff --git a/tests/test_main.c b/tests/test_main.c
index 1a35e60..c9f8da3 100644
--- a/tests/test_main.c
+++ b/tests/test_main.c
@@ -69,7 +69,12 @@ static libgit2_suite suite_methods[]= {
#define GIT_SUITE_COUNT (ARRAY_SIZE(suite_methods))
-int main(int GIT_UNUSED(argc), char *GIT_UNUSED(argv[]))
+#ifdef GIT_WIN32
+int __cdecl
+#else
+int
+#endif
+main(int GIT_UNUSED(argc), char *GIT_UNUSED(argv[]))
{
unsigned int i, failures;