summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2020-12-08 14:33:31 +0000
committerEdward Thomson <ethomson@edwardthomson.com>2020-12-08 14:50:06 +0000
commit42d5f11084c67f8c96693bd42b424b0262be3f84 (patch)
tree32639e60775fa582e74e317a132638d1b3a516c3
parent971b7187faa1260aab75c531d9c78b29cdba6cc4 (diff)
downloadlibgit2-42d5f11084c67f8c96693bd42b424b0262be3f84.tar.gz
win32: provide macros for calling conventions
Provide more clarity for Win32 calling conventions - now that we always compile to __cdecl on Win32, we'll define that as the the libgit2 calling convention. Also offer NTAPI (__stdcall) calling conventions for things that need callbacks from NTAPI code (eg fiber-local storage).
-rw-r--r--src/common.h4
-rw-r--r--src/util.c2
-rw-r--r--src/win32/msvc-compat.h10
3 files changed, 13 insertions, 3 deletions
diff --git a/src/common.h b/src/common.h
index a4ddcf90b..bda3edbc1 100644
--- a/src/common.h
+++ b/src/common.h
@@ -63,7 +63,9 @@
# include <pthread.h>
# include <sched.h>
# endif
-#define GIT_STDLIB_CALL
+
+#define GIT_LIBGIT2_CALL
+#define GIT_SYSTEM_CALL
#ifdef GIT_USE_STAT_ATIMESPEC
# define st_atim st_atimespec
diff --git a/src/util.c b/src/util.c
index 18a02a265..87ccf32af 100644
--- a/src/util.c
+++ b/src/util.c
@@ -687,7 +687,7 @@ typedef struct {
void *payload;
} git__qsort_r_glue;
-static int GIT_STDLIB_CALL git__qsort_r_glue_cmp(
+static int GIT_LIBGIT2_CALL git__qsort_r_glue_cmp(
void *payload, const void *a, const void *b)
{
git__qsort_r_glue *glue = payload;
diff --git a/src/win32/msvc-compat.h b/src/win32/msvc-compat.h
index 4cf471f1d..03f9f36dc 100644
--- a/src/win32/msvc-compat.h
+++ b/src/win32/msvc-compat.h
@@ -23,6 +23,14 @@ typedef SSIZE_T ssize_t;
#endif
-#define GIT_STDLIB_CALL __cdecl
+/*
+ * Offer GIT_LIBGIT2_CALL for our calling conventions (__cdecl, always).
+ * This is useful for providing callbacks to userspace code.
+ *
+ * Offer GIT_SYSTEM_CALL for the system calling conventions (__stdcall on
+ * Win32). Useful for providing callbacks to system libraries.
+ */
+#define GIT_LIBGIT2_CALL __cdecl
+#define GIT_SYSTEM_CALL NTAPI
#endif