Skip to content

Commit 968113c

Browse files
committed
don't try to use 128-bit types on 32-bit platforms
1 parent 973fbb0 commit 968113c

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

libkd/kdint_ttype_l.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,27 @@
55

66
typedef u64 ttype;
77

8+
// https://stackoverflow.com/questions/16088282/is-there-a-128-bit-integer-in-gcc
9+
// gcc: 128-bit ints only available on 64-bit platforms, not 32-bit
10+
#ifdef __SIZEOF_INT128__
811
// GCC only??
912
typedef __int128 int128_t;
1013
typedef unsigned __int128 uint128_t;
1114
static const uint128_t UINT128_MAX = (uint128_t)((int128_t)(-1L));
12-
1315
#define BIGTTYPE uint128_t
1416
#define BIGTTYPE_MAX UINT128_MAX
1517
typedef uint128_t bigttype;
1618

19+
#else
20+
// Fall back to using just 64-bit types. This *should* still work okay, because
21+
// we're careful to check the max possible value before using BIGT types; search
22+
// for "use_tmath" in the code.
23+
#define BIGTTYPE uint64_t
24+
#define BIGTTYPE_MAX UINT64_MAX
25+
typedef uint64_t bigttype;
26+
27+
#endif
28+
1729
#define TTYPE_INTEGER 1
1830

1931
#define TTYPE_MIN 0

0 commit comments

Comments
 (0)