From: Mike Frysinger <vapier@gentoo.org>
To: gdb-patches@sourceware.org
Cc: Markus Metzger <markus.t.metzger@intel.com>,
jan.kratochvil@redhat.com,
Mark Kettenis <mark.kettenis@xs4all.nl>
Subject: Re: [PATCH 1/2] i386-cpuid: add support for identifying a processor
Date: Fri, 14 Feb 2014 17:29:00 -0000 [thread overview]
Message-ID: <1912377.WkKB1rPacE@vapier> (raw)
In-Reply-To: <1392294615-16416-1-git-send-email-markus.t.metzger@intel.com>
[-- Attachment #1: Type: text/plain, Size: 2301 bytes --]
On Thursday, February 13, 2014 13:30:14 Markus Metzger wrote:
> --- /dev/null
> +++ b/gdb/common/i386-cpuid.c
> @@ -0,0 +1,74 @@
> +/*
> + Copyright (C) 2014 Free Software Foundation, Inc.
> +
> + This file is part of GDB.
> +
> + This file is free software; you can redistribute it and/or modify it
> + under the terms of the GNU General Public License as published by the
> + Free Software Foundation; either version 3, or (at your option) any
> + later version.
> +
> + This program is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + GNU General Public License for more details.
> +
> + You should have received a copy of the GNU General Public License
> + along with this program. If not, see <http://www.gnu.org/licenses/>.
> */ +
> +#include "i386-cpuid.h"
> +
> +#if defined(__i386__) || defined(__x86_64__)
> +
> +/* See i386-cpuid.h. */
> +
> +struct i386_cpu
> +i386_this_cpu (void)
> +{
> + struct i386_cpu cpu;
> + unsigned int eax, ebx, ecx, edx;
> + int ok;
> +
> + cpu.vendor = CV_UNKNOWN;
> +
> + ok = i386_cpuid (0, &eax, &ebx, &ecx, &edx);
> + if (ok != 0)
> + {
> + if (ebx == signature_INTEL_ebx && ecx == signature_INTEL_ecx
> + && edx == signature_INTEL_edx)
> + {
> + unsigned int cpuid, ignore;
> +
> + ok = i386_cpuid (1, &cpuid, &ignore, &ignore, &ignore);
> + if (ok != 0)
> + {
> + cpu.vendor = CV_INTEL;
> +
> + cpu.family = (cpuid >> 8) & 0xf;
> + cpu.model = (cpuid >> 4) & 0xf;
> + cpu.stepping = cpuid & 0xf;
> +
> + if (cpu.family == 0x6)
> + cpu.model += (cpuid >> 12) & 0xf0;
> + }
> + }
> + }
> +
> + return cpu;
> +}
> +
> +#else /* i386 && x86_64 */
> +
> +/* See i386-cpuid.h. */
> +
> +struct i386_cpu
> +i386_this_cpu (void)
> +{
> + struct i386_cpu cpu;
> +
> + cpu.vendor = CV_UNKNOWN;
> +
> + return cpu;
> +}
> +
> +#endif /* i386 && x86_64 */
afaict, you don't need the #else. the non-x86 codepaths in i386-cpuid.h will
set the return value to 0, and your main code will treat this as an error and
set cpu.vendor to CV_UNKNOWN.
-mike
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2014-02-14 17:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-13 12:30 Markus Metzger
2014-02-13 12:30 ` [PATCH 2/2] btrace: use i386-cpuid's cpu identifier Markus Metzger
2014-02-13 13:29 ` [PATCH 1/2] i386-cpuid: add support for identifying a processor Mark Kettenis
2014-02-13 13:34 ` Metzger, Markus T
2014-02-13 18:32 ` Pedro Alves
2014-02-14 8:30 ` Metzger, Markus T
2014-02-14 17:29 ` Mike Frysinger [this message]
2014-02-17 8:04 ` Metzger, Markus T
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=1912377.WkKB1rPacE@vapier \
--to=vapier@gentoo.org \
--cc=gdb-patches@sourceware.org \
--cc=jan.kratochvil@redhat.com \
--cc=mark.kettenis@xs4all.nl \
--cc=markus.t.metzger@intel.com \
/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