aboutsummaryrefslogtreecommitdiff
path: root/compat/mingw.c
diff options
context:
space:
mode:
authorJohannes Sixt <johannes.sixt@telecom.at>2007-12-01 21:24:59 +0100
committerJohannes Sixt <johannes.sixt@telecom.at>2008-06-22 11:32:45 +0200
commitf4626df51f63d53b89ff01de54cbf7558217ea2b (patch)
tree3f2e8f987cab6e12fcb8fa4d4a6004e60e57b053 /compat/mingw.c
parent58eda02257a89df6e05f504bdf87e578d90f3b5e (diff)
downloadgit-f4626df51f63d53b89ff01de54cbf7558217ea2b.tar.gz
git-f4626df51f63d53b89ff01de54cbf7558217ea2b.tar.xz
Add target architecture MinGW.
With this change GIT can be compiled and linked using MinGW. Builtins that only read the repository such as the log family and grep already work. Simple stubs are provided for a number of functions that the Windows C runtime does not offer. They will be completed in later patches. However, a fix for the snprintf/vsnprintf replacement is applied here to avoid buffer overflows. Dmitry Kakurin pointed out that access(..., X_OK) would always fails on Vista and suggested the -D__USE_MINGW_ACCESS workaround. Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Diffstat (limited to 'compat/mingw.c')
-rw-r--r--compat/mingw.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/compat/mingw.c b/compat/mingw.c
new file mode 100644
index 000000000..075448d24
--- /dev/null
+++ b/compat/mingw.c
@@ -0,0 +1,57 @@
+#include "../git-compat-util.h"
+
+unsigned int _CRT_fmode = _O_BINARY;
+
+unsigned int sleep (unsigned int seconds)
+{
+ Sleep(seconds*1000);
+ return 0;
+}
+
+int mkstemp(char *template)
+{
+ char *filename = mktemp(template);
+ if (filename == NULL)
+ return -1;
+ return open(filename, O_RDWR | O_CREAT, 0600);
+}
+
+int gettimeofday(struct timeval *tv, void *tz)
+{
+ return -1;
+}
+
+int poll(struct pollfd *ufds, unsigned int nfds, int timeout)
+{
+ return -1;
+}
+
+struct tm *gmtime_r(const time_t *timep, struct tm *result)
+{
+ /* gmtime() in MSVCRT.DLL is thread-safe, but not reentrant */
+ memcpy(result, gmtime(timep), sizeof(struct tm));
+ return result;
+}
+
+struct tm *localtime_r(const time_t *timep, struct tm *result)
+{
+ /* localtime() in MSVCRT.DLL is thread-safe, but not reentrant */
+ memcpy(result, localtime(timep), sizeof(struct tm));
+ return result;
+}
+
+struct passwd *getpwuid(int uid)
+{
+ static struct passwd p;
+ return &p;
+}
+
+int setitimer(int type, struct itimerval *in, struct itimerval *out)
+{
+ return -1;
+}
+
+int sigaction(int sig, struct sigaction *in, struct sigaction *out)
+{
+ return -1;
+}