Skip to content

Commit

Permalink
Merge branch 'kb/fix-msvc-stat-definitions'
Browse files Browse the repository at this point in the history
  • Loading branch information
kblees committed Oct 1, 2013
2 parents 8102961 + 3a05a04 commit 6c99f68
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
21 changes: 17 additions & 4 deletions compat/mingw.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ typedef int socklen_t;
#define WEXITSTATUS(x) ((x) & 0xff)
#define WTERMSIG(x) SIGTERM

#ifndef EWOULDBLOCK
#define EWOULDBLOCK EAGAIN
#endif
#define SHUT_WR SD_SEND

#define SIGHUP 1
Expand All @@ -46,8 +48,12 @@ typedef int socklen_t;
#define F_SETFD 2
#define FD_CLOEXEC 0x1

#ifndef EAFNOSUPPORT
#define EAFNOSUPPORT WSAEAFNOSUPPORT
#endif
#ifndef ECONNABORTED
#define ECONNABORTED WSAECONNABORTED
#endif

struct passwd {
char *pw_name;
Expand Down Expand Up @@ -271,19 +277,26 @@ static inline int getrlimit(int resource, struct rlimit *rlp)
return 0;
}

/* Use mingw_lstat() instead of lstat()/stat() and
* mingw_fstat() instead of fstat() on Windows.
/*
* Use mingw specific stat()/lstat()/fstat() implementations on Windows.
*/
#define off_t off64_t
#define lseek _lseeki64
#ifndef ALREADY_DECLARED_STAT_FUNCS

/* use struct stat with 64 bit st_size */
#define stat _stati64
int mingw_lstat(const char *file_name, struct stat *buf);
int mingw_stat(const char *file_name, struct stat *buf);
int mingw_fstat(int fd, struct stat *buf);
#define fstat mingw_fstat
#define lstat mingw_lstat
#define _stati64(x,y) mingw_stat(x,y)

#ifndef _stati64
# define _stati64(x,y) mingw_stat(x,y)
#elif defined (_USE_32BIT_TIME_T)
# define _stat32i64(x,y) mingw_stat(x,y)
#else
# define _stat64(x,y) mingw_stat(x,y)
#endif

int mingw_utime(const char *file_name, const struct utimbuf *times);
Expand Down
15 changes: 0 additions & 15 deletions compat/msvc.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,6 @@ static __inline int strcasecmp (const char *s1, const char *s2)

#undef ERROR

/* Use mingw_lstat() instead of lstat()/stat() and mingw_fstat() instead
* of fstat(). We add the declaration of these functions here, suppressing
* the corresponding declarations in mingw.h, so that we can use the
* appropriate structure type (and function) names from the msvc headers.
*/
#define stat _stat64
int mingw_lstat(const char *file_name, struct stat *buf);
int mingw_fstat(int fd, struct stat *buf);
#define fstat mingw_fstat
#define lstat mingw_lstat
#define _stat64(x,y) mingw_lstat(x,y)
#define ALREADY_DECLARED_STAT_FUNCS

#include "compat/mingw.h"

#undef ALREADY_DECLARED_STAT_FUNCS

#endif
1 change: 1 addition & 0 deletions config.mak.uname
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ ifeq ($(uname_S),Windows)
OBJECT_CREATION_USES_RENAMES = UnfortunatelyNeedsTo
NO_REGEX = YesPlease
NO_CURL = YesPlease
NO_GETTEXT = YesPlease
NO_PYTHON = YesPlease
BLK_SHA1 = YesPlease
ETAGS_TARGET = ETAGS
Expand Down

0 comments on commit 6c99f68

Please sign in to comment.