Merge branch 'js/msys2'
Beginning of the upstreaming process of Git for Windows effort. * js/msys2: mingw: uglify (a, 0) definitions to shut up warnings mingw: squash another warning about a cast mingw: avoid warnings when casting HANDLEs to int mingw: avoid redefining S_* constants compat/winansi: support compiling with MSys2 compat/mingw: support MSys2-based MinGW build nedmalloc: allow compiling with MSys2's compiler config.mak.uname: supporting 64-bit MSys2 config.mak.uname: support MSys2
This commit is contained in:
commit
116a866bf5
@ -6,6 +6,8 @@
|
|||||||
#include "../run-command.h"
|
#include "../run-command.h"
|
||||||
#include "../cache.h"
|
#include "../cache.h"
|
||||||
|
|
||||||
|
#define HCAST(type, handle) ((type)(intptr_t)handle)
|
||||||
|
|
||||||
static const int delay[] = { 0, 1, 10, 20, 40 };
|
static const int delay[] = { 0, 1, 10, 20, 40 };
|
||||||
|
|
||||||
int err_win_to_posix(DWORD winerr)
|
int err_win_to_posix(DWORD winerr)
|
||||||
@ -691,13 +693,13 @@ int pipe(int filedes[2])
|
|||||||
errno = err_win_to_posix(GetLastError());
|
errno = err_win_to_posix(GetLastError());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
filedes[0] = _open_osfhandle((int)h[0], O_NOINHERIT);
|
filedes[0] = _open_osfhandle(HCAST(int, h[0]), O_NOINHERIT);
|
||||||
if (filedes[0] < 0) {
|
if (filedes[0] < 0) {
|
||||||
CloseHandle(h[0]);
|
CloseHandle(h[0]);
|
||||||
CloseHandle(h[1]);
|
CloseHandle(h[1]);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
filedes[1] = _open_osfhandle((int)h[1], O_NOINHERIT);
|
filedes[1] = _open_osfhandle(HCAST(int, h[1]), O_NOINHERIT);
|
||||||
if (filedes[1] < 0) {
|
if (filedes[1] < 0) {
|
||||||
close(filedes[0]);
|
close(filedes[0]);
|
||||||
CloseHandle(h[1]);
|
CloseHandle(h[1]);
|
||||||
@ -1846,7 +1848,8 @@ void mingw_open_html(const char *unixpath)
|
|||||||
die("cannot run browser");
|
die("cannot run browser");
|
||||||
|
|
||||||
printf("Launching default browser to display HTML ...\n");
|
printf("Launching default browser to display HTML ...\n");
|
||||||
r = (int)ShellExecute(NULL, "open", htmlpath, NULL, "\\", SW_SHOWNORMAL);
|
r = HCAST(int, ShellExecute(NULL, "open", htmlpath,
|
||||||
|
NULL, "\\", SW_SHOWNORMAL));
|
||||||
FreeLibrary(shell32);
|
FreeLibrary(shell32);
|
||||||
/* see the MSDN documentation referring to the result codes here */
|
/* see the MSDN documentation referring to the result codes here */
|
||||||
if (r <= 32) {
|
if (r <= 32) {
|
||||||
|
@ -1,27 +1,43 @@
|
|||||||
|
#ifdef __MINGW64_VERSION_MAJOR
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <wchar.h>
|
||||||
|
typedef _sigset_t sigset_t;
|
||||||
|
#endif
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include <ws2tcpip.h>
|
#include <ws2tcpip.h>
|
||||||
|
|
||||||
|
/* MinGW-w64 reports to have flockfile, but it does not actually have it. */
|
||||||
|
#ifdef __MINGW64_VERSION_MAJOR
|
||||||
|
#undef _POSIX_THREAD_SAFE_FUNCTIONS
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* things that are not available in header files
|
* things that are not available in header files
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef int pid_t;
|
|
||||||
typedef int uid_t;
|
typedef int uid_t;
|
||||||
typedef int socklen_t;
|
typedef int socklen_t;
|
||||||
|
#ifndef __MINGW64_VERSION_MAJOR
|
||||||
|
typedef int pid_t;
|
||||||
#define hstrerror strerror
|
#define hstrerror strerror
|
||||||
|
#endif
|
||||||
|
|
||||||
#define S_IFLNK 0120000 /* Symbolic link */
|
#define S_IFLNK 0120000 /* Symbolic link */
|
||||||
#define S_ISLNK(x) (((x) & S_IFMT) == S_IFLNK)
|
#define S_ISLNK(x) (((x) & S_IFMT) == S_IFLNK)
|
||||||
#define S_ISSOCK(x) 0
|
#define S_ISSOCK(x) 0
|
||||||
|
|
||||||
|
#ifndef S_IRWXG
|
||||||
#define S_IRGRP 0
|
#define S_IRGRP 0
|
||||||
#define S_IWGRP 0
|
#define S_IWGRP 0
|
||||||
#define S_IXGRP 0
|
#define S_IXGRP 0
|
||||||
#define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
|
#define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
|
||||||
|
#endif
|
||||||
|
#ifndef S_IRWXO
|
||||||
#define S_IROTH 0
|
#define S_IROTH 0
|
||||||
#define S_IWOTH 0
|
#define S_IWOTH 0
|
||||||
#define S_IXOTH 0
|
#define S_IXOTH 0
|
||||||
#define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
|
#define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define S_ISUID 0004000
|
#define S_ISUID 0004000
|
||||||
#define S_ISGID 0002000
|
#define S_ISGID 0002000
|
||||||
@ -100,8 +116,10 @@ static inline int symlink(const char *oldpath, const char *newpath)
|
|||||||
{ errno = ENOSYS; return -1; }
|
{ errno = ENOSYS; return -1; }
|
||||||
static inline int fchmod(int fildes, mode_t mode)
|
static inline int fchmod(int fildes, mode_t mode)
|
||||||
{ errno = ENOSYS; return -1; }
|
{ errno = ENOSYS; return -1; }
|
||||||
|
#ifndef __MINGW64_VERSION_MAJOR
|
||||||
static inline pid_t fork(void)
|
static inline pid_t fork(void)
|
||||||
{ errno = ENOSYS; return -1; }
|
{ errno = ENOSYS; return -1; }
|
||||||
|
#endif
|
||||||
static inline unsigned int alarm(unsigned int seconds)
|
static inline unsigned int alarm(unsigned int seconds)
|
||||||
{ return 0; }
|
{ return 0; }
|
||||||
static inline int fsync(int fd)
|
static inline int fsync(int fd)
|
||||||
@ -176,8 +194,10 @@ int pipe(int filedes[2]);
|
|||||||
unsigned int sleep (unsigned int seconds);
|
unsigned int sleep (unsigned int seconds);
|
||||||
int mkstemp(char *template);
|
int mkstemp(char *template);
|
||||||
int gettimeofday(struct timeval *tv, void *tz);
|
int gettimeofday(struct timeval *tv, void *tz);
|
||||||
|
#ifndef __MINGW64_VERSION_MAJOR
|
||||||
struct tm *gmtime_r(const time_t *timep, struct tm *result);
|
struct tm *gmtime_r(const time_t *timep, struct tm *result);
|
||||||
struct tm *localtime_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 */
|
int getpagesize(void); /* defined in MinGW's libgcc.a */
|
||||||
struct passwd *getpwuid(uid_t uid);
|
struct passwd *getpwuid(uid_t uid);
|
||||||
int setitimer(int type, struct itimerval *in, struct itimerval *out);
|
int setitimer(int type, struct itimerval *in, struct itimerval *out);
|
||||||
@ -301,8 +321,10 @@ static inline int getrlimit(int resource, struct rlimit *rlp)
|
|||||||
/*
|
/*
|
||||||
* Use mingw specific stat()/lstat()/fstat() implementations on Windows.
|
* Use mingw specific stat()/lstat()/fstat() implementations on Windows.
|
||||||
*/
|
*/
|
||||||
|
#ifndef __MINGW64_VERSION_MAJOR
|
||||||
#define off_t off64_t
|
#define off_t off64_t
|
||||||
#define lseek _lseeki64
|
#define lseek _lseeki64
|
||||||
|
#endif
|
||||||
|
|
||||||
/* use struct stat with 64 bit st_size */
|
/* use struct stat with 64 bit st_size */
|
||||||
#ifdef stat
|
#ifdef stat
|
||||||
@ -375,8 +397,12 @@ static inline char *mingw_find_last_dir_sep(const char *path)
|
|||||||
int mingw_offset_1st_component(const char *path);
|
int mingw_offset_1st_component(const char *path);
|
||||||
#define offset_1st_component mingw_offset_1st_component
|
#define offset_1st_component mingw_offset_1st_component
|
||||||
#define PATH_SEP ';'
|
#define PATH_SEP ';'
|
||||||
|
#ifndef __MINGW64_VERSION_MAJOR
|
||||||
#define PRIuMAX "I64u"
|
#define PRIuMAX "I64u"
|
||||||
#define PRId64 "I64d"
|
#define PRId64 "I64d"
|
||||||
|
#else
|
||||||
|
#include <inttypes.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
void mingw_open_html(const char *path);
|
void mingw_open_html(const char *path);
|
||||||
#define open_html mingw_open_html
|
#define open_html mingw_open_html
|
||||||
|
@ -720,6 +720,9 @@ struct mallinfo {
|
|||||||
inlining are defined as macros, so these aren't used for them.
|
inlining are defined as macros, so these aren't used for them.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef __MINGW64_VERSION_MAJOR
|
||||||
|
#undef FORCEINLINE
|
||||||
|
#endif
|
||||||
#ifndef FORCEINLINE
|
#ifndef FORCEINLINE
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
#define FORCEINLINE __inline __attribute__ ((always_inline))
|
#define FORCEINLINE __inline __attribute__ ((always_inline))
|
||||||
@ -1382,6 +1385,7 @@ LONG __cdecl _InterlockedExchange(LONG volatile *Target, LONG Value);
|
|||||||
|
|
||||||
/*** Atomic operations ***/
|
/*** Atomic operations ***/
|
||||||
#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) > 40100
|
#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) > 40100
|
||||||
|
#undef _ReadWriteBarrier
|
||||||
#define _ReadWriteBarrier() __sync_synchronize()
|
#define _ReadWriteBarrier() __sync_synchronize()
|
||||||
#else
|
#else
|
||||||
static __inline__ __attribute__((always_inline)) long __sync_lock_test_and_set(volatile long * const Target, const long Value)
|
static __inline__ __attribute__((always_inline)) long __sync_lock_test_and_set(volatile long * const Target, const long Value)
|
||||||
@ -1798,9 +1802,10 @@ struct win32_mlock_t
|
|||||||
volatile long threadid;
|
volatile long threadid;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static inline int return_0(int i) { return 0; }
|
||||||
#define MLOCK_T struct win32_mlock_t
|
#define MLOCK_T struct win32_mlock_t
|
||||||
#define CURRENT_THREAD win32_getcurrentthreadid()
|
#define CURRENT_THREAD win32_getcurrentthreadid()
|
||||||
#define INITIAL_LOCK(sl) (memset(sl, 0, sizeof(MLOCK_T)), 0)
|
#define INITIAL_LOCK(sl) (memset(sl, 0, sizeof(MLOCK_T)), return_0(0))
|
||||||
#define ACQUIRE_LOCK(sl) win32_acquire_lock(sl)
|
#define ACQUIRE_LOCK(sl) win32_acquire_lock(sl)
|
||||||
#define RELEASE_LOCK(sl) win32_release_lock(sl)
|
#define RELEASE_LOCK(sl) win32_release_lock(sl)
|
||||||
#define TRY_LOCK(sl) win32_try_lock(sl)
|
#define TRY_LOCK(sl) win32_try_lock(sl)
|
||||||
|
@ -76,7 +76,7 @@
|
|||||||
|
|
||||||
#ifdef WIN32_NATIVE
|
#ifdef WIN32_NATIVE
|
||||||
|
|
||||||
#define IsConsoleHandle(h) (((long) (h) & 3) == 3)
|
#define IsConsoleHandle(h) (((long) (intptr_t) (h) & 3) == 3)
|
||||||
|
|
||||||
static BOOL
|
static BOOL
|
||||||
IsSocketHandle (HANDLE h)
|
IsSocketHandle (HANDLE h)
|
||||||
|
@ -18,7 +18,10 @@
|
|||||||
*/
|
*/
|
||||||
#define pthread_mutex_t CRITICAL_SECTION
|
#define pthread_mutex_t CRITICAL_SECTION
|
||||||
|
|
||||||
#define pthread_mutex_init(a,b) (InitializeCriticalSection((a)), 0)
|
static inline int return_0(int i) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#define pthread_mutex_init(a,b) return_0((InitializeCriticalSection((a)), 0))
|
||||||
#define pthread_mutex_destroy(a) DeleteCriticalSection((a))
|
#define pthread_mutex_destroy(a) DeleteCriticalSection((a))
|
||||||
#define pthread_mutex_lock EnterCriticalSection
|
#define pthread_mutex_lock EnterCriticalSection
|
||||||
#define pthread_mutex_unlock LeaveCriticalSection
|
#define pthread_mutex_unlock LeaveCriticalSection
|
||||||
@ -77,7 +80,7 @@ extern pthread_t pthread_self(void);
|
|||||||
|
|
||||||
static inline int pthread_exit(void *ret)
|
static inline int pthread_exit(void *ret)
|
||||||
{
|
{
|
||||||
ExitThread((DWORD)ret);
|
ExitThread((DWORD)(intptr_t)ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef DWORD pthread_key_t;
|
typedef DWORD pthread_key_t;
|
||||||
|
@ -23,6 +23,7 @@ static HANDLE hthread, hread, hwrite;
|
|||||||
static HANDLE hconsole1, hconsole2;
|
static HANDLE hconsole1, hconsole2;
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#ifdef __MINGW32__
|
||||||
|
#if !defined(__MINGW64_VERSION_MAJOR) || __MINGW64_VERSION_MAJOR < 5
|
||||||
typedef struct _CONSOLE_FONT_INFOEX {
|
typedef struct _CONSOLE_FONT_INFOEX {
|
||||||
ULONG cbSize;
|
ULONG cbSize;
|
||||||
DWORD nFont;
|
DWORD nFont;
|
||||||
@ -32,6 +33,7 @@ typedef struct _CONSOLE_FONT_INFOEX {
|
|||||||
WCHAR FaceName[LF_FACESIZE];
|
WCHAR FaceName[LF_FACESIZE];
|
||||||
} CONSOLE_FONT_INFOEX, *PCONSOLE_FONT_INFOEX;
|
} CONSOLE_FONT_INFOEX, *PCONSOLE_FONT_INFOEX;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef BOOL (WINAPI *PGETCURRENTCONSOLEFONTEX)(HANDLE, BOOL,
|
typedef BOOL (WINAPI *PGETCURRENTCONSOLEFONTEX)(HANDLE, BOOL,
|
||||||
PCONSOLE_FONT_INFOEX);
|
PCONSOLE_FONT_INFOEX);
|
||||||
@ -452,7 +454,8 @@ static HANDLE duplicate_handle(HANDLE hnd)
|
|||||||
HANDLE hresult, hproc = GetCurrentProcess();
|
HANDLE hresult, hproc = GetCurrentProcess();
|
||||||
if (!DuplicateHandle(hproc, hnd, hproc, &hresult, 0, TRUE,
|
if (!DuplicateHandle(hproc, hnd, hproc, &hresult, 0, TRUE,
|
||||||
DUPLICATE_SAME_ACCESS))
|
DUPLICATE_SAME_ACCESS))
|
||||||
die_lasterr("DuplicateHandle(%li) failed", (long) hnd);
|
die_lasterr("DuplicateHandle(%li) failed",
|
||||||
|
(long) (intptr_t) hnd);
|
||||||
return hresult;
|
return hresult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -518,13 +518,12 @@ ifneq (,$(findstring MINGW,$(uname_S)))
|
|||||||
NO_INET_NTOP = YesPlease
|
NO_INET_NTOP = YesPlease
|
||||||
NO_POSIX_GOODIES = UnfortunatelyYes
|
NO_POSIX_GOODIES = UnfortunatelyYes
|
||||||
DEFAULT_HELP_FORMAT = html
|
DEFAULT_HELP_FORMAT = html
|
||||||
COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -D_USE_32BIT_TIME_T -DNOGDI -Icompat -Icompat/win32
|
COMPAT_CFLAGS += -DNOGDI -Icompat -Icompat/win32
|
||||||
COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
|
COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
|
||||||
COMPAT_OBJS += compat/mingw.o compat/winansi.o \
|
COMPAT_OBJS += compat/mingw.o compat/winansi.o \
|
||||||
compat/win32/pthread.o compat/win32/syslog.o \
|
compat/win32/pthread.o compat/win32/syslog.o \
|
||||||
compat/win32/dirent.o
|
compat/win32/dirent.o
|
||||||
BASIC_CFLAGS += -DPROTECT_NTFS_DEFAULT=1
|
BASIC_CFLAGS += -DPROTECT_NTFS_DEFAULT=1
|
||||||
BASIC_LDFLAGS += -Wl,--large-address-aware
|
|
||||||
EXTLIBS += -lws2_32
|
EXTLIBS += -lws2_32
|
||||||
GITLIBS += git.res
|
GITLIBS += git.res
|
||||||
PTHREAD_LIBS =
|
PTHREAD_LIBS =
|
||||||
@ -541,8 +540,34 @@ ifneq (,$(wildcard ../THIS_IS_MSYSGIT))
|
|||||||
INTERNAL_QSORT = YesPlease
|
INTERNAL_QSORT = YesPlease
|
||||||
HAVE_LIBCHARSET_H = YesPlease
|
HAVE_LIBCHARSET_H = YesPlease
|
||||||
NO_GETTEXT = YesPlease
|
NO_GETTEXT = YesPlease
|
||||||
|
COMPAT_CLFAGS += -D__USE_MINGW_ACCESS
|
||||||
else
|
else
|
||||||
NO_CURL = YesPlease
|
ifeq ($(shell expr "$(uname_R)" : '2\.'),2)
|
||||||
|
# MSys2
|
||||||
|
prefix = /usr/
|
||||||
|
ifeq (MINGW32,$(MSYSTEM))
|
||||||
|
prefix = /mingw32
|
||||||
|
endif
|
||||||
|
ifeq (MINGW64,$(MSYSTEM))
|
||||||
|
prefix = /mingw64
|
||||||
|
else
|
||||||
|
COMPAT_CFLAGS += -D_USE_32BIT_TIME_T
|
||||||
|
BASIC_LDFLAGS += -Wl,--large-address-aware
|
||||||
|
endif
|
||||||
|
CC = gcc
|
||||||
|
COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO=0
|
||||||
|
INSTALL = /bin/install
|
||||||
|
NO_R_TO_GCC_LINKER = YesPlease
|
||||||
|
INTERNAL_QSORT = YesPlease
|
||||||
|
HAVE_LIBCHARSET_H = YesPlease
|
||||||
|
NO_GETTEXT = YesPlease
|
||||||
|
USE_LIBPCRE= YesPlease
|
||||||
|
NO_CURL =
|
||||||
|
USE_NED_ALLOCATOR = YesPlease
|
||||||
|
else
|
||||||
|
COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO
|
||||||
|
NO_CURL = YesPlease
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
ifeq ($(uname_S),QNX)
|
ifeq ($(uname_S),QNX)
|
||||||
|
Loading…
Reference in New Issue
Block a user