From patchwork Thu Mar 7 20:56:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1909457 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=WKXfyRMr; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TrM7G6xK6z1yWx for ; Fri, 8 Mar 2024 07:57:13 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C1A34385770F for ; Thu, 7 Mar 2024 20:57:10 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id A2688385841A for ; Thu, 7 Mar 2024 20:56:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A2688385841A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A2688385841A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709845006; cv=none; b=YwAqj7TGE78ATaI1CJR4bOy0qawcwDOTKW+XLC6g9DmpnlXKoUSQMzQBRgq5St9Cv+Xt/WZP9RdFAVp18ap7xU1YL0+PFyGwGq3opjdweJSAfV/MiaYpD8shzxWXmCP7WyE9arbDfjBnkxOzTmkA8ff/uOTTRjHoTO9p+E+7NxE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709845006; c=relaxed/simple; bh=DaeCVl/g95Lij+cEqHFhPze3tKu5Z3b+GJuOj9nXiCU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=CKoMBy5XnoJ96aleIfx4ODovUUABv8NKP/DnE3oBcgKmRBZvULh7WjRYYQeqtIXHkGgd/fWNmx45IdyV3JmgP66unbgNINXSxORLX0M9QIffasH5t8aSZzn8R5ftn7RqK3eFF3+ldhqiZcIPYGtiZ2xpMS5bQo+KCOrfAN+LRRg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709845003; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=HIJDHEHEo7h+rZUpKmW6FyWf/6HnId+1J4SsLIN9/7k=; b=WKXfyRMrehv1IEcjApOfy5SjZ/8TUw5PQM6JvL9ylZgwK49i1U4b9L0AIuIK8bPcEwWwSt uWMo45OI0djzHenzoXphAysC6oeqsfUdcdy0ThtTZpk+sIL/cVplSAaU0drHKc51yvm3bH iCxBVMqLFrq12pfpq5bnLS5U4yEEjyw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-133-qGsmX5edP1GM7z2HBk14LA-1; Thu, 07 Mar 2024 15:56:39 -0500 X-MC-Unique: qGsmX5edP1GM7z2HBk14LA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9B3D28007A3; Thu, 7 Mar 2024 20:56:39 +0000 (UTC) Received: from localhost (unknown [10.42.28.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id 50445C15772; Thu, 7 Mar 2024 20:56:39 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Replace unnecessary uses of built-ins in testsuite Date: Thu, 7 Mar 2024 20:56:22 +0000 Message-ID: <20240307205638.590677-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Tested x86_64-linux. Pushed to trunk. -- >8 -- I don't see why we should rely on __builtin_memset etc. in tests. We can just include and use the public API. libstdc++-v3/ChangeLog: * testsuite/23_containers/deque/allocator/default_init.cc: Use std::memset instead of __builtin_memset. * testsuite/23_containers/forward_list/allocator/default_init.cc: Likewise. * testsuite/23_containers/list/allocator/default_init.cc: Likewise. * testsuite/23_containers/map/allocator/default_init.cc: Likewise. * testsuite/23_containers/set/allocator/default_init.cc: Likewise. * testsuite/23_containers/unordered_map/allocator/default_init.cc: Likewise. * testsuite/23_containers/unordered_set/allocator/default_init.cc: Likewise. * testsuite/23_containers/vector/allocator/default_init.cc: Likewise. * testsuite/23_containers/vector/bool/allocator/default_init.cc: Likewise. * testsuite/29_atomics/atomic/compare_exchange_padding.cc: Likewise. * testsuite/util/atomic/wait_notify_util.h: Likewise. --- .../23_containers/deque/allocator/default_init.cc | 5 +++-- .../forward_list/allocator/default_init.cc | 5 +++-- .../23_containers/list/allocator/default_init.cc | 5 +++-- .../23_containers/map/allocator/default_init.cc | 5 +++-- .../23_containers/set/allocator/default_init.cc | 5 +++-- .../unordered_map/allocator/default_init.cc | 5 +++-- .../unordered_set/allocator/default_init.cc | 5 +++-- .../23_containers/vector/allocator/default_init.cc | 5 +++-- .../vector/bool/allocator/default_init.cc | 5 +++-- .../29_atomics/atomic/compare_exchange_padding.cc | 5 +++-- libstdc++-v3/testsuite/util/atomic/wait_notify_util.h | 11 +++++------ 11 files changed, 35 insertions(+), 26 deletions(-) diff --git a/libstdc++-v3/testsuite/23_containers/deque/allocator/default_init.cc b/libstdc++-v3/testsuite/23_containers/deque/allocator/default_init.cc index ce8c6ba8114..63ada98d048 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/allocator/default_init.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/allocator/default_init.cc @@ -22,6 +22,7 @@ #include #include +#include #include using T = int; @@ -34,7 +35,7 @@ void test01() typedef std::deque test_type; __gnu_cxx::__aligned_buffer buf; - __builtin_memset(buf._M_addr(), ~0, sizeof(test_type)); + std::memset(buf._M_addr(), ~0, sizeof(test_type)); test_type *tmp = ::new(buf._M_addr()) test_type; @@ -49,7 +50,7 @@ void test02() typedef std::deque test_type; __gnu_cxx::__aligned_buffer buf; - __builtin_memset(buf._M_addr(), ~0, sizeof(test_type)); + std::memset(buf._M_addr(), ~0, sizeof(test_type)); test_type *tmp = ::new(buf._M_addr()) test_type(); diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/allocator/default_init.cc b/libstdc++-v3/testsuite/23_containers/forward_list/allocator/default_init.cc index 1865e39a885..d8a8bdf05a9 100644 --- a/libstdc++-v3/testsuite/23_containers/forward_list/allocator/default_init.cc +++ b/libstdc++-v3/testsuite/23_containers/forward_list/allocator/default_init.cc @@ -22,6 +22,7 @@ #include #include +#include #include using T = int; @@ -34,7 +35,7 @@ void test01() typedef std::forward_list test_type; __gnu_cxx::__aligned_buffer buf; - __builtin_memset(buf._M_addr(), ~0, sizeof(test_type)); + std::memset(buf._M_addr(), ~0, sizeof(test_type)); test_type *tmp = ::new(buf._M_addr()) test_type; @@ -49,7 +50,7 @@ void test02() typedef std::forward_list test_type; __gnu_cxx::__aligned_buffer buf; - __builtin_memset(buf._M_addr(), ~0, sizeof(test_type)); + std::memset(buf._M_addr(), ~0, sizeof(test_type)); test_type *tmp = ::new(buf._M_addr()) test_type(); diff --git a/libstdc++-v3/testsuite/23_containers/list/allocator/default_init.cc b/libstdc++-v3/testsuite/23_containers/list/allocator/default_init.cc index ab19ca7070c..cffad227bc0 100644 --- a/libstdc++-v3/testsuite/23_containers/list/allocator/default_init.cc +++ b/libstdc++-v3/testsuite/23_containers/list/allocator/default_init.cc @@ -22,6 +22,7 @@ #include #include +#include #include using T = int; @@ -34,7 +35,7 @@ void test01() typedef std::list test_type; __gnu_cxx::__aligned_buffer buf; - __builtin_memset(buf._M_addr(), ~0, sizeof(test_type)); + std::memset(buf._M_addr(), ~0, sizeof(test_type)); VERIFY( buf._M_ptr()->get_allocator().state != 0 ); @@ -51,7 +52,7 @@ void test02() typedef std::list test_type; __gnu_cxx::__aligned_buffer buf; - __builtin_memset(buf._M_addr(), ~0, sizeof(test_type)); + std::memset(buf._M_addr(), ~0, sizeof(test_type)); VERIFY( buf._M_ptr()->get_allocator().state != 0 ); diff --git a/libstdc++-v3/testsuite/23_containers/map/allocator/default_init.cc b/libstdc++-v3/testsuite/23_containers/map/allocator/default_init.cc index 15fa1bfcf92..6b34227a5d0 100644 --- a/libstdc++-v3/testsuite/23_containers/map/allocator/default_init.cc +++ b/libstdc++-v3/testsuite/23_containers/map/allocator/default_init.cc @@ -22,6 +22,7 @@ #include #include +#include #include using T = int; @@ -34,7 +35,7 @@ void test01() typedef std::map, alloc_type> test_type; __gnu_cxx::__aligned_buffer buf; - __builtin_memset(buf._M_addr(), ~0, sizeof(test_type)); + std::memset(buf._M_addr(), ~0, sizeof(test_type)); test_type *tmp = ::new(buf._M_addr()) test_type; @@ -49,7 +50,7 @@ void test02() typedef std::map, alloc_type> test_type; __gnu_cxx::__aligned_buffer buf; - __builtin_memset(buf._M_addr(), ~0, sizeof(test_type)); + std::memset(buf._M_addr(), ~0, sizeof(test_type)); test_type *tmp = ::new(buf._M_addr()) test_type(); diff --git a/libstdc++-v3/testsuite/23_containers/set/allocator/default_init.cc b/libstdc++-v3/testsuite/23_containers/set/allocator/default_init.cc index 553a93422c0..1976bed445a 100644 --- a/libstdc++-v3/testsuite/23_containers/set/allocator/default_init.cc +++ b/libstdc++-v3/testsuite/23_containers/set/allocator/default_init.cc @@ -22,6 +22,7 @@ #include #include +#include #include using T = int; @@ -34,7 +35,7 @@ void test01() typedef std::set, alloc_type> test_type; __gnu_cxx::__aligned_buffer buf; - __builtin_memset(buf._M_addr(), ~0, sizeof(test_type)); + std::memset(buf._M_addr(), ~0, sizeof(test_type)); test_type *tmp = ::new(buf._M_addr()) test_type; @@ -49,7 +50,7 @@ void test02() typedef std::set, alloc_type> test_type; __gnu_cxx::__aligned_buffer buf; - __builtin_memset(buf._M_addr(), ~0, sizeof(test_type)); + std::memset(buf._M_addr(), ~0, sizeof(test_type)); test_type *tmp = ::new(buf._M_addr()) test_type(); diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/default_init.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/default_init.cc index d86d2537a16..eb3c177f2b4 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/default_init.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/default_init.cc @@ -22,6 +22,7 @@ #include #include +#include #include using T = int; @@ -35,7 +36,7 @@ void test01() alloc_type> test_type; __gnu_cxx::__aligned_buffer buf; - __builtin_memset(buf._M_addr(), ~0, sizeof(test_type)); + std::memset(buf._M_addr(), ~0, sizeof(test_type)); test_type *tmp = ::new(buf._M_addr()) test_type; @@ -51,7 +52,7 @@ void test02() alloc_type> test_type; __gnu_cxx::__aligned_buffer buf; - __builtin_memset(buf._M_addr(), ~0, sizeof(test_type)); + std::memset(buf._M_addr(), ~0, sizeof(test_type)); test_type *tmp = ::new(buf._M_addr()) test_type(); diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/default_init.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/default_init.cc index a86eb987e57..cff8d74a8b2 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/default_init.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/default_init.cc @@ -22,6 +22,7 @@ #include #include +#include #include using T = int; @@ -35,7 +36,7 @@ void test01() alloc_type> test_type; __gnu_cxx::__aligned_buffer buf; - __builtin_memset(buf._M_addr(), ~0, sizeof(test_type)); + std::memset(buf._M_addr(), ~0, sizeof(test_type)); test_type *tmp = ::new(buf._M_addr()) test_type; @@ -51,7 +52,7 @@ void test02() alloc_type> test_type; __gnu_cxx::__aligned_buffer buf; - __builtin_memset(buf._M_addr(), ~0, sizeof(test_type)); + std::memset(buf._M_addr(), ~0, sizeof(test_type)); test_type *tmp = ::new(buf._M_addr()) test_type(); diff --git a/libstdc++-v3/testsuite/23_containers/vector/allocator/default_init.cc b/libstdc++-v3/testsuite/23_containers/vector/allocator/default_init.cc index 1e69f6382c4..ae631da13a4 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/allocator/default_init.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/allocator/default_init.cc @@ -22,6 +22,7 @@ #include #include +#include #include using T = int; @@ -34,7 +35,7 @@ void test01() typedef std::vector test_type; __gnu_cxx::__aligned_buffer buf; - __builtin_memset(buf._M_addr(), ~0, sizeof(test_type)); + std::memset(buf._M_addr(), ~0, sizeof(test_type)); test_type *tmp = ::new(buf._M_addr()) test_type; @@ -49,7 +50,7 @@ void test02() typedef std::vector test_type; __gnu_cxx::__aligned_buffer buf; - __builtin_memset(buf._M_addr(), ~0, sizeof(test_type)); + std::memset(buf._M_addr(), ~0, sizeof(test_type)); test_type *tmp = ::new(buf._M_addr()) test_type(); diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/allocator/default_init.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/allocator/default_init.cc index 5c4d60990e1..1bd69f25685 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/bool/allocator/default_init.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/bool/allocator/default_init.cc @@ -22,6 +22,7 @@ #include #include +#include #include using T = bool; @@ -34,7 +35,7 @@ void test01() typedef std::vector test_type; __gnu_cxx::__aligned_buffer buf; - __builtin_memset(buf._M_addr(), ~0, sizeof(test_type)); + std::memset(buf._M_addr(), ~0, sizeof(test_type)); test_type *tmp = ::new(buf._M_addr()) test_type; @@ -49,7 +50,7 @@ void test02() typedef std::vector test_type; __gnu_cxx::__aligned_buffer buf; - __builtin_memset(buf._M_addr(), ~0, sizeof(test_type)); + std::memset(buf._M_addr(), ~0, sizeof(test_type)); test_type *tmp = ::new(buf._M_addr()) test_type(); diff --git a/libstdc++-v3/testsuite/29_atomics/atomic/compare_exchange_padding.cc b/libstdc++-v3/testsuite/29_atomics/atomic/compare_exchange_padding.cc index 859629e625f..2f18d426e7f 100644 --- a/libstdc++-v3/testsuite/29_atomics/atomic/compare_exchange_padding.cc +++ b/libstdc++-v3/testsuite/29_atomics/atomic/compare_exchange_padding.cc @@ -3,6 +3,7 @@ // { dg-add-options libatomic } #include +#include #include @@ -10,11 +11,11 @@ struct S { char c; short s; }; void __attribute__((noinline,noipa)) fill_struct(S& s) -{ __builtin_memset(&s, 0xff, sizeof(S)); } +{ std::memset(&s, 0xff, sizeof(S)); } bool compare_struct(const S& a, const S& b) -{ return __builtin_memcmp(&a, &b, sizeof(S)) == 0; } +{ return std::memcmp(&a, &b, sizeof(S)) == 0; } int main () diff --git a/libstdc++-v3/testsuite/util/atomic/wait_notify_util.h b/libstdc++-v3/testsuite/util/atomic/wait_notify_util.h index eb890113713..9e96d3cd1bd 100644 --- a/libstdc++-v3/testsuite/util/atomic/wait_notify_util.h +++ b/libstdc++-v3/testsuite/util/atomic/wait_notify_util.h @@ -21,11 +21,10 @@ #include #include #include +#include #include -#include - template Tp check_wait_notify(Tp val1, Tp val2) requires std::equality_comparable @@ -76,7 +75,7 @@ Tp check_wait_notify(Tp val1, Tp val2) a.wait(val1); auto v = a.load(); // TODO this needs to zero padding bits when we can do that - if (__builtin_memcmp(&v, &val2, sizeof(Tp)) != 0) + if (std::memcmp(&v, &val2, sizeof(Tp)) != 0) a = val1; }); cv.wait(l); @@ -137,7 +136,7 @@ Tp check_atomic_wait_notify(Tp val1, Tp val2) std::atomic_wait(&a, val1); auto v = a.load(); // TODO this needs to zero padding bits when we can do that - if (__builtin_memcmp(&v, &val2, sizeof(Tp)) != 0) + if (std::memcmp(&v, &val2, sizeof(Tp)) != 0) a = val1; }); cv.wait(l); @@ -163,13 +162,13 @@ struct check { // TODO this needs to zero padding bits when we can do that auto v = check_wait_notify(a, b); - VERIFY( __builtin_memcmp(&v, &b, sizeof(Tp)) == 0 ); + VERIFY( std::memcmp(&v, &b, sizeof(Tp)) == 0 ); } { // TODO this needs to zero padding bits when we can do that auto v = check_atomic_wait_notify(a, b); - VERIFY( __builtin_memcmp(&v, &b, sizeof(Tp)) == 0); + VERIFY( std::memcmp(&v, &b, sizeof(Tp)) == 0); } } }