Merge branch 'jk/push-client-deadlock-fix'
authorJunio C Hamano <gitster@pobox.com>
Wed, 18 May 2016 22:11:46 +0000 (15:11 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 18 May 2016 22:11:46 +0000 (15:11 -0700)
Some Windows SDK lacks pthread_sigmask() implementation and fails
to compile the recently updated "git push" codepath that uses it.

* jk/push-client-deadlock-fix:
Windows: only add a no-op pthread_sigmask() when needed
Windows: add pthread_sigmask() that does nothing

1  2 
compat/mingw.h
compat/win32/pthread.h
diff --combined compat/mingw.h
index a1808b4e6b8049b6623ec98f4a65313b2665772b,c26b6e2958c456647e96d98bfd79275417cc3e14..69bb43dc35d4c28724f007d9684715ec40421542
@@@ -1,43 -1,27 +1,43 @@@
 +#ifdef __MINGW64_VERSION_MAJOR
 +#include <stdint.h>
 +#include <wchar.h>
 +typedef _sigset_t sigset_t;
 +#endif
  #include <winsock2.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
   */
  
 -typedef int pid_t;
  typedef int uid_t;
  typedef int socklen_t;
 +#ifndef __MINGW64_VERSION_MAJOR
 +typedef int pid_t;
  #define hstrerror strerror
 +#endif
  
  #define S_IFLNK    0120000 /* Symbolic link */
  #define S_ISLNK(x) (((x) & S_IFMT) == S_IFLNK)
  #define S_ISSOCK(x) 0
  
 +#ifndef S_IRWXG
  #define S_IRGRP 0
  #define S_IWGRP 0
  #define S_IXGRP 0
  #define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
 +#endif
 +#ifndef S_IRWXO
  #define S_IROTH 0
  #define S_IWOTH 0
  #define S_IXOTH 0
  #define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
 +#endif
  
  #define S_ISUID 0004000
  #define S_ISGID 0002000
@@@ -116,10 -100,8 +116,10 @@@ static inline int symlink(const char *o
  { 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)
@@@ -142,6 -124,7 +142,7 @@@ static inline int fcntl(int fd, int cmd
  #define sigemptyset(x) (void)0
  static inline int sigaddset(sigset_t *set, int signum)
  { return 0; }
+ #define SIG_BLOCK 0
  #define SIG_UNBLOCK 0
  static inline int sigprocmask(int how, const sigset_t *set, sigset_t *oldset)
  { return 0; }
@@@ -194,10 -177,8 +195,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);
@@@ -321,10 -302,8 +322,10 @@@ static inline int getrlimit(int resourc
  /*
   * 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
@@@ -396,26 -375,19 +397,26 @@@ static inline char *mingw_find_last_dir
                        ret = (char *)path;
        return ret;
  }
 +static inline void convert_slashes(char *path)
 +{
 +      for (; *path; path++)
 +              if (*path == '\\')
 +                      *path = '/';
 +}
  #define find_last_dir_sep mingw_find_last_dir_sep
  int mingw_offset_1st_component(const char *path);
  #define offset_1st_component mingw_offset_1st_component
  #define PATH_SEP ';'
 +#if !defined(__MINGW64_VERSION_MAJOR) && (!defined(_MSC_VER) || _MSC_VER < 1800)
  #define PRIuMAX "I64u"
  #define PRId64 "I64d"
 +#else
 +#include <inttypes.h>
 +#endif
  
  void mingw_open_html(const char *path);
  #define open_html mingw_open_html
  
 -void mingw_mark_as_git_dir(const char *dir);
 -#define mark_as_git_dir mingw_mark_as_git_dir
 -
  /**
   * Converts UTF-8 encoded string to UTF-16LE.
   *
diff --combined compat/win32/pthread.h
index b6ed9e74621fe0bc506beb893e477bff26e88756,7eac560d85a2a10f63673e763fa47203af216f4b..1c164088fbb64d2f0143f536f3186f481d876d28
   */
  #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_lock EnterCriticalSection
  #define pthread_mutex_unlock LeaveCriticalSection
@@@ -78,9 -75,9 +78,9 @@@ extern int win32_pthread_join(pthread_
  #define pthread_equal(t1, t2) ((t1).tid == (t2).tid)
  extern pthread_t pthread_self(void);
  
 -static inline int pthread_exit(void *ret)
 +static inline void NORETURN pthread_exit(void *ret)
  {
 -      ExitThread((DWORD)ret);
 +      ExitThread((DWORD)(intptr_t)ret);
  }
  
  typedef DWORD pthread_key_t;
@@@ -104,4 -101,11 +104,11 @@@ static inline void *pthread_getspecific
        return TlsGetValue(key);
  }
  
+ #ifndef __MINGW64_VERSION_MAJOR
+ static inline int pthread_sigmask(int how, const sigset_t *set, sigset_t *oset)
+ {
+       return 0;
+ }
+ #endif
  #endif /* PTHREAD_H */