rcx

library of miscellaneous bits of C code
git clone git://git.rr3.xyz/rcx
Log | Files | Refs | README | LICENSE

commit 6515b984afa17541af56c816e454524311e04fd9
parent 131dddce750beae49daa3d26c2057a7caa44eff9
Author: robert <robertrussell.72001@gmail.com>
Date:   Fri, 19 Aug 2022 19:43:00 -0700

Reorganize 128 bit defs

Diffstat:
Minc/cext/def.h | 27+++++++++++++++------------
1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/inc/cext/def.h b/inc/cext/def.h @@ -21,6 +21,10 @@ #define unlikely(x) (x) #endif +#if !defined(__STRICT_ANSI__) && defined(__SIZEOF_INT128__) +#define CEXT_HAVE_128 1 +#endif + /* Here, roughly speaking, "word" means the largest unit that the machine can * operate on in one instruction (typically the same width as registers and * the bus). This detection is probably wrong on some weird machines, but this @@ -66,6 +70,12 @@ typedef int32_t i32; #define I64_C INT64_C typedef int64_t i64; +#ifdef CEXT_HAVE_128 +#define I128_MIN ((i128)-1 - I128_MAX) +#define I128_MAX ((i128)(U128_MAX >> 1)) +typedef __int128 i128; +#endif + #define IMAX_MIN INTMAX_MIN #define IMAX_MAX INTMAX_MAX #define IMAX_C INTMAX_C @@ -109,6 +119,11 @@ typedef uint32_t u32; #define U64_C UINT64_C typedef uint64_t u64; +#ifdef CEXT_HAVE_128 +#define U128_MAX (((u128)U64_MAX << 64) | U64_MAX) +typedef unsigned __int128 u128; +#endif + #define UMAX_MAX UINTMAX_MAX #define UMAX_C UINTMAX_C typedef uintmax_t umax; @@ -127,18 +142,6 @@ typedef size_t usize; #endif typedef uintptr_t uword; -#if !defined(__STRICT_ANSI__) && defined(__SIZEOF_INT128__) -#define CEXT_HAVE_128 1 - -#define I128_MIN ((i128)-1 - I128_MAX) -#define I128_MAX ((i128)(U128_MAX >> 1)) -typedef __int128 i128; - -#define U128_MAX (((u128)U64_MAX << 64) | U64_MAX) -typedef unsigned __int128 u128; - -#endif - #define RUNE_BAD RUNE_C(0xFFFD) #define RUNE_MAX RUNE_C(0x10FFFF) #define RUNE_C UINT32_C