From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id aCsAErviSmRlFzgAWB0awg (envelope-from ) for ; Thu, 27 Apr 2023 17:01:47 -0400 Received: by simark.ca (Postfix, from userid 112) id 47E641E221; Thu, 27 Apr 2023 17:01:47 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham autolearn_force=no version=3.4.6 Received: from 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 RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 942621E13D for ; Thu, 27 Apr 2023 17:01:46 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 110FF3857708 for ; Thu, 27 Apr 2023 21:01:45 +0000 (GMT) Received: from mail.baldwin.cx (bigwig.baldwin.cx [IPv6:2607:f138:0:13::2]) by sourceware.org (Postfix) with ESMTPS id 354953858C50 for ; Thu, 27 Apr 2023 21:01:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 354953858C50 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.baldwin.net (c-98-35-126-114.hsd1.ca.comcast.net [98.35.126.114]) by mail.baldwin.cx (Postfix) with ESMTPSA id A02A51A84E1C for ; Thu, 27 Apr 2023 17:01:30 -0400 (EDT) From: John Baldwin To: gdb-patches@sourceware.org Subject: [PATCH v5 04/19] nat/x86-cpuid.h: Add x86_cpuid_count wrapper around __get_cpuid_count. Date: Thu, 27 Apr 2023 14:00:58 -0700 Message-Id: <20230427210113.45380-5-jhb@FreeBSD.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230427210113.45380-1-jhb@FreeBSD.org> References: <20230427210113.45380-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]); Thu, 27 Apr 2023 17:01:30 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.103.1 at mail.baldwin.cx X-Virus-Status: Clean X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" --- 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