From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.baldwin.cx (bigwig.baldwin.cx [66.216.25.90]) by sourceware.org (Postfix) with ESMTPS id 8DAA03858CD1 for ; Fri, 14 Jul 2023 15:55:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8DAA03858CD1 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=FreeBSD.org Received: from ralph.com (c-98-35-126-114.hsd1.ca.comcast.net [98.35.126.114]) by mail.baldwin.cx (Postfix) with ESMTPSA id 6846B1A84E2E for ; Fri, 14 Jul 2023 11:55:51 -0400 (EDT) From: John Baldwin To: gdb-patches@sourceware.org Subject: [PATCH v6 04/15] nat/x86-cpuid.h: Add x86_cpuid_count wrapper around __get_cpuid_count. Date: Fri, 14 Jul 2023 08:51:40 -0700 Message-Id: <20230714155151.21723-5-jhb@FreeBSD.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230714155151.21723-1-jhb@FreeBSD.org> References: <20230714155151.21723-1-jhb@FreeBSD.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.4 (mail.baldwin.cx [0.0.0.0]); Fri, 14 Jul 2023 11:55:51 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.103.1 at mail.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00,FORGED_SPF_HELO,GIT_PATCH_0,KAM_DMARC_STATUS,KHOP_HELO_FCRDNS,SPF_HELO_PASS,SPF_SOFTFAIL,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --- gdb/nat/x86-cpuid.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/gdb/nat/x86-cpuid.h b/gdb/nat/x86-cpuid.h index 0955afba577..517113d45e8 100644 --- a/gdb/nat/x86-cpuid.h +++ b/gdb/nat/x86-cpuid.h @@ -48,6 +48,30 @@ x86_cpuid (unsigned int __level, return __get_cpuid (__level, __eax, __ebx, __ecx, __edx); } +/* Return cpuid data for requested cpuid level and sub-level, as found + in returned eax, ebx, ecx and edx registers. The function checks + if cpuid is supported and returns 1 for valid cpuid information or + 0 for unsupported cpuid level. Pointers may be non-null. */ + +static __inline int +x86_cpuid_count (unsigned int __level, unsigned int __sublevel, + unsigned int *__eax, unsigned int *__ebx, + unsigned int *__ecx, unsigned int *__edx) +{ + unsigned int __scratch; + + if (__eax == nullptr) + __eax = &__scratch; + if (__ebx == nullptr) + __ebx = &__scratch; + if (__ecx == nullptr) + __ecx = &__scratch; + if (__edx == nullptr) + __edx = &__scratch; + + return __get_cpuid_count (__level, __sublevel, __eax, __ebx, __ecx, __edx); +} + #else static __inline int @@ -58,6 +82,14 @@ x86_cpuid (unsigned int __level, return 0; } +static __inline int +x86_cpuid_count (unsigned int __level, unsigned int __sublevel, + unsigned int *__eax, unsigned int *__ebx, + unsigned int *__ecx, unsigned int *__edx) +{ + return 0; +} + #endif /* i386 && x86_64 */ #endif /* NAT_X86_CPUID_H */ -- 2.40.0