Skip to content

Commit 8a8d66c

Browse files
dschonalla
authored andcommitted
Assorted header fixes to support MSys2-based MinGW build
The excellent MSys2 project brings a substantially updated MinGW environment including newer GCC versions and new headers. To support compiling Git, let's special-case the new MinGW (tell-tale: the _MINGW64_VERSION_MAJOR constant is defined). Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 8bb5b6e commit 8a8d66c

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

compat/mingw.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1+
#include <stdint.h>
2+
#include <wchar.h>
13
#include <winsock2.h>
24
#include <ws2tcpip.h>
3-
45
/*
56
* things that are not available in header files
67
*/
78

8-
typedef int pid_t;
99
typedef int uid_t;
1010
typedef int socklen_t;
11-
#define hstrerror strerror
1211

1312
#define S_IFLNK 0120000 /* Symbolic link */
1413
#define S_ISLNK(x) (((x) & S_IFMT) == S_IFLNK)
@@ -92,8 +91,10 @@ static inline int symlink(const char *oldpath, const char *newpath)
9291
{ errno = ENOSYS; return -1; }
9392
static inline int fchmod(int fildes, mode_t mode)
9493
{ errno = ENOSYS; return -1; }
94+
#ifndef __MINGW64_VERSION_MAJOR
9595
static inline pid_t fork(void)
9696
{ errno = ENOSYS; return -1; }
97+
#endif
9798
static inline unsigned int alarm(unsigned int seconds)
9899
{ return 0; }
99100
static inline int fsync(int fd)
@@ -164,8 +165,10 @@ int pipe(int filedes[2]);
164165
unsigned int sleep (unsigned int seconds);
165166
int mkstemp(char *template);
166167
int gettimeofday(struct timeval *tv, void *tz);
168+
#ifndef __MINGW64_VERSION_MAJOR
167169
struct tm *gmtime_r(const time_t *timep, struct tm *result);
168170
struct tm *localtime_r(const time_t *timep, struct tm *result);
171+
#endif
169172
int getpagesize(void); /* defined in MinGW's libgcc.a */
170173
struct passwd *getpwuid(uid_t uid);
171174
int setitimer(int type, struct itimerval *in, struct itimerval *out);
@@ -285,8 +288,10 @@ static inline int getrlimit(int resource, struct rlimit *rlp)
285288
/*
286289
* Use mingw specific stat()/lstat()/fstat() implementations on Windows.
287290
*/
291+
#ifndef __MINGW64_VERSION_MAJOR
288292
#define off_t off64_t
289293
#define lseek _lseeki64
294+
#endif
290295

291296
/* use struct stat with 64 bit st_size */
292297
#ifdef stat
@@ -359,8 +364,12 @@ static inline char *mingw_find_last_dir_sep(const char *path)
359364
int mingw_offset_1st_component(const char *path);
360365
#define offset_1st_component mingw_offset_1st_component
361366
#define PATH_SEP ';'
367+
#ifndef __MINGW64_VERSION_MAJOR
362368
#define PRIuMAX "I64u"
363369
#define PRId64 "I64d"
370+
#else
371+
#include <inttypes.h>
372+
#endif
364373

365374
void mingw_open_html(const char *path);
366375
#define open_html mingw_open_html

0 commit comments

Comments
 (0)