Skip to content

Commit b1b9520

Browse files
Ramsay Jonesgitster
authored andcommitted
MSVC: Add support for building with NO_MMAP
When the NO_MMAP build variable is set, the msvc linker complains: error LNK2001: unresolved external symbol _getpagesize The msvc libraries do not define the getpagesize() function, so we move the mingw_getpagesize() implementation from the conditionally built win32mmap.c file to mingw.c. Signed-off-by: Ramsay Jones <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d691d84 commit b1b9520

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

compat/mingw.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,6 +1000,18 @@ int mingw_rename(const char *pold, const char *pnew)
10001000
return -1;
10011001
}
10021002

1003+
/*
1004+
* Note that this doesn't return the actual pagesize, but
1005+
* the allocation granularity. If future Windows specific git code
1006+
* needs the real getpagesize function, we need to find another solution.
1007+
*/
1008+
int mingw_getpagesize(void)
1009+
{
1010+
SYSTEM_INFO si;
1011+
GetSystemInfo(&si);
1012+
return si.dwAllocationGranularity;
1013+
}
1014+
10031015
struct passwd *getpwuid(int uid)
10041016
{
10051017
static char user_name[100];

compat/mingw.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ int mingw_connect(int sockfd, struct sockaddr *sa, size_t sz);
166166
int mingw_rename(const char*, const char*);
167167
#define rename mingw_rename
168168

169-
#ifdef USE_WIN32_MMAP
169+
#if defined(USE_WIN32_MMAP) || defined(_MSC_VER)
170170
int mingw_getpagesize(void);
171171
#define getpagesize mingw_getpagesize
172172
#endif

compat/win32mmap.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
11
#include "../git-compat-util.h"
22

3-
/*
4-
* Note that this doesn't return the actual pagesize, but
5-
* the allocation granularity. If future Windows specific git code
6-
* needs the real getpagesize function, we need to find another solution.
7-
*/
8-
int mingw_getpagesize(void)
9-
{
10-
SYSTEM_INFO si;
11-
GetSystemInfo(&si);
12-
return si.dwAllocationGranularity;
13-
}
14-
153
void *git_mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset)
164
{
175
HANDLE hmap;

0 commit comments

Comments
 (0)