Initial pass at using int64_t instead of long long Even on systems without C99 where long long and stdint are both missing, we can shim stdint and point it to any compiler-specific type (i.e long long, _int64, etc.). Also next is constant suffixes and determining what needs to include stdint.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
diff --git a/src/hash/sha1/generic.h b/src/hash/sha1/generic.h
index e4cc602..53fc082 100644
--- a/src/hash/sha1/generic.h
+++ b/src/hash/sha1/generic.h
@@ -11,7 +11,7 @@
#include "hash/sha1.h"
struct git_hash_sha1_ctx {
- unsigned long long size;
+ uint64_t size;
unsigned int H[5];
unsigned int W[16];
};
diff --git a/src/integer.h b/src/integer.h
index a3a0f53..6327717 100644
--- a/src/integer.h
+++ b/src/integer.h
@@ -43,10 +43,10 @@ GIT_INLINE(int) git__is_ulong(int64_t p)
}
/** @return true if p fits into the range of an int */
-GIT_INLINE(int) git__is_int(long long p)
+GIT_INLINE(int) git__is_int(int64_t p)
{
int r = (int)p;
- return p == (long long)r;
+ return p == (int64_t)r;
}
/* Use clang/gcc compiler intrinsics whenever possible */
diff --git a/src/khash.h b/src/khash.h
index 40e2d18..5066b58 100644
--- a/src/khash.h
+++ b/src/khash.h
@@ -137,11 +137,7 @@ typedef unsigned int khint32_t;
typedef unsigned long khint32_t;
#endif
-#if ULONG_MAX == ULLONG_MAX
-typedef unsigned long khint64_t;
-#else
-typedef unsigned long long khint64_t;
-#endif
+typedef int64_t khint64_t;
#ifndef kh_inline
#ifdef _MSC_VER
diff --git a/src/win32/w32_util.h b/src/win32/w32_util.h
index d7f9d3d..060504e 100644
--- a/src/win32/w32_util.h
+++ b/src/win32/w32_util.h
@@ -74,7 +74,7 @@ GIT_INLINE(void) git_win32__filetime_to_timespec(
const FILETIME *ft,
struct timespec *ts)
{
- long long winTime = ((long long)ft->dwHighDateTime << 32) + ft->dwLowDateTime;
+ int64_t winTime = ((int64_t)ft->dwHighDateTime << 32) + ft->dwLowDateTime;
winTime -= 116444736000000000LL; /* Windows to Unix Epoch conversion */
ts->tv_sec = (time_t)(winTime / 10000000);
#ifdef GIT_USE_NSEC
@@ -87,7 +87,7 @@ GIT_INLINE(void) git_win32__filetime_to_timespec(
GIT_INLINE(void) git_win32__timeval_to_filetime(
FILETIME *ft, const struct p_timeval tv)
{
- long long ticks = (tv.tv_sec * 10000000LL) +
+ int64_t ticks = (tv.tv_sec * 10000000LL) +
(tv.tv_usec * 10LL) + 116444736000000000LL;
ft->dwHighDateTime = ((ticks >> 32) & 0xffffffffLL);