Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Mike Frysinger <vapier@gentoo.org>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH v2] gdb: clean up x86 cpuid implementations
Date: Tue, 07 May 2013 14:49:00 -0000	[thread overview]
Message-ID: <51891479.70000@redhat.com> (raw)
In-Reply-To: <201305071031.12413.vapier@gentoo.org>

On 05/07/2013 03:31 PM, Mike Frysinger wrote:
> On Tuesday 07 May 2013 10:19:06 Pedro Alves wrote:
>> On 05/07/2013 03:08 PM, Pedro Alves wrote:
>>> On 05/07/2013 02:29 PM, Mike Frysinger wrote:
>>>> Fortunately, that last header there is pretty damn good -- it handles
>>>> lots of edge cases, the code is nice & tight (uses gcc asm operands
>>>> rather than manual movs), and is already almost a general library type
>>>> header.
>>>
>>> The top of the header says:
>>>
>>> /* Helper file for i386 platform.  Runtime check for MMX/SSE/SSE2/AVX
>>>  * support. Copied from gcc 4.4.
>>>
>>> I'd rather not fork the gcc file.  If we need to wrap its
>>> functions/macros for gdb's purpose, I'd rather do that in a separate
>>> file that
>>> #includes (a copy of) gcc's, verbatim, so we can pull updates from
>>> upstream easily.  In fact, diffing our copy against gcc's shows we're
>>> already out of date --- see below.  The bits removed are gdb-specific
>>> additions.
>>>
>>> I wonder whether pushing the file down to libiberty, so both gcc
>>> and gdb could share it would be viable?
>>
>> Actually, it seems like __get_cpuid is a gcc built-in nowadays, but I don't
>> when it was added.  We could make use of it, and only fallback to the
>> header copy if the host compiler doesn't have the builtin.
> 
> yes, gcc introduced a cpuid.h starting with gcc-4.3.0.  i wanted to focus on 
> getting everyone on the same header first before tackling that.  

Your changes were effectively diverging our header from gcc's, not
converging.

i didn't think  people would be ok with x86 builds requiring gcc-4.3.0 ?

Right, and I did not suggest that?  The fallback part would take care
of < gcc 4.3 (and then at some point in the distant future older gccs
would become irrelevant and we drop the fallback).  But yes, an autocheck
can/could be done separately.

Really the main issue is with the forking of gcc's __get_cpuid,
like in

 static __inline int
-__get_cpuid (unsigned int __level,
-	     unsigned int *__eax, unsigned int *__ebx,
-	     unsigned int *__ecx, unsigned int *__edx)
+i386_cpuid (unsigned int __level,
+	    unsigned int *__eax, unsigned int *__ebx,
+	    unsigned int *__ecx, unsigned int *__edx)
 {
+  unsigned int __scratch;
   unsigned int __ext = __level & 0x80000000;

+  if (!__eax)
+    __eax = &__scratch;
+  if (!__ebx)
+    __ebx = &__scratch;
+  if (!__ecx)
+    __ecx = &__scratch;
+  if (!__edx)
+    __edx = &__scratch;
+
   if (__get_cpuid_max (__ext, 0) < __level)
-    return 0;
+    return 1;

instead of building on it.

-- 
Pedro Alves


  reply	other threads:[~2013-05-07 14:49 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-06 18:51 [patch/rfc] " Mike Frysinger
2013-05-06 19:44 ` Eli Zaretskii
2013-05-06 20:30   ` Mike Frysinger
2013-05-07  2:41     ` Eli Zaretskii
2013-05-07  4:26       ` Doug Evans
2013-05-07 15:56         ` Eli Zaretskii
2013-05-07 13:29 ` [PATCH v2] " Mike Frysinger
2013-05-07 14:08   ` Pedro Alves
2013-05-07 14:19     ` Pedro Alves
2013-05-07 14:31       ` Mike Frysinger
2013-05-07 14:49         ` Pedro Alves [this message]
2013-05-07 15:05           ` Mike Frysinger
2013-05-07 15:21             ` Pedro Alves
2013-05-07 15:11 ` [PATCH v3] " Mike Frysinger
2013-06-17  6:16   ` Mike Frysinger
2013-06-17 17:52     ` Pedro Alves
2013-06-18 17:53       ` Mike Frysinger
2013-06-18 18:32         ` Pedro Alves
2013-06-18 23:37           ` Joel Brobecker
2013-06-19  3:12           ` Mike Frysinger
2013-06-19 12:11             ` Pedro Alves
2013-06-19 15:06               ` Mike Frysinger
2013-06-19 15:16                 ` Pedro Alves
2013-06-19 15:50                   ` Mike Frysinger
2013-06-19 16:59                     ` Pedro Alves
2013-06-19 17:35 ` [PATCH v4] " Mike Frysinger
2013-06-19 17:42   ` Pedro Alves
2013-06-19 22:45     ` Mike Frysinger
2013-06-21 11:42       ` Regression for btrace [Re: [PATCH v4] gdb: clean up x86 cpuid implementations] Jan Kratochvil
2013-06-21 15:36         ` Mike Frysinger
2013-06-21 15:41           ` Pedro Alves
2013-06-21 15:51             ` [commit] " Jan Kratochvil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51891479.70000@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=vapier@gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox