Unverified Commit 6a7f0403 by Edward Thomson Committed by GitHub

Merge pull request #5941 from NattyNarwhal/stdintification

stdintification: use int64_t and INT64_C instead of long long
parents 36e80306 d6bea53d
......@@ -304,7 +304,7 @@ static int git_commit_graph_entry_get_byindex(
e->generation = ntohl(*((uint32_t *)(commit_data + GIT_OID_RAWSZ + 2 * sizeof(uint32_t))));
e->commit_time = ntohl(*((uint32_t *)(commit_data + GIT_OID_RAWSZ + 3 * sizeof(uint32_t))));
e->commit_time |= (e->generation & 0x3ull) << 32ull;
e->commit_time |= (e->generation & UINT64_C(0x3)) << UINT64_C(32);
e->generation >>= 2u;
if (e->parent_indices[1] & 0x80000000u) {
uint32_t extra_edge_list_pos = e->parent_indices[1] & 0x7fffffff;
......
......@@ -16,7 +16,7 @@
/* xdiff cannot cope with large files. these files should not be passed to
* xdiff. callers should treat these large files as binary.
*/
#define GIT_XDIFF_MAX_SIZE (1024LL * 1024 * 1023)
#define GIT_XDIFF_MAX_SIZE (INT64_C(1024) * 1024 * 1023)
/* A git_xdiff_output is a git_patch_generate_output with extra fields
* necessary to use libxdiff. Calling git_xdiff_init() will set the diff_cb
......
......@@ -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];
};
......
......@@ -17,7 +17,7 @@ typedef uint64_t hashsig_state;
#define HASHSIG_SCALE 100
#define HASHSIG_MAX_RUN 80
#define HASHSIG_HASH_START 0x012345678ABCDEF0LL
#define HASHSIG_HASH_START INT64_C(0x012345678ABCDEF0)
#define HASHSIG_HASH_SHIFT 5
#define HASHSIG_HASH_MIX(S,CH) \
......
......@@ -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 */
......
......@@ -131,17 +131,8 @@ int main() {
/* compiler specific configuration */
#if UINT_MAX == 0xffffffffu
typedef unsigned int khint32_t;
#elif ULONG_MAX == 0xffffffffu
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 uint32_t khint32_t;
typedef uint64_t khint64_t;
#ifndef kh_inline
#ifdef _MSC_VER
......
......@@ -20,7 +20,7 @@
: 32 * 1024 * 1024)
#define DEFAULT_MAPPED_LIMIT \
((1024 * 1024) * (sizeof(void*) >= 8 ? 8192ULL : 256UL))
((1024 * 1024) * (sizeof(void*) >= 8 ? UINT64_C(8192) : UINT64_C(256)))
/* default is unlimited */
#define DEFAULT_FILE_LIMIT 0
......
......@@ -22,7 +22,7 @@
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
#define bitsizeof(x) (CHAR_BIT * sizeof(x))
#define MSB(x, bits) ((x) & (~0ULL << (bitsizeof(x) - (bits))))
#define MSB(x, bits) ((x) & (~UINT64_C(0) << (bitsizeof(x) - (bits))))
#ifndef min
# define min(a,b) ((a) < (b) ? (a) : (b))
#endif
......
......@@ -74,8 +74,8 @@ GIT_INLINE(void) git_win32__filetime_to_timespec(
const FILETIME *ft,
struct timespec *ts)
{
long long winTime = ((long long)ft->dwHighDateTime << 32) + ft->dwLowDateTime;
winTime -= 116444736000000000LL; /* Windows to Unix Epoch conversion */
int64_t winTime = ((int64_t)ft->dwHighDateTime << 32) + ft->dwLowDateTime;
winTime -= INT64_C(116444736000000000); /* Windows to Unix Epoch conversion */
ts->tv_sec = (time_t)(winTime / 10000000);
#ifdef GIT_USE_NSEC
ts->tv_nsec = (winTime % 10000000) * 100;
......@@ -87,11 +87,11 @@ 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) +
(tv.tv_usec * 10LL) + 116444736000000000LL;
int64_t ticks = (tv.tv_sec * INT64_C(10000000)) +
(tv.tv_usec * INT64_C(10)) + INT64_C(116444736000000000);
ft->dwHighDateTime = ((ticks >> 32) & 0xffffffffLL);
ft->dwLowDateTime = (ticks & 0xffffffffLL);
ft->dwHighDateTime = ((ticks >> 32) & INT64_C(0xffffffff));
ft->dwLowDateTime = (ticks & INT64_C(0xffffffff));
}
GIT_INLINE(void) git_win32__stat_init(
......
......@@ -14,7 +14,7 @@ void test_core_encoding__decode(void)
cl_assert(size == 4);
buf = (unsigned char *)"\xaa\xaa\xfe\xdc\xbaXY";
cl_assert(git_decode_varint(buf, &size) == 1489279344088ULL);
cl_assert(git_decode_varint(buf, &size) == UINT64_C(1489279344088));
cl_assert(size == 6);
buf = (unsigned char *)"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xfe\xdc\xbaXY";
......@@ -35,8 +35,8 @@ void test_core_encoding__encode(void)
cl_assert(git_encode_varint(buf, 100, 267869656) == 4);
cl_assert(!memcmp(buf, "\xfe\xdc\xbaX", 4));
cl_assert(git_encode_varint(buf, 100, 1489279344088ULL) == 6);
cl_assert(git_encode_varint(buf, 100, UINT64_C(1489279344088)) == 6);
cl_assert(!memcmp(buf, "\xaa\xaa\xfe\xdc\xbaX", 6));
cl_assert(git_encode_varint(buf, 1, 1489279344088ULL) == -1);
cl_assert(git_encode_varint(buf, 1, UINT64_C(1489279344088)) == -1);
}
......@@ -32,7 +32,7 @@ void test_core_strtol__int32(void)
assert_l32_parses(" +123 ", 123, 10);
assert_l32_parses(" -123 ", -123, 10);
assert_l32_parses(" +2147483647 ", 2147483647, 10);
assert_l32_parses(" -2147483648 ", -2147483648LL, 10);
assert_l32_parses(" -2147483648 ", INT64_C(-2147483648), 10);
assert_l32_parses("A", 10, 16);
assert_l32_parses("1x1", 1, 10);
......@@ -49,9 +49,9 @@ void test_core_strtol__int64(void)
assert_l64_parses(" +123 ", 123, 10);
assert_l64_parses(" -123 ", -123, 10);
assert_l64_parses(" +2147483647 ", 2147483647, 10);
assert_l64_parses(" -2147483648 ", -2147483648LL, 10);
assert_l64_parses(" 2147483657 ", 2147483657LL, 10);
assert_l64_parses(" -2147483657 ", -2147483657LL, 10);
assert_l64_parses(" -2147483648 ", INT64_C(-2147483648), 10);
assert_l64_parses(" 2147483657 ", INT64_C(2147483657), 10);
assert_l64_parses(" -2147483657 ", INT64_C(-2147483657), 10);
assert_l64_parses(" 9223372036854775807 ", INT64_MAX, 10);
assert_l64_parses(" -9223372036854775808 ", INT64_MIN, 10);
assert_l64_parses(" 0x7fffffffffffffff ", INT64_MAX, 16);
......
......@@ -23,14 +23,14 @@ void test_graph_commit_graph__parse(void)
cl_git_pass(git_oid_fromstr(&id, "418382dff1ffb8bdfba833f4d8bbcde58b1e7f47"));
cl_assert_equal_oid(&e.tree_oid, &id);
cl_assert_equal_i(e.generation, 1);
cl_assert_equal_i(e.commit_time, 1273610423ull);
cl_assert_equal_i(e.commit_time, UINT64_C(1273610423));
cl_assert_equal_i(e.parent_count, 0);
cl_git_pass(git_oid_fromstr(&id, "be3563ae3f795b2b4353bcce3a527ad0a4f7f644"));
cl_git_pass(git_commit_graph_entry_find(&e, cgraph, &id, GIT_OID_HEXSZ));
cl_assert_equal_oid(&e.sha1, &id);
cl_assert_equal_i(e.generation, 5);
cl_assert_equal_i(e.commit_time, 1274813907ull);
cl_assert_equal_i(e.commit_time, UINT64_C(1274813907));
cl_assert_equal_i(e.parent_count, 2);
cl_git_pass(git_oid_fromstr(&id, "9fd738e8f7967c078dceed8190330fc8648ee56a"));
......@@ -66,7 +66,7 @@ void test_graph_commit_graph__parse_octopus_merge(void)
cl_git_pass(git_oid_fromstr(&id, "348f16ffaeb73f319a75cec5b16a0a47d2d5e27c"));
cl_assert_equal_oid(&e.tree_oid, &id);
cl_assert_equal_i(e.generation, 7);
cl_assert_equal_i(e.commit_time, 1447083009ull);
cl_assert_equal_i(e.commit_time, UINT64_C(1447083009));
cl_assert_equal_i(e.parent_count, 3);
cl_git_pass(git_oid_fromstr(&id, "ad2ace9e15f66b3d1138922e6ffdc3ea3f967fa6"));
......
......@@ -530,7 +530,7 @@ void test_revwalk_basic__big_timestamp(void)
cl_git_pass(git_reference_peel((git_object **) &tip, head, GIT_OBJECT_COMMIT));
/* Commit with a far-ahead timestamp, we should be able to parse it in the revwalk */
cl_git_pass(git_signature_new(&sig, "Joe", "joe@example.com", 2399662595ll, 0));
cl_git_pass(git_signature_new(&sig, "Joe", "joe@example.com", INT64_C(2399662595), 0));
cl_git_pass(git_commit_tree(&tree, tip));
cl_git_pass(git_commit_create(&id, _repo, "HEAD", sig, sig, NULL, "some message", tree, 1,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment