setarch question, uname -m
Hi,
I wonder whether it would be possible (and useful) to always support
setarch $(uname -m) ...
like we are trying in tests/ts/misc/setarch.
Currently we only support these hardcoded transistions where a lot of archs are missing. Couldn't we just add something like
{PER_LINUX$word_size, un.machine, un.machine}
to transitions dynamically at runtime? Or wouldn't it make any sense?
cu,
Rudi
PATCH 1/1 setarch question, uname -m
From: Ruediger Meier <[email protected]>
I just send a patch proposal to let "setarch $(uname -m) ..." work everywhere. Tested on several arm flavours. If this makes no sense please tell me. Then I would fix our setarch test for non-hardcoded archs.
Ruediger Meier (1):
setarch, add generic support for setarch $(uname -m) ...
sys-utils/setarch.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
Signature · 1 line
1.8.4.5
PATCH 1/1 setarch, add generic support for setarch $(uname -m) ...
From: Ruediger Meier <[email protected]>
--- sys-utils/setarch.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
sys-utils/setarch.c +16 -0
@@ -202,9 +202,25 @@ set_arch(const char *pers, unsigned long options, int list) {PER_LINUX, "alphaev6", "alpha"}, {PER_LINUX, "alphaev67", "alpha"}, #endif + {-1, NULL, NULL}, /* place holder, eventually filled up at runtime */ {-1, NULL, NULL} }; + /* Add the trivial transition {PER_LINUX, machine, machine} if no such + target_arch is hardcoded yet. */ + uname(&un); + for (i = 0; transitions[i].perval >= 0; i++) + if(!strcmp(un.machine, transitions[i].target_arch)) + break; + if (transitions[i].perval < 0) { + unsigned long wrdsz = CHAR_BIT * sizeof(void*); + if (wrdsz == 32 || wrdsz == 64) { + transitions[i].perval = wrdsz == 32 ? PER_LINUX32 : PER_LINUX; + transitions[i].target_arch = un.machine; + transitions[i].result_arch = un.machine; + } + } + if (list) { for(i = 0; transitions[i].target_arch != NULL; i++) printf("%s\n", transitions[i].target_arch);
Signature · 1 line
1.8.4.5
Re: [PATCH] setarch, add generic support for setarch $(uname -m) ...
Quoted 2 lines · Ruediger Meier
sys-utils/setarch.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
Applied, thanks.
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com