Skip to content

Commit 79a4059

Browse files
committed
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 de29de5 commit 79a4059

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);
@@ -301,8 +304,10 @@ static inline time_t filetime_to_time_t(const FILETIME *ft)
301304
/*
302305
* Use mingw specific stat()/lstat()/fstat() implementations on Windows.
303306
*/
307+
#ifndef __MINGW64_VERSION_MAJOR
304308
#define off_t off64_t
305309
#define lseek _lseeki64
310+
#endif
306311

307312
/* use struct stat with 64 bit st_size */
308313
#ifdef stat
@@ -375,8 +380,12 @@ static inline char *mingw_find_last_dir_sep(const char *path)
375380
int mingw_offset_1st_component(const char *path);
376381
#define offset_1st_component mingw_offset_1st_component
377382
#define PATH_SEP ';'
383+
#ifndef __MINGW64_VERSION_MAJOR
378384
#define PRIuMAX "I64u"
379385
#define PRId64 "I64d"
386+
#else
387+
#include <inttypes.h>
388+
#endif
380389

381390
void mingw_open_html(const char *path);
382391
#define open_html mingw_open_html

0 commit comments

Comments
 (0)