From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1256) id 952C03858D28; Fri, 10 Feb 2023 23:50:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 952C03858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676073014; bh=USUChP01jLeymCvbE97zOgxEjIaq0P+DfcTbkQwlzI8=; h=From:To:Subject:Date:From; b=aehmQNSqccB3qv1EcySUya3KbWQWA06qBUYo2KeTMxsJp7QfyFylvDn6NfKiQOUQ6 Sg7BiypxQNeUZYn0OTxgo5MklamSql1aH11xEHDhNTQfGOXeDmJG0RQlRJSd3nfsA6 guK+ZYwzXy2iFUJpltz4E6z6c/tKzHLAJQsEn4O8= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Maciej W. Rozycki To: gdb-cvs@sourceware.org Subject: [binutils-gdb] GDB: Switch to using C++ standard integer type limits X-Act-Checkin: binutils-gdb X-Git-Author: Maciej W. Rozycki X-Git-Refname: refs/heads/master X-Git-Oldrev: 5036bde964bc1a18282dde536a95aecd0d2c08fb X-Git-Newrev: 4a9efa5d63b2253a595ff9d6944415bf8cbfe408 Message-Id: <20230210235014.952C03858D28@sourceware.org> Date: Fri, 10 Feb 2023 23:50:14 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D4a9efa5d63b2= 253a595ff9d6944415bf8cbfe408 commit 4a9efa5d63b2253a595ff9d6944415bf8cbfe408 Author: Maciej W. Rozycki Date: Fri Feb 10 23:49:19 2023 +0000 GDB: Switch to using C++ standard integer type limits =20 Use instead of and ditch local fallback definitions for minimum and maximum value macros provided by C++11. Add LONGEST_MAX and LONGEST_MIN definitions. =20 Approved-By: Tom Tromey Diff: --- gdb/defs.h | 33 +-------------------------------- gdb/gnu-nat.c | 1 - gdbsupport/common-types.h | 8 +++++++- 3 files changed, 8 insertions(+), 34 deletions(-) diff --git a/gdb/defs.h b/gdb/defs.h index b6a132173fb..f4fba9acf30 100644 --- a/gdb/defs.h +++ b/gdb/defs.h @@ -37,7 +37,7 @@ #include "bfd.h" =20 #include -#include +#include =20 /* The libdecnumber library, on which GDB depends, includes a header file called gstdint.h instead of relying directly on stdint.h. GDB, on the @@ -446,37 +446,6 @@ enum val_prettyformat # include "fopen-bin.h" #endif =20 -/* Defaults for system-wide constants (if not defined by xm.h, we fake it). - FIXME: Assumes 2's complement arithmetic. */ - -#if !defined (UINT_MAX) -#define UINT_MAX ((unsigned int)(~0)) /* 0xFFFFFFFF for 32-bits */ -#endif - -#if !defined (INT_MAX) -#define INT_MAX ((int)(UINT_MAX >> 1)) /* 0x7FFFFFFF for 32-bits */ -#endif - -#if !defined (INT_MIN) -#define INT_MIN ((int)((int) ~0 ^ INT_MAX)) /* 0x80000000 for 32-bits */ -#endif - -#if !defined (ULONG_MAX) -#define ULONG_MAX ((unsigned long)(~0L)) /* 0xFFFFFFFF for 32-bits */ -#endif - -#if !defined (LONG_MAX) -#define LONG_MAX ((long)(ULONG_MAX >> 1)) /* 0x7FFFFFFF for 32-bits */ -#endif - -#if !defined (ULONGEST_MAX) -#define ULONGEST_MAX (~(ULONGEST)0) /* 0xFFFFFFFFFFFFFFFF for 64-bi= ts */ -#endif - -#if !defined (LONGEST_MAX) /* 0x7FFFFFFFFFFFFFFF for 64-bi= ts */ -#define LONGEST_MAX ((LONGEST)(ULONGEST_MAX >> 1)) -#endif - /* * Convert a LONGEST to an int. This is used in contexts (e.g. number of arguments to a function, number in a value history, register number, et= c.) where the value must not be larger than can fit in an int. */ diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c index 004cacc8180..afaec46e3c1 100644 --- a/gdb/gnu-nat.c +++ b/gdb/gnu-nat.c @@ -52,7 +52,6 @@ extern "C" #include "defs.h" =20 #include -#include #include #include #include diff --git a/gdbsupport/common-types.h b/gdbsupport/common-types.h index e863d6505ea..4156021abb4 100644 --- a/gdbsupport/common-types.h +++ b/gdbsupport/common-types.h @@ -36,9 +36,15 @@ typedef uint64_t ULONGEST; /* * The largest CORE_ADDR value. */ #define CORE_ADDR_MAX (~(CORE_ADDR) 0) =20 -/* * The largest ULONGEST value. */ +/* * The largest ULONGEST value, 0xFFFFFFFFFFFFFFFF for 64-bits. */ #define ULONGEST_MAX (~(ULONGEST) 0) =20 +/* * The largest LONGEST value, 0x7FFFFFFFFFFFFFFF for 64-bits. */ +#define LONGEST_MAX ((LONGEST) (ULONGEST_MAX >> 1)) + +/* * The smallest LONGEST value, 0x8000000000000000 for 64-bits. */ +#define LONGEST_MIN ((LONGEST) (~(LONGEST) 0 ^ LONGEST_MAX)) + enum tribool { TRIBOOL_UNKNOWN =3D -1, TRIBOOL_FALSE =3D 0, TRIBOOL_TRUE = =3D 1 }; =20 #endif /* COMMON_COMMON_TYPES_H */