Skip to content

Commit 42d5f11

Browse files
Edward Thomsonethomson
authored andcommitted
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).
1 parent 971b718 commit 42d5f11

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

src/common.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@
6363
# include <pthread.h>
6464
# include <sched.h>
6565
# endif
66-
#define GIT_STDLIB_CALL
66+
67+
#define GIT_LIBGIT2_CALL
68+
#define GIT_SYSTEM_CALL
6769

6870
#ifdef GIT_USE_STAT_ATIMESPEC
6971
# define st_atim st_atimespec

src/util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ typedef struct {
687687
void *payload;
688688
} git__qsort_r_glue;
689689

690-
static int GIT_STDLIB_CALL git__qsort_r_glue_cmp(
690+
static int GIT_LIBGIT2_CALL git__qsort_r_glue_cmp(
691691
void *payload, const void *a, const void *b)
692692
{
693693
git__qsort_r_glue *glue = payload;

src/win32/msvc-compat.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ typedef SSIZE_T ssize_t;
2323

2424
#endif
2525

26-
#define GIT_STDLIB_CALL __cdecl
26+
/*
27+
* Offer GIT_LIBGIT2_CALL for our calling conventions (__cdecl, always).
28+
* This is useful for providing callbacks to userspace code.
29+
*
30+
* Offer GIT_SYSTEM_CALL for the system calling conventions (__stdcall on
31+
* Win32). Useful for providing callbacks to system libraries.
32+
*/
33+
#define GIT_LIBGIT2_CALL __cdecl
34+
#define GIT_SYSTEM_CALL NTAPI
2735

2836
#endif

0 commit comments

Comments
 (0)