Make git compile under MinGW.
[git/mingw.git] / compat / mingw.c
blob0f7077983f9f4d8bccb97da8d168eefc01f147c3
1 #include <stdint.h>
2 #include "../git-compat-util.h"
4 int readlink(const char *path, char *buf, size_t bufsiz)
6 errno = EINVAL;
7 return -1;
10 int symlink(const char *oldpath, const char *newpath)
12 errno = EFAULT;
13 return -1;
16 int fchmod(int fildes, mode_t mode)
18 errno = EBADF;
19 return -1;
22 int lstat(const char *file_name, struct stat *buf)
24 return stat(file_name, buf);
27 /* missing: link, mkstemp, fchmod, getuid (?), gettimeofday */
28 int socketpair(int d, int type, int protocol, int sv[2])
30 return -1;
32 int syslog(int type, char *bufp, ...)
34 return -1;
36 unsigned int alarm(unsigned int seconds)
38 return 0;
40 #include <winsock2.h>
41 int fork()
43 return -1;
45 typedef int pid_t;
46 pid_t waitpid(pid_t pid, int *status, int options)
48 errno = ECHILD;
49 return -1;
52 int kill(pid_t pid, int sig)
54 return -1;
56 int sigaction(int p1, const struct sigaction *p2, struct sigaction *p3)
58 return -1;
60 int sigemptyset(sigset_t *p1)
62 return -1;
64 int setitimer(int __which, const struct itimerval *__value,
65 struct itimerval *__ovalue)
67 return -1;
69 unsigned int sleep (unsigned int __seconds)
71 return 0;
73 const char *inet_ntop(int af, const void *src,
74 char *dst, size_t cnt)
76 return NULL;
78 int mkstemp (char *__template)
80 return -1;
82 int gettimeofday(struct timeval *tv, void *tz)
84 return -1;
86 int pipe(int filedes[2])
88 return -1;
91 int poll(struct pollfd *ufds, unsigned int nfds, int timeout)
93 return -1;
96 int fnmatch(const char *pattern, const char *string, int flags)
98 return -1;
101 int regcomp(regex_t *preg, const char *regex, int cflags)
103 return -1;
105 size_t regerror(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size)
107 return 0;
109 void regfree(regex_t *preg)
113 int regexec(const regex_t *preg, const char *string, size_t nmatch, regmatch_t pmatch[], int eflags)
115 return -1;
118 #undef mkdir
119 int git_mkdir(const char *path, int mode)
121 return mkdir(path);
124 #include <time.h>
126 struct tm *gmtime_r(const time_t *timep, struct tm *result)
128 memcpy(result, gmtime(timep), sizeof(struct tm));
129 return result;
132 struct tm *localtime_r(const time_t *timep, struct tm *result)
134 memcpy(result, localtime(timep), sizeof(struct tm));
135 return result;
138 #undef getcwd
139 char *mingw_getcwd(char *pointer, int len)
141 char *ret = getcwd(pointer, len);
142 if (!ret)
143 return ret;
144 if (pointer[0] != 0 && pointer[1] == ':') {
145 int i;
146 pointer[1] = pointer[0];
147 pointer[0] = '/';
148 for (i = 2; pointer[i]; i++)
149 /* Thanks, Bill. You'll burn in hell for that. */
150 if (pointer[i] == '\\')
151 pointer[i] = '/';
153 return ret;
155 const char *strptime(char *buf, const char *format, struct tm *tm)
157 die("MinGW does not yet support strptime!");
159 void sync(void)
162 void openlog(const char *ident, int option, int facility)