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 <johannes.schindelin@gmx.de>
This commit is contained in:
Johannes Schindelin
2015-02-13 12:18:54 +00:00
parent 16d0277dfb
commit 1f73288ef9

View File

@@ -1,14 +1,13 @@
#include <stdint.h>
#include <wchar.h>
#include <winsock2.h>
#include <ws2tcpip.h>
/*
* things that are not available in header files
*/
typedef int pid_t;
typedef int uid_t;
typedef int socklen_t;
#define hstrerror strerror
#define S_IFLNK 0120000 /* Symbolic link */
#define S_ISLNK(x) (((x) & S_IFMT) == S_IFLNK)
@@ -100,8 +99,10 @@ static inline int symlink(const char *oldpath, const char *newpath)
{ errno = ENOSYS; return -1; }
static inline int fchmod(int fildes, mode_t mode)
{ errno = ENOSYS; return -1; }
#ifndef __MINGW64_VERSION_MAJOR
static inline pid_t fork(void)
{ errno = ENOSYS; return -1; }
#endif
static inline unsigned int alarm(unsigned int seconds)
{ return 0; }
static inline int fsync(int fd)
@@ -176,8 +177,10 @@ int pipe(int filedes[2]);
unsigned int sleep (unsigned int seconds);
int mkstemp(char *template);
int gettimeofday(struct timeval *tv, void *tz);
#ifndef __MINGW64_VERSION_MAJOR
struct tm *gmtime_r(const time_t *timep, struct tm *result);
struct tm *localtime_r(const time_t *timep, struct tm *result);
#endif
int getpagesize(void); /* defined in MinGW's libgcc.a */
struct passwd *getpwuid(uid_t uid);
int setitimer(int type, struct itimerval *in, struct itimerval *out);
@@ -317,8 +320,10 @@ static inline time_t filetime_to_time_t(const FILETIME *ft)
/*
* Use mingw specific stat()/lstat()/fstat() implementations on Windows.
*/
#ifndef __MINGW64_VERSION_MAJOR
#define off_t off64_t
#define lseek _lseeki64
#endif
/* use struct stat with 64 bit st_size */
#ifdef stat
@@ -391,8 +396,12 @@ static inline char *mingw_find_last_dir_sep(const char *path)
int mingw_offset_1st_component(const char *path);
#define offset_1st_component mingw_offset_1st_component
#define PATH_SEP ';'
#ifndef __MINGW64_VERSION_MAJOR
#define PRIuMAX "I64u"
#define PRId64 "I64d"
#else
#include <inttypes.h>
#endif
void mingw_open_html(const char *path);
#define open_html mingw_open_html