RFC: Read the cache information from /proc/self/auxv on PPC Linux
PATCH 1/1 RFC: Read the cache information from /proc/self/auxv on PPC Linux
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
From ac63e41830ec555a36e05bd37c9718945b3c8e3b Mon Sep 17 00:00:00 2001
From: Filip Navara <[email protected]>
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(-)
cache-utils.c +15 -9
@@ -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); } }
Signature · 1 line
1.6.3.msysgit.0
Quoted 9 lines · Filip Navara
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. Ifppc_init_cacheline_sizesgets 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.
That will only work on 2.6 and only when proc is mounted.
Signature · 1 line
mailto:[email protected]