From: "Ulrich Weigand" <uweigand@de.ibm.com>
To: yao@codesourcery.com (Yao Qi)
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 2/2] Detect 64-bit-ness in PowerPC Book III-E
Date: Tue, 13 Jan 2015 17:00:00 -0000 [thread overview]
Message-ID: <201501131700.t0DH0eDu014515@d03av02.boulder.ibm.com> (raw)
In-Reply-To: <1420964846-18881-3-git-send-email-yao@codesourcery.com> from "Yao Qi" at Jan 11, 2015 04:27:26 PM
Yao Qi wrote:
> gdb:
>
> 2015-01-11 Yao Qi <yao@codesourcery.com>
>
> * Makefile.in (ppc-linux.o): New rule.
> * config/powerpc/ppc64-linux.mh (NATDEPFILES): Add ppc-linux.o.
> * nat/ppc-linux.h [__powerpc64__] (ppc64_64bit_inferior_p):
> Declare.
> * nat/ppc-linux.c: New file.
> * ppc-linux-nat.c (ppc_linux_target_wordsize) [__powerpc64__]:
> Call ppc64_64bit_inferior_p.
>
> gdb/gdbserver:
>
> 2015-01-11 Yao Qi <yao@codesourcery.com>
>
> * Makefile.in (SFILES): Add nat/ppc-linux.c.
> (ppc-linux.o): New rule.
> * configure.srv (powerpc*-*-linux*): Add ppc-linux.o.
> * linux-ppc-low.c (ppc_arch_setup) [__powerpc64__]: Call
> ppc64_64bit_inferior_p
This is OK in principle, however:
> +static void
> +ppc64_host_hwcap (unsigned long *valp)
> +{
> + unsigned char data[2 * 8];
> + FILE *f = fopen ("/proc/self/auxv", "r");
> +
> + if (f == NULL)
> + return;
> +
> + while (fread (data, sizeof (data), 1, f) > 0)
> + {
> + unsigned long *data_p = (unsigned long *) data;
> +
> + if (data_p[0] == AT_HWCAP)
> + {
> + *valp = data_p[1];
> + break;
> + }
> + }
> +
> + fclose (f);
> +}
All this can be done using "getauxval (AT_HWCAP)", which is faster and works
even if /proc is not mounted. However, getauxval was only introduced with
glibc 2.16, so we'll probably still need the fallback ...
Bye,
Ulrich
--
Dr. Ulrich Weigand
GNU/Linux compilers and toolchain
Ulrich.Weigand@de.ibm.com
next prev parent reply other threads:[~2015-01-13 17:00 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-11 11:15 [PATCH] " Yao Qi
2014-12-11 15:31 ` Ulrich Weigand
2014-12-19 8:06 ` Yao Qi
2014-12-19 15:49 ` Ulrich Weigand
2015-01-11 8:27 ` [PATCH 0/2, V2] " Yao Qi
2015-01-11 8:27 ` [PATCH 2/2] " Yao Qi
2015-01-13 17:00 ` Ulrich Weigand [this message]
2015-01-14 2:54 ` Yao Qi
2015-01-14 12:47 ` Ulrich Weigand
2015-01-14 14:22 ` Yao Qi
2015-01-11 8:27 ` [PATCH 1/2] Move some ppc macros to nat/ppc-linux.h Yao Qi
2015-01-13 16:57 ` Ulrich Weigand
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=201501131700.t0DH0eDu014515@d03av02.boulder.ibm.com \
--to=uweigand@de.ibm.com \
--cc=gdb-patches@sourceware.org \
--cc=yao@codesourcery.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).