]> git.proxmox.com Git - libgit2.git/commitdiff
win32: introduce p_timeval that isn't stupid
authorEdward Thomson <ethomson@github.com>
Thu, 11 Feb 2016 20:24:21 +0000 (12:24 -0800)
committerEdward Thomson <ethomson@github.com>
Fri, 12 Feb 2016 18:34:15 +0000 (10:34 -0800)
Windows defines `timeval` with `long`, which we cannot
sanely cope with.  Instead, use a custom timeval struct.

src/unix/posix.h
src/win32/posix.h
src/win32/posix_w32.c
src/win32/w32_util.h
src/win32/win32-compat.h
tests/checkout/checkout_helpers.c
tests/core/posix.c
tests/diff/workdir.c
tests/index/racy.c
tests/merge/workdir/dirty.c

index 6633689bcfcaaa28538d4dd5fe95754eaa824c20..83edf2b7ec701c5015a16bbd7420dc03346990fa 100644 (file)
@@ -52,8 +52,10 @@ extern char *p_realpath(const char *, char *);
 #define p_localtime_r(c, r) localtime_r(c, r)
 #define p_gmtime_r(c, r) gmtime_r(c, r)
 
+#define p_timeval timeval
+
 #ifdef HAVE_FUTIMENS
-GIT_INLINE(int) p_futimes(int f, const struct timeval t[2])
+GIT_INLINE(int) p_futimes(int f, const struct p_timeval t[2])
 {
        struct timespec s[2];
        s[0].tv_sec = t[0].tv_sec;
index ac98fd864eda574f69e664c545d83d1e2a0b6283..732128bb0b9326c162f94a6b13537518dd3152c9 100644 (file)
@@ -9,6 +9,7 @@
 
 #include "common.h"
 #include "../posix.h"
+#include "win32-compat.h"
 #include "path_w32.h"
 #include "utf-conv.h"
 #include "dir.h"
@@ -20,8 +21,8 @@ typedef SOCKET GIT_SOCKET;
 extern int p_lstat(const char *file_name, struct stat *buf);
 extern int p_stat(const char* path, struct stat* buf);
 
-extern int p_utimes(const char *filename, const struct timeval times[2]);
-extern int p_futimes(int fd, const struct timeval times[2]);
+extern int p_utimes(const char *filename, const struct p_timeval times[2]);
+extern int p_futimes(int fd, const struct p_timeval times[2]);
 
 extern int p_readlink(const char *path, char *buf, size_t bufsiz);
 extern int p_symlink(const char *old, const char *new);
index 414cb4701ec4a6b576635a6285fae35a349ce05f..d743e8fc82dee409bf30614c92cfadf0d48fbc4c 100644 (file)
@@ -210,7 +210,7 @@ int p_lstat_posixly(const char *filename, struct stat *buf)
        return do_lstat(filename, buf, true);
 }
 
-int p_utimes(const char *filename, const struct timeval times[2])
+int p_utimes(const char *filename, const struct p_timeval times[2])
 {
        int fd, error;
 
@@ -223,7 +223,7 @@ int p_utimes(const char *filename, const struct timeval times[2])
        return error;
 }
 
-int p_futimes(int fd, const struct timeval times[2])
+int p_futimes(int fd, const struct p_timeval times[2])
 {
        HANDLE handle;
        FILETIME atime = {0}, mtime = {0};
index 727ed1cef2aa62f6be4b08234170b884a305f7fc..b095939a1a49b1285e40fcf7ba2bf039fa00f277 100644 (file)
@@ -96,7 +96,7 @@ GIT_INLINE(void) git_win32__filetime_to_timespec(
 }
 
 GIT_INLINE(void) git_win32__timeval_to_filetime(
-       FILETIME *ft, const struct timeval tv)
+       FILETIME *ft, const struct p_timeval tv)
 {
        long long ticks = (tv.tv_sec * 10000000LL) +
                (tv.tv_usec * 10LL) + 116444736000000000LL;
index d3a5b68a35ae2a86b6f7f840185d46c7c8eb57e3..dff1f45bef42520e9ad0163780894c454181af84 100644 (file)
 #include <sys/stat.h>
 #include <sys/types.h>
 
+typedef long suseconds_t;
+
+struct p_timeval {
+       time_t tv_sec;
+       suseconds_t tv_usec;
+};
+
 struct p_timespec {
        time_t tv_sec;
        long tv_nsec;
index fb2f415e78e074d83570f8f15812fb3ae7cc2d89..d7d24f33f4ce8237323c7b5764916443e05036b1 100644 (file)
@@ -133,7 +133,7 @@ int checkout_count_callback(
 void tick_index(git_index *index)
 {
        struct timespec ts;
-       struct timeval times[2];
+       struct p_timeval times[2];
 
        cl_assert(index->on_disk);
        cl_assert(git_index_path(index));
index 5a9e24899f9ad59c6d40585860e09667e1c4ffa6..34a67bf47b533f92ceeeb3a3e6f440360e2ccfe4 100644 (file)
@@ -100,7 +100,7 @@ void test_core_posix__inet_pton(void)
 
 void test_core_posix__utimes(void)
 {
-       struct timeval times[2];
+       struct p_timeval times[2];
        struct stat st;
        time_t curtime;
        int fd;
index 4c782339ddf4c509d0fae4fa1e285cd76765a0d6..892c7b72d9ff38d1245a9373a5fd1207a3ea55ef 100644 (file)
@@ -1755,7 +1755,7 @@ void test_diff_workdir__with_stale_index(void)
 static int touch_file(void *payload, git_buf *path)
 {
        struct stat st;
-       struct timeval times[2];
+       struct p_timeval times[2];
 
        GIT_UNUSED(payload);
        if (git_path_isdir(path->ptr))
@@ -2006,7 +2006,7 @@ void test_diff_workdir__only_writes_index_when_necessary(void)
        git_oid initial, first, second;
        git_buf path = GIT_BUF_INIT;
        struct stat st;
-       struct timeval times[2];
+       struct p_timeval times[2];
 
        opts.flags |= GIT_DIFF_INCLUDE_UNTRACKED | GIT_DIFF_UPDATE_INDEX;
 
index e2275ea14305ca9ad3f7af974914550078bc26e6..ace84d58599e4fed2c2bc7abe02ced9ceec1703f 100644 (file)
@@ -54,7 +54,7 @@ void test_index_racy__write_index_just_after_file(void)
        git_index *index;
        git_diff *diff;
        git_buf path = GIT_BUF_INIT;
-       struct timeval times[2];
+       struct p_timeval times[2];
 
        /* Make sure we do have a timestamp */
        cl_git_pass(git_repository_index(&index, g_repo));
index 994a1d813ac357dfbfa51102efe17c7d51799dac..99e33e0cde75b93994595618b15c3af26185f475 100644 (file)
@@ -133,7 +133,7 @@ static void hack_index(char *files[])
        struct stat statbuf;
        git_buf path = GIT_BUF_INIT;
        git_index_entry *entry;
-       struct timeval times[2];
+       struct p_timeval times[2];
        time_t now;
        size_t i;