From: Albert Cahalan <albert@users.sourceforge.net>
To: linuxppc-dev@lists.linuxppc.org
Cc: damm@opensource.se, hollis@austin.ibm.com,
benh@kernel.crashing.org, ningerso@ruralcenter.org
Subject: Re: Runtime Altivec detection
Date: 08 Mar 2003 23:01:47 -0500 [thread overview]
Message-ID: <1047182509.1900.246.camel@cube> (raw)
For those of you needing to get at ELF note info
to determine CPU features and other things, here
is the code procps-3.1.x has been using. You'll
need the appropriate ID code; here I use AT_CLKTCK
to determine USER_HZ. Pass the ID code into this
function, and you get back the ELF note value.
//////////////////////////////////////////////////////////////////////////
#ifndef AT_CLKTCK
#define AT_CLKTCK 17 // frequency of times()
#endif
#define ERROR_CODE 42 // choose something better!
extern char** environ;
// for ELF executables, notes are pushed before environment and args
static unsigned long find_elf_note(unsigned long findme){
unsigned long *ep = (unsigned long *)environ;
while(*ep++);
while(*ep){
if(ep[0]==findme) return ep[1];
ep+=2;
}
return ERROR_CODE;
}
// Usage:
// Hertz = find_elf_note(AT_CLKTCK);
////////////////////////////////////////////////////////////////////////
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
next reply other threads:[~2003-03-09 4:01 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-03-09 4:01 Albert Cahalan [this message]
-- strict thread matches above, loose matches on Subject: below --
2003-03-08 2:02 Runtime Altivec detection Bill Fink
2003-03-08 2:11 ` Hollis Blanchard
2003-03-08 8:04 ` Bill Fink
2003-03-08 18:21 ` Nathan Ingersoll
2003-03-07 16:47 Nathan Ingersoll
2003-03-07 17:24 ` Dan Malek
2003-03-07 17:35 ` Nathan Ingersoll
2003-03-07 17:37 ` Anton Blanchard
2003-03-07 17:41 ` Benjamin Herrenschmidt
2003-03-07 17:52 ` Nathan Ingersoll
2003-03-07 18:55 ` Magnus Damm
2003-03-07 18:06 ` Benjamin Herrenschmidt
2003-03-07 18:18 ` Hollis Blanchard
2003-03-07 18:54 ` Magnus Damm
2003-03-07 18:08 ` Nathan Ingersoll
2003-03-07 19:44 ` Magnus Damm
2003-03-07 19:23 ` Nathan Ingersoll
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=1047182509.1900.246.camel@cube \
--to=albert@users.sourceforge.net \
--cc=benh@kernel.crashing.org \
--cc=damm@opensource.se \
--cc=hollis@austin.ibm.com \
--cc=linuxppc-dev@lists.linuxppc.org \
--cc=ningerso@ruralcenter.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.