diff options
Diffstat (limited to 'compat')
-rw-r--r-- | compat/gmtime.c | 29 | ||||
-rw-r--r-- | compat/mingw.c | 17 | ||||
-rw-r--r-- | compat/mingw.h | 3 | ||||
-rwxr-xr-x[-rw-r--r--] | compat/vcbuild/scripts/clink.pl | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | compat/vcbuild/scripts/lib.pl | 0 |
5 files changed, 29 insertions, 20 deletions
diff --git a/compat/gmtime.c b/compat/gmtime.c new file mode 100644 index 0000000000..e8362dd2b9 --- /dev/null +++ b/compat/gmtime.c @@ -0,0 +1,29 @@ +#include "../git-compat-util.h" +#undef gmtime +#undef gmtime_r + +struct tm *git_gmtime(const time_t *timep) +{ + static struct tm result; + return git_gmtime_r(timep, &result); +} + +struct tm *git_gmtime_r(const time_t *timep, struct tm *result) +{ + struct tm *ret; + + memset(result, 0, sizeof(*result)); + ret = gmtime_r(timep, result); + + /* + * Rather than NULL, FreeBSD gmtime simply leaves the "struct tm" + * untouched when it encounters overflow. Since "mday" cannot otherwise + * be zero, we can test this very quickly. + */ + if (ret && !ret->tm_mday) { + ret = NULL; + errno = EOVERFLOW; + } + + return ret; +} diff --git a/compat/mingw.c b/compat/mingw.c index fecb98bcff..e9892f8ee4 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -304,23 +304,6 @@ int mingw_open (const char *filename, int oflags, ...) return fd; } -#undef write -ssize_t mingw_write(int fd, const void *buf, size_t count) -{ - /* - * While write() calls to a file on a local disk are translated - * into WriteFile() calls with a maximum size of 64KB on Windows - * XP and 256KB on Vista, no such cap is placed on writes to - * files over the network on Windows XP. Unfortunately, there - * seems to be a limit of 32MB-28KB on X64 and 64MB-32KB on x86; - * bigger writes fail on Windows XP. - * So we cap to a nice 31MB here to avoid write failures over - * the net without changing the number of WriteFile() calls in - * the local case. - */ - return write(fd, buf, min(count, 31 * 1024 * 1024)); -} - static BOOL WINAPI ctrl_ignore(DWORD type) { return TRUE; diff --git a/compat/mingw.h b/compat/mingw.h index 92cd728d3d..e033e720c9 100644 --- a/compat/mingw.h +++ b/compat/mingw.h @@ -180,9 +180,6 @@ int mingw_rmdir(const char *path); int mingw_open (const char *filename, int oflags, ...); #define open mingw_open -ssize_t mingw_write(int fd, const void *buf, size_t count); -#define write mingw_write - int mingw_fgetc(FILE *stream); #define fgetc mingw_fgetc diff --git a/compat/vcbuild/scripts/clink.pl b/compat/vcbuild/scripts/clink.pl index 4374771df2..4374771df2 100644..100755 --- a/compat/vcbuild/scripts/clink.pl +++ b/compat/vcbuild/scripts/clink.pl diff --git a/compat/vcbuild/scripts/lib.pl b/compat/vcbuild/scripts/lib.pl index d8054e469f..d8054e469f 100644..100755 --- a/compat/vcbuild/scripts/lib.pl +++ b/compat/vcbuild/scripts/lib.pl |