From: Filip Navara <filip.navara@gmail.com>
To: qemu-devel <qemu-devel@nongnu.org>
Subject: [Qemu-devel] [PATCH] RFC: Read the cache information from /proc/self/auxv on PPC Linux
Date: Tue, 23 Jun 2009 16:54:31 +0200 [thread overview]
Message-ID: <5b31733c0906230754s4acab089j37e0335dcc77def7@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 485 bytes --]
Hello,
I'd really like to cleanup the code for SDL_main, but a prerequisite
is to change reading of cache information on PPC Linux. This patch is
based on suggestion by Hollis Blanchard. If ppc_init_cacheline_sizes
gets fixed on PPC Linux we will no longer need to pass the "env"
variable around and the code will be cleaner. Unfortunately I don't
have access to PPC Linux, so I can't really test if the patch works or
even compiles, so any help is appreciated.
Thanks,
Filip Navara
[-- Attachment #2: 0001-Read-the-cache-information-from-proc-self-auxv-on-PP.patch.txt --]
[-- Type: text/plain, Size: 1640 bytes --]
From ac63e41830ec555a36e05bd37c9718945b3c8e3b Mon Sep 17 00:00:00 2001
From: Filip Navara <filip.navara@gmail.com>
Date: Tue, 23 Jun 2009 16:47:24 +0200
Subject: [PATCH] Read the cache information from /proc/self/auxv on PPC Linux
---
cache-utils.c | 24 +++++++++++++++---------
1 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/cache-utils.c b/cache-utils.c
index 45d62c9..1675905 100644
--- a/cache-utils.c
+++ b/cache-utils.c
@@ -16,6 +16,8 @@ static void ppc_init_cacheline_sizes(void)
}
#elif defined __linux__
+#include <unistd.h>
+#include <fcntl.h>
#define QEMU_AT_NULL 0
#define QEMU_AT_DCACHEBSIZE 19
@@ -23,16 +25,20 @@ static void ppc_init_cacheline_sizes(void)
static void ppc_init_cacheline_sizes(char **envp)
{
- unsigned long *auxv;
-
- while (*envp++);
-
- for (auxv = (unsigned long *) envp; *auxv != QEMU_AT_NULL; auxv += 2) {
- switch (*auxv) {
- case QEMU_AT_DCACHEBSIZE: qemu_cache_conf.dcache_bsize = auxv[1]; break;
- case QEMU_AT_ICACHEBSIZE: qemu_cache_conf.icache_bsize = auxv[1]; break;
- default: break;
+ int fd;
+ unsigned long auxv[2];
+
+ fd = open("/proc/self/auxv", O_RDONLY);
+ if (fd != -1) {
+ while (read(fd, auxv, sizeof(auxv)) == sizeof(auxv) &&
+ auxv[0] != QEMU_AT_NULL) {
+ switch (auxv[0]) {
+ case QEMU_AT_DCACHEBSIZE: qemu_cache_conf.dcache_bsize = auxv[1]; break;
+ case QEMU_AT_ICACHEBSIZE: qemu_cache_conf.icache_bsize = auxv[1]; break;
+ default: break;
+ }
}
+ close(fd);
}
}
--
1.6.3.msysgit.0
next reply other threads:[~2009-06-23 14:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-23 14:54 Filip Navara [this message]
2009-06-23 15:47 ` [Qemu-devel] [PATCH] RFC: Read the cache information from /proc/self/auxv on PPC Linux malc
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=5b31733c0906230754s4acab089j37e0335dcc77def7@mail.gmail.com \
--to=filip.navara@gmail.com \
--cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).