From aeb8ed53e41af8a030c03963ecc9489a6814a605 Mon Sep 17 00:00:00 2001 From: George Koehler Date: Thu, 12 Sep 2019 13:40:07 -0400 Subject: [PATCH] Define _EM_LLSIZE, int64_t, uint64_t for linux386. Also change UINT32_MAX in from 4294967295 to 4294967295U. The U suffix avoids a promotion to long or unsigned long if it would fit in unsigned int. Define _EM_LLSIZE but not EM_LLSIZE. The leading underscore is a convention for such macros. If code always uses _EM_LLSIZE, we will never need to add EM_LLSIZE. The flag -D_EM_LLSIZE={q} is in plat/linux386/descr, not lib/descr/fe, so platforms without long long don't define _EM_LLSIZE. doesn't keep the old code for _EM_LSIZE == 8, because I change it to _EM_LLSIZE == 8. No platform had _EM_LSIZE == 8, and the old limits like INT64_MAX were wrong. --- lang/cem/libcc.ansi/headers/stdint.h | 16 ++++++++-------- plat/linux386/descr | 6 ++++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lang/cem/libcc.ansi/headers/stdint.h b/lang/cem/libcc.ansi/headers/stdint.h index e2eb4c201..e21b48d7a 100644 --- a/lang/cem/libcc.ansi/headers/stdint.h +++ b/lang/cem/libcc.ansi/headers/stdint.h @@ -33,16 +33,16 @@ typedef unsigned long uint32_t; #endif #define INT32_MAX 2147483647 #define INT32_MIN (-2147483648) -#define UINT32_MAX 4294967295 +#define UINT32_MAX 4294967295U -/* We only get int64_t if longs are 8 bytes. */ +/* We only get int64_t if long longs are 8 bytes. */ -#if _EM_LSIZE == 8 -typedef signed long int64_t; -typedef unsigned long uint64_t; -#define INT64_MAX 2147483647LL -#define INT64_MIN (-2147483648LL) -#define UINT64_MAX 4294967295ULL +#if _EM_LLSIZE == 8 +typedef signed long long int64_t; +typedef unsigned long long uint64_t; +#define INT64_MAX 9223372036854775807LL +#define INT64_MIN (-9223372036854775808LL) +#define UINT64_MAX 18446744073709551615ULL typedef int64_t intmax_t; typedef uint64_t uintmax_t; diff --git a/plat/linux386/descr b/plat/linux386/descr index 8a7dc5f47..9ae17a548 100644 --- a/plat/linux386/descr +++ b/plat/linux386/descr @@ -10,6 +10,8 @@ var s=2 var sa={s} var l={w} var la={w} +var q=8 +var qa=4 var f={w} var fa={w} var d=8 @@ -19,12 +21,12 @@ var xa={x} var ARCH=i386 var PLATFORM=linux386 var PLATFORMDIR={EM}/share/ack/{PLATFORM} -var CPP_F=-D__unix +var CPP_F=-D__unix -D_EM_LLSIZE={q} var ALIGN=-a0:4 -a1:4 -a2:4 -a3:4 -b0:0x08048054 var C_LIB={PLATFORMDIR}/libc-ansi.a # bitfields reversed for compatibility with (g)cc. # long long enabled. -var CC_ALIGN=-Vrq8.4 +var CC_ALIGN=-Vrq{q}.{qa} var OLD_C_LIB={C_LIB} var MACHOPT_F=-m10 var EGO_PLAT_FLAGS=-M{EM}/share/ack/ego/{ARCH}.descr