diff options
author | Kevin Ryde <user42@zip.com.au> | 2002-03-04 23:08:31 +0100 |
---|---|---|
committer | Kevin Ryde <user42@zip.com.au> | 2002-03-04 23:08:31 +0100 |
commit | a35d37ba4a548df4ea296779d3f1c5cfb0e27495 (patch) | |
tree | cb428972f6ac391cd6bc1e2a984f84d79e9a1535 /config.guess | |
parent | df5d0e110c2b2d6612b5c268e3e5ef477f4305ec (diff) | |
download | gmp-a35d37ba4a548df4ea296779d3f1c5cfb0e27495.tar.gz |
* config.guess [powerpc]: Force code alignment for mfpvr test.
Diffstat (limited to 'config.guess')
-rwxr-xr-x | config.guess | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/config.guess b/config.guess index 296ef34d7..2305fbfde 100755 --- a/config.guess +++ b/config.guess @@ -263,23 +263,40 @@ EOF rs6000-*-* | powerpc*-*-*) - # Try to read the PVR. mfpvr is a protected instruction, the linux kernel - # allows it in user mode, but MacOS and AIX don't. + # Try to read the PVR. mfpvr is a protected instruction, MacOS and AIX + # don't allow it in user mode, but the Linux kernel does. + # + # Using explicit bytes for mfpvr avoids worrying about assembler syntax + # and underscores. "char"s are used instead of "int"s to avoid worrying + # whether sizeof(int)==4 or if it's the right endianness. + # + # Note this is no good on AIX, since a C function there is the address of + # a function descriptor, not actual code. But this doesn't matter since + # AIX doesn't allow mfpvr anyway. + # cat >$dummy.c <<\EOF -/* this is a bit nasty, but saves worrying about the assembler syntax */ -const unsigned char getpvr[] = { - 0x7c, 0x7f, 0x42, 0xa6, /* mfpvr r3 */ - 0x4e, 0x80, 0x00, 0x20, /* blr */ +#include <stdio.h> +struct { + int n; /* force 4-byte alignment */ + char a[8]; +} getpvr = { + 0, + { + 0x7c, 0x7f, 0x42, 0xa6, /* mfpvr r3 */ + 0x4e, 0x80, 0x00, 0x20, /* blr */ + } }; int main () { unsigned (*fun)(); unsigned pvr; - /* a separate "fun" variable is necessary for the gcc 2.95.2 on MacOS, + + /* a separate "fun" variable is necessary for gcc 2.95.2 on MacOS, it gets a compiler error on a combined cast and call */ - fun = (unsigned (*)()) getpvr; + fun = (unsigned (*)()) getpvr.a; pvr = (*fun) (); + switch (pvr >> 16) { case 1: puts ("powerpc601"); break; case 3: puts ("powerpc603"); break; |