From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1879) id 59B033858435; Wed, 21 Feb 2024 18:31:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 59B033858435 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1708540294; bh=PDROT0zByV2xsgrpwfcx0KTxhnXe3pMi5F6IKy3J/JE=; h=From:To:Subject:Date:From; b=pXZXTW78KiqwfIW94PhRBaB/mHfuD20ynnQUa1IxyfFN/0v6bg8lMNma2RYGxR+f4 cPygkhs5iGPIcpX3z8OoHFxvaa1boD93LgvkcapXrUAqDeqXRb4EmqKtiAOGEQqFTq Hoc+EpNZqLeb197VsHVkh2Jm0YyzcnFfAn8A2vOQ= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Simon Marchi To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdbsupport: assume that compiler supports std::{is_trivially_constructible,is_trivially_copyable} X-Act-Checkin: binutils-gdb X-Git-Author: Simon Marchi X-Git-Refname: refs/heads/master X-Git-Oldrev: aca8a74923c4a0c222a2f8f5f3e23de84ab19e77 X-Git-Newrev: 23acbfee6a82cc147b04b74a89d5b34b47c150f4 Message-Id: <20240221183134.59B033858435@sourceware.org> Date: Wed, 21 Feb 2024 18:31:34 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D23acbfee6a82= cc147b04b74a89d5b34b47c150f4 commit 23acbfee6a82cc147b04b74a89d5b34b47c150f4 Author: Simon Marchi Date: Wed Feb 21 11:46:52 2024 -0500 gdbsupport: assume that compiler supports std::{is_trivially_constructi= ble,is_trivially_copyable} =20 This code was there to support g++ 4, which didn't support std::is_trivially_constructible and std::is_trivially_copyable. Since we now require g++ >=3D 9, I think it's fair to assume that GDB will always be compiled with a compiler that supports those. =20 Change-Id: Ie7c1649139a2f48bf662cac92d7f3e38fb1f1ba1 Diff: --- gdb/trad-frame.c | 2 -- gdb/unittests/array-view-selftests.c | 4 ---- gdb/unittests/enum-flags-selftests.c | 4 ---- gdb/unittests/packed-selftests.c | 4 ---- gdbsupport/check-defines.el | 2 -- gdbsupport/packed.h | 2 -- gdbsupport/poison.h | 8 -------- gdbsupport/traits.h | 21 --------------------- 8 files changed, 47 deletions(-) diff --git a/gdb/trad-frame.c b/gdb/trad-frame.c index 8b63927b133..c35e08ab280 100644 --- a/gdb/trad-frame.c +++ b/gdb/trad-frame.c @@ -61,9 +61,7 @@ trad_frame_reset_saved_regs (struct gdbarch *gdbarch, trad_frame_saved_reg * trad_frame_alloc_saved_regs (struct gdbarch *gdbarch) { -#ifdef HAVE_IS_TRIVIALLY_CONSTRUCTIBLE static_assert (std::is_trivially_constructible::va= lue); -#endif =20 int numregs =3D gdbarch_num_cooked_regs (gdbarch); trad_frame_saved_reg *this_saved_regs diff --git a/gdb/unittests/array-view-selftests.c b/gdb/unittests/array-vie= w-selftests.c index 9d2448fefc1..299318ace43 100644 --- a/gdb/unittests/array-view-selftests.c +++ b/gdb/unittests/array-view-selftests.c @@ -30,15 +30,11 @@ namespace array_view_tests { #define CHECK_TRAIT(TRAIT) \ static_assert (std::TRAIT>::value, "") =20 -#if HAVE_IS_TRIVIALLY_COPYABLE - CHECK_TRAIT (is_trivially_copyable); CHECK_TRAIT (is_trivially_move_assignable); CHECK_TRAIT (is_trivially_move_constructible); CHECK_TRAIT (is_trivially_destructible); =20 -#endif - #undef CHECK_TRAIT =20 /* Wrapper around std::is_convertible to make the code using it a bit diff --git a/gdb/unittests/enum-flags-selftests.c b/gdb/unittests/enum-flag= s-selftests.c index 607b8ac66a6..54e168173de 100644 --- a/gdb/unittests/enum-flags-selftests.c +++ b/gdb/unittests/enum-flags-selftests.c @@ -63,14 +63,10 @@ DEF_ENUM_FLAGS_TYPE (RE, EF); DEF_ENUM_FLAGS_TYPE (RE2, EF2); DEF_ENUM_FLAGS_TYPE (URE, UEF); =20 -#if HAVE_IS_TRIVIALLY_COPYABLE - /* So that std::vectors of types that have enum_flags fields can reallocate efficiently memcpy. */ static_assert (std::is_trivially_copyable::value); =20 -#endif - /* A couple globals used as lvalues in the CHECK_VALID expressions below. Their names (and types) match the uppercase type names exposed by CHECK_VALID just to make the expressions easier to diff --git a/gdb/unittests/packed-selftests.c b/gdb/unittests/packed-selfte= sts.c index 3f20861ad4a..852a7d364ce 100644 --- a/gdb/unittests/packed-selftests.c +++ b/gdb/unittests/packed-selftests.c @@ -46,16 +46,12 @@ static_assert (alignof (packed) =3D=3D 1); #define CHECK_TRAIT(TRAIT) \ static_assert (std::TRAIT>::value, "") =20 -#if HAVE_IS_TRIVIALLY_COPYABLE - CHECK_TRAIT (is_trivially_copyable); CHECK_TRAIT (is_trivially_copy_constructible); CHECK_TRAIT (is_trivially_move_constructible); CHECK_TRAIT (is_trivially_copy_assignable); CHECK_TRAIT (is_trivially_move_assignable); =20 -#endif - #undef CHECK_TRAIT =20 /* Entry point. */ diff --git a/gdbsupport/check-defines.el b/gdbsupport/check-defines.el index 7603effc29d..b7cf61ba859 100644 --- a/gdbsupport/check-defines.el +++ b/gdbsupport/check-defines.el @@ -35,8 +35,6 @@ (put (intern "HAVE_USEFUL_SBRK") :check-ok t) (put (intern "HAVE_SOCKETS") :check-ok t) (put (intern "HAVE_F_GETFD") :check-ok t) -(put (intern "HAVE_IS_TRIVIALLY_COPYABLE") :check-ok t) -(put (intern "HAVE_IS_TRIVIALLY_CONSTRUCTIBLE") :check-ok t) (put (intern "HAVE_DOS_BASED_FILE_SYSTEM") :check-ok t) =20 (defun check-read-config.in (file) diff --git a/gdbsupport/packed.h b/gdbsupport/packed.h index 8035535386b..5c817d4c9cc 100644 --- a/gdbsupport/packed.h +++ b/gdbsupport/packed.h @@ -80,9 +80,7 @@ public: static_assert (alignof (packed) =3D=3D 1); =20 /* Make sure packed can be wrapped with std::atomic. */ -#if HAVE_IS_TRIVIALLY_COPYABLE static_assert (std::is_trivially_copyable::value); -#endif static_assert (std::is_copy_constructible::value); static_assert (std::is_move_constructible::value); static_assert (std::is_copy_assignable::value); diff --git a/gdbsupport/poison.h b/gdbsupport/poison.h index 0d0159eb7f8..7b4f8e8a178 100644 --- a/gdbsupport/poison.h +++ b/gdbsupport/poison.h @@ -56,8 +56,6 @@ template >>> void *memset (T *s, int c, size_t n) =3D delete; =20 -#if HAVE_IS_TRIVIALLY_COPYABLE - /* Similarly, poison memcpy and memmove of non trivially-copyable types, which is undefined. */ =20 @@ -83,17 +81,11 @@ template >>> void *memmove (D *dest, const S *src, size_t n) =3D delete; =20 -#endif /* HAVE_IS_TRIVIALLY_COPYABLE */ - /* Poison XNEW and friends to catch usages of malloc-style allocations on objects that require new/delete. */ =20 template -#if HAVE_IS_TRIVIALLY_CONSTRUCTIBLE using IsMallocable =3D std::is_trivially_constructible; -#else -using IsMallocable =3D std::true_type; -#endif =20 template using IsFreeable =3D gdb::Or, std::is_vo= id>; diff --git a/gdbsupport/traits.h b/gdbsupport/traits.h index eb97b965990..92fe59f34af 100644 --- a/gdbsupport/traits.h +++ b/gdbsupport/traits.h @@ -20,27 +20,6 @@ =20 #include =20 -/* GCC does not understand __has_feature. */ -#if !defined(__has_feature) -# define __has_feature(x) 0 -#endif - -/* HAVE_IS_TRIVIALLY_COPYABLE is defined as 1 iff - std::is_trivially_copyable is available. GCC only implemented it - in GCC 5. */ -#if (__has_feature(is_trivially_copyable) \ - || (defined __GNUC__ && __GNUC__ >=3D 5)) -# define HAVE_IS_TRIVIALLY_COPYABLE 1 -#endif - -/* HAVE_IS_TRIVIALLY_CONSTRUCTIBLE is defined as 1 iff - std::is_trivially_constructible is available. GCC only implemented it - in GCC 5. */ -#if (__has_feature(is_trivially_constructible) \ - || (defined __GNUC__ && __GNUC__ >=3D 5)) -# define HAVE_IS_TRIVIALLY_CONSTRUCTIBLE 1 -#endif - namespace gdb { =20 /* Implementation of the detection idiom: