|
From: <sv...@va...> - 2009-02-15 23:38:30
|
Author: njn
Date: 2009-02-15 23:38:24 +0000 (Sun, 15 Feb 2009)
New Revision: 9175
Log:
Added 'os_test' and 'platform_test' scripts that ensure that inappropriate
OS- and platform-specific regtests are not run. This avoids 11 regtest
failures on Darwin.
Renamed 'cputest' to 'arch_test' to be consistent with 'os_test' and
'platform_test'.
Added:
branches/DARWIN/tests/arch_test.c
branches/DARWIN/tests/os_test.in
branches/DARWIN/tests/platform_test
Removed:
branches/DARWIN/tests/cputest.c
Modified:
branches/DARWIN/configure.in
branches/DARWIN/docs/internals/porting-HOWTO.txt
branches/DARWIN/docs/internals/porting-to-ARM.txt
branches/DARWIN/memcheck/tests/x86/fxsave.vgtest
branches/DARWIN/memcheck/tests/x86/sse1_memory.vgtest
branches/DARWIN/memcheck/tests/x86/sse2_memory.vgtest
branches/DARWIN/memcheck/tests/x86/xor-undef-x86.vgtest
branches/DARWIN/none/tests/amd64/insn_sse3.vgtest
branches/DARWIN/none/tests/amd64/insn_ssse3.vgtest
branches/DARWIN/none/tests/amd64/ssse3_misaligned.vgtest
branches/DARWIN/none/tests/x86/bug137714-x86.vgtest
branches/DARWIN/none/tests/x86/cse_fail.vgtest
branches/DARWIN/none/tests/x86/insn_cmov.vgtest
branches/DARWIN/none/tests/x86/insn_fpu.vgtest
branches/DARWIN/none/tests/x86/insn_mmx.vgtest
branches/DARWIN/none/tests/x86/insn_mmxext.vgtest
branches/DARWIN/none/tests/x86/insn_sse.vgtest
branches/DARWIN/none/tests/x86/insn_sse2.vgtest
branches/DARWIN/none/tests/x86/insn_sse3.vgtest
branches/DARWIN/none/tests/x86/insn_ssse3.vgtest
branches/DARWIN/none/tests/x86/ssse3_misaligned.vgtest
branches/DARWIN/tests/Makefile.am
branches/DARWIN/tests/vg_regtest.in
Modified: branches/DARWIN/configure.in
===================================================================
--- branches/DARWIN/configure.in 2009-02-15 22:04:20 UTC (rev 9174)
+++ branches/DARWIN/configure.in 2009-02-15 23:38:24 UTC (rev 9175)
@@ -1783,6 +1783,7 @@
docs/xml/Makefile
tests/Makefile
tests/vg_regtest
+ tests/os_test
perf/Makefile
perf/vg_perf
include/Makefile
Modified: branches/DARWIN/docs/internals/porting-HOWTO.txt
===================================================================
--- branches/DARWIN/docs/internals/porting-HOWTO.txt 2009-02-15 22:04:20 UTC (rev 9174)
+++ branches/DARWIN/docs/internals/porting-HOWTO.txt 2009-02-15 23:38:24 UTC (rev 9175)
@@ -68,8 +68,9 @@
Once it runs ok:
-- Add the cpu to the tests/cputest.c file so the reg test script will work.
- (Don't forget to add it to all_archs[].)
+- Add the arch to the tests/arch_test.c file so the reg test script will work.
+ (Don't forget to add it to all_archs[].) Likewise for os_test.in and
+ platform_test.
- Ensure the regression tests work, and add some arch-specific tests to
none/tests directory.
Modified: branches/DARWIN/docs/internals/porting-to-ARM.txt
===================================================================
--- branches/DARWIN/docs/internals/porting-to-ARM.txt 2009-02-15 22:04:20 UTC (rev 9174)
+++ branches/DARWIN/docs/internals/porting-to-ARM.txt 2009-02-15 23:38:24 UTC (rev 9175)
@@ -156,7 +156,7 @@
# error VG_UCONTEXT_SYSCALL_RET undefined for ARM/Linux
=============================================================================
-From tests/cputest.c
+From tests/arch_test.c
=============================================================================
- You'll need to add "arm" to all_archs[].
Modified: branches/DARWIN/memcheck/tests/x86/fxsave.vgtest
===================================================================
--- branches/DARWIN/memcheck/tests/x86/fxsave.vgtest 2009-02-15 22:04:20 UTC (rev 9174)
+++ branches/DARWIN/memcheck/tests/x86/fxsave.vgtest 2009-02-15 23:38:24 UTC (rev 9175)
@@ -1,4 +1,4 @@
prog: fxsave
-prereq: ../../../tests/cputest x86-sse
+prereq: ../../../tests/arch_test x86-sse
vgopts: -q
args: x
Modified: branches/DARWIN/memcheck/tests/x86/sse1_memory.vgtest
===================================================================
--- branches/DARWIN/memcheck/tests/x86/sse1_memory.vgtest 2009-02-15 22:04:20 UTC (rev 9174)
+++ branches/DARWIN/memcheck/tests/x86/sse1_memory.vgtest 2009-02-15 23:38:24 UTC (rev 9175)
@@ -1,4 +1,4 @@
prog: sse_memory
vgopts: -q
args: sse1
-prereq: ../../../tests/cputest x86-sse
+prereq: ../../../tests/arch_test x86-sse
Modified: branches/DARWIN/memcheck/tests/x86/sse2_memory.vgtest
===================================================================
--- branches/DARWIN/memcheck/tests/x86/sse2_memory.vgtest 2009-02-15 22:04:20 UTC (rev 9174)
+++ branches/DARWIN/memcheck/tests/x86/sse2_memory.vgtest 2009-02-15 23:38:24 UTC (rev 9175)
@@ -1,4 +1,4 @@
prog: sse_memory
vgopts: -q
args: sse2
-prereq: ../../../tests/cputest x86-sse2
+prereq: ../../../tests/arch_test x86-sse2
Modified: branches/DARWIN/memcheck/tests/x86/xor-undef-x86.vgtest
===================================================================
--- branches/DARWIN/memcheck/tests/x86/xor-undef-x86.vgtest 2009-02-15 22:04:20 UTC (rev 9174)
+++ branches/DARWIN/memcheck/tests/x86/xor-undef-x86.vgtest 2009-02-15 23:38:24 UTC (rev 9175)
@@ -1,2 +1,2 @@
prog: xor-undef-x86
-prereq: ../../../tests/cputest x86-sse
+prereq: ../../../tests/arch_test x86-sse
Modified: branches/DARWIN/none/tests/amd64/insn_sse3.vgtest
===================================================================
--- branches/DARWIN/none/tests/amd64/insn_sse3.vgtest 2009-02-15 22:04:20 UTC (rev 9174)
+++ branches/DARWIN/none/tests/amd64/insn_sse3.vgtest 2009-02-15 23:38:24 UTC (rev 9175)
@@ -1,3 +1,3 @@
prog: ../../../none/tests/amd64/insn_sse3
-prereq: ../../../tests/cputest amd64-sse3
+prereq: ../../../tests/arch_test amd64-sse3
vgopts: -q
Modified: branches/DARWIN/none/tests/amd64/insn_ssse3.vgtest
===================================================================
--- branches/DARWIN/none/tests/amd64/insn_ssse3.vgtest 2009-02-15 22:04:20 UTC (rev 9174)
+++ branches/DARWIN/none/tests/amd64/insn_ssse3.vgtest 2009-02-15 23:38:24 UTC (rev 9175)
@@ -1,3 +1,3 @@
prog: ../../../none/tests/amd64/insn_ssse3
-prereq: ../../../tests/cputest amd64-sse3
+prereq: ../../../tests/arch_test amd64-sse3
vgopts: -q
Modified: branches/DARWIN/none/tests/amd64/ssse3_misaligned.vgtest
===================================================================
--- branches/DARWIN/none/tests/amd64/ssse3_misaligned.vgtest 2009-02-15 22:04:20 UTC (rev 9174)
+++ branches/DARWIN/none/tests/amd64/ssse3_misaligned.vgtest 2009-02-15 23:38:24 UTC (rev 9175)
@@ -1,3 +1,3 @@
prog: ssse3_misaligned
-prereq: ../../../tests/cputest amd64-sse3
+prereq: ../../../tests/arch_test amd64-sse3
vgopts: -q
Modified: branches/DARWIN/none/tests/x86/bug137714-x86.vgtest
===================================================================
--- branches/DARWIN/none/tests/x86/bug137714-x86.vgtest 2009-02-15 22:04:20 UTC (rev 9174)
+++ branches/DARWIN/none/tests/x86/bug137714-x86.vgtest 2009-02-15 23:38:24 UTC (rev 9175)
@@ -1,3 +1,3 @@
prog: bug137714-x86
-prereq: ../../../tests/cputest x86-sse2
+prereq: ../../../tests/arch_test x86-sse2
vgopts: -q
Modified: branches/DARWIN/none/tests/x86/cse_fail.vgtest
===================================================================
--- branches/DARWIN/none/tests/x86/cse_fail.vgtest 2009-02-15 22:04:20 UTC (rev 9174)
+++ branches/DARWIN/none/tests/x86/cse_fail.vgtest 2009-02-15 23:38:24 UTC (rev 9175)
@@ -1,3 +1,3 @@
prog: cse_fail
-prereq: ../../../tests/cputest x86-sse
+prereq: ../../../tests/arch_test x86-sse
vgopts: -q
Modified: branches/DARWIN/none/tests/x86/insn_cmov.vgtest
===================================================================
--- branches/DARWIN/none/tests/x86/insn_cmov.vgtest 2009-02-15 22:04:20 UTC (rev 9174)
+++ branches/DARWIN/none/tests/x86/insn_cmov.vgtest 2009-02-15 23:38:24 UTC (rev 9175)
@@ -1,3 +1,3 @@
prog: ../../../none/tests/x86/insn_cmov
-prereq: ../../../tests/cputest x86-cmov
+prereq: ../../../tests/arch_test x86-cmov
vgopts: -q
Modified: branches/DARWIN/none/tests/x86/insn_fpu.vgtest
===================================================================
--- branches/DARWIN/none/tests/x86/insn_fpu.vgtest 2009-02-15 22:04:20 UTC (rev 9174)
+++ branches/DARWIN/none/tests/x86/insn_fpu.vgtest 2009-02-15 23:38:24 UTC (rev 9175)
@@ -1,3 +1,3 @@
prog: ../../../none/tests/x86/insn_fpu
-prereq: ../../../tests/cputest x86-fpu
+prereq: ../../../tests/arch_test x86-fpu
vgopts: -q
Modified: branches/DARWIN/none/tests/x86/insn_mmx.vgtest
===================================================================
--- branches/DARWIN/none/tests/x86/insn_mmx.vgtest 2009-02-15 22:04:20 UTC (rev 9174)
+++ branches/DARWIN/none/tests/x86/insn_mmx.vgtest 2009-02-15 23:38:24 UTC (rev 9175)
@@ -1,3 +1,3 @@
prog: ../../../none/tests/x86/insn_mmx
-prereq: ../../../tests/cputest x86-mmx
+prereq: ../../../tests/arch_test x86-mmx
vgopts: -q
Modified: branches/DARWIN/none/tests/x86/insn_mmxext.vgtest
===================================================================
--- branches/DARWIN/none/tests/x86/insn_mmxext.vgtest 2009-02-15 22:04:20 UTC (rev 9174)
+++ branches/DARWIN/none/tests/x86/insn_mmxext.vgtest 2009-02-15 23:38:24 UTC (rev 9175)
@@ -1,3 +1,3 @@
prog: ../../../none/tests/x86/insn_mmxext
-prereq: ../../../tests/cputest x86-mmxext
+prereq: ../../../tests/arch_test x86-mmxext
vgopts: -q
Modified: branches/DARWIN/none/tests/x86/insn_sse.vgtest
===================================================================
--- branches/DARWIN/none/tests/x86/insn_sse.vgtest 2009-02-15 22:04:20 UTC (rev 9174)
+++ branches/DARWIN/none/tests/x86/insn_sse.vgtest 2009-02-15 23:38:24 UTC (rev 9175)
@@ -1,3 +1,3 @@
prog: ../../../none/tests/x86/insn_sse
-prereq: ../../../tests/cputest x86-sse
+prereq: ../../../tests/arch_test x86-sse
vgopts: -q
Modified: branches/DARWIN/none/tests/x86/insn_sse2.vgtest
===================================================================
--- branches/DARWIN/none/tests/x86/insn_sse2.vgtest 2009-02-15 22:04:20 UTC (rev 9174)
+++ branches/DARWIN/none/tests/x86/insn_sse2.vgtest 2009-02-15 23:38:24 UTC (rev 9175)
@@ -1,3 +1,3 @@
prog: ../../../none/tests/x86/insn_sse2
-prereq: ../../../tests/cputest x86-sse2
+prereq: ../../../tests/arch_test x86-sse2
vgopts: -q
Modified: branches/DARWIN/none/tests/x86/insn_sse3.vgtest
===================================================================
--- branches/DARWIN/none/tests/x86/insn_sse3.vgtest 2009-02-15 22:04:20 UTC (rev 9174)
+++ branches/DARWIN/none/tests/x86/insn_sse3.vgtest 2009-02-15 23:38:24 UTC (rev 9175)
@@ -1,3 +1,3 @@
prog: ../../../none/tests/x86/insn_sse3
-prereq: ../../../tests/cputest x86-sse3
+prereq: ../../../tests/arch_test x86-sse3
vgopts: -q
Modified: branches/DARWIN/none/tests/x86/insn_ssse3.vgtest
===================================================================
--- branches/DARWIN/none/tests/x86/insn_ssse3.vgtest 2009-02-15 22:04:20 UTC (rev 9174)
+++ branches/DARWIN/none/tests/x86/insn_ssse3.vgtest 2009-02-15 23:38:24 UTC (rev 9175)
@@ -1,3 +1,3 @@
prog: ../../../none/tests/x86/insn_ssse3
-prereq: ../../../tests/cputest x86-sse3
+prereq: ../../../tests/arch_test x86-sse3
vgopts: -q
Modified: branches/DARWIN/none/tests/x86/ssse3_misaligned.vgtest
===================================================================
--- branches/DARWIN/none/tests/x86/ssse3_misaligned.vgtest 2009-02-15 22:04:20 UTC (rev 9174)
+++ branches/DARWIN/none/tests/x86/ssse3_misaligned.vgtest 2009-02-15 23:38:24 UTC (rev 9175)
@@ -1,3 +1,3 @@
prog: ssse3_misaligned
-prereq: ../../../tests/cputest x86-sse3
+prereq: ../../../tests/arch_test x86-sse3
vgopts: -q
Modified: branches/DARWIN/tests/Makefile.am
===================================================================
--- branches/DARWIN/tests/Makefile.am 2009-02-15 22:04:20 UTC (rev 9174)
+++ branches/DARWIN/tests/Makefile.am 2009-02-15 23:38:24 UTC (rev 9175)
@@ -3,19 +3,21 @@
include $(top_srcdir)/Makefile.flags.am
noinst_SCRIPTS = \
- vg_regtest \
filter_addresses \
filter_discards \
filter_libc \
filter_numbers \
filter_stderr_basic \
filter_sink \
- filter_test_paths
+ filter_test_paths \
+ os_test \
+ platform_test \
+ vg_regtest
EXTRA_DIST = $(noinst_SCRIPTS)
check_PROGRAMS = \
- cputest \
+ arch_test \
toobig-allocs \
true
@@ -23,7 +25,7 @@
AM_CXXFLAGS = $(AM_CFLAGS)
# generic C ones
-cputest_CFLAGS = $(AM_CFLAGS) \
+arch_test_CFLAGS = $(AM_CFLAGS) \
-DVGA_$(VGCONF_ARCH_PRI)=1 \
-DVGO_$(VGCONF_OS)=1 \
-DVGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS)=1
Copied: branches/DARWIN/tests/arch_test.c (from rev 9173, branches/DARWIN/tests/cputest.c)
===================================================================
--- branches/DARWIN/tests/arch_test.c (rev 0)
+++ branches/DARWIN/tests/arch_test.c 2009-02-15 23:38:24 UTC (rev 9175)
@@ -0,0 +1,207 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+// This file determines which architectures that this Valgrind installation
+// supports, which depends on the machine's architecture. It also depends
+// on the configuration options; for example, if Valgrind is installed on
+// an AMD64 machine but has been configured with --enable-only32bit then
+// this program will not match "amd64".
+//
+// We return:
+// - 0 if the machine matches the asked-for cpu
+// - 1 if it didn't match, but did match the name of another arch
+// - 2 otherwise
+
+// Nb: When updating this file for a new architecture, add the name to
+// 'all_archs' as well as adding go().
+
+#define False 0
+#define True 1
+typedef int Bool;
+
+char* all_archs[] = {
+ "amd64",
+ "ppc32",
+ "ppc64",
+ "x86",
+ NULL
+};
+
+//-----------------------------------------------------------------------------
+// ppc32-linux
+//---------------------------------------------------------------------------
+#if defined(VGP_ppc32_linux)
+static Bool go(char* cpu)
+{
+ if ( strcmp( cpu, "ppc32" ) == 0 )
+ return True;
+ return False;
+}
+#endif // VGP_ppc32_linux
+
+//---------------------------------------------------------------------------
+// ppc64-linux
+//---------------------------------------------------------------------------
+#if defined(VGP_ppc64_linux)
+static Bool go(char* cpu)
+{
+ if ( strcmp( cpu, "ppc64" ) == 0 )
+ return True;
+ if ( strcmp( cpu, "ppc32" ) == 0 )
+ return True;
+ return False;
+}
+#endif // VGP_ppc64_linux
+
+//---------------------------------------------------------------------------
+// ppc{32,64}-aix
+//---------------------------------------------------------------------------
+#if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5)
+static Bool go(char* cpu)
+{
+ if (sizeof(void*) == 8) {
+ /* cpu is in 64-bit mode */
+ if ( strcmp( cpu, "ppc64" ) == 0 )
+ return True;
+ if ( strcmp( cpu, "ppc32" ) == 0 )
+ return True;
+ } else {
+ if ( strcmp( cpu, "ppc32" ) == 0 )
+ return True;
+ }
+ return False;
+}
+#endif // VGP_ppc32_aix5 || VGP_ppc64_aix5
+
+//---------------------------------------------------------------------------
+// {x86,amd64}-linux (part 1 of 2)
+//---------------------------------------------------------------------------
+#if defined(VGP_x86_linux) || defined(VGP_amd64_linux)
+static void cpuid ( unsigned int n,
+ unsigned int* a, unsigned int* b,
+ unsigned int* c, unsigned int* d )
+{
+ __asm__ __volatile__ (
+ "cpuid"
+ : "=a" (*a), "=b" (*b), "=c" (*c), "=d" (*d) /* output */
+ : "0" (n) /* input */
+ );
+}
+#endif // VGP_x86_linux || VGP_amd64_linux
+
+//---------------------------------------------------------------------------
+// {x86,amd64}-darwin (part 1 of 2)
+//---------------------------------------------------------------------------
+#if defined(VGP_x86_darwin) || defined(VGP_amd64_darwin)
+static void cpuid ( unsigned int n,
+ unsigned int* a, unsigned int* b,
+ unsigned int* c, unsigned int* d )
+{
+ __asm__ __volatile__ (
+ "pushl %%eax\n\t"
+ "pushl %%ebx\n\t"
+ "pushl %%ecx\n\t"
+ "pushl %%edx\n\t"
+ "movl %4, %%eax\n\t"
+ "cpuid\n\t"
+ "movl %%eax,%0\n\t"
+ "movl %%ebx,%1\n\t"
+ "movl %%ecx,%2\n\t"
+ "movl %%edx,%3\n\t"
+ "popl %%edx\n\t"
+ "popl %%ecx\n\t"
+ "popl %%ebx\n\t"
+ "popl %%eax\n\t"
+ : "=m" (*a), "=m" (*b), "=m" (*c), "=m" (*d)
+ : "mr" (n)
+ );
+}
+#endif // VGP_x86_darwin || VGP_amd64_darwin
+
+//---------------------------------------------------------------------------
+// {x86,amd64}-{linux,darwin} (part 2 of 2)
+//---------------------------------------------------------------------------
+#if defined(VGP_x86_linux) || defined(VGP_amd64_linux) || \
+ defined(VGP_x86_darwin) || defined(VGP_amd64_darwin)
+static Bool go(char* cpu)
+{
+ unsigned int level = 0, cmask = 0, dmask = 0, a, b, c, d;
+
+ if ( strcmp( cpu, "x86" ) == 0 ) {
+ return True;
+ } else if ( strcmp( cpu, "x86-fpu" ) == 0 ) {
+ level = 1;
+ dmask = 1 << 0;
+ } else if ( strcmp( cpu, "x86-cmov" ) == 0 ) {
+ level = 1;
+ dmask = 1 << 15;
+ } else if ( strcmp( cpu, "x86-mmx" ) == 0 ) {
+ level = 1;
+ dmask = 1 << 23;
+ } else if ( strcmp( cpu, "x86-mmxext" ) == 0 ) {
+ level = 0x80000001;
+ dmask = 1 << 22;
+ } else if ( strcmp( cpu, "x86-sse" ) == 0 ) {
+ level = 1;
+ dmask = 1 << 25;
+ } else if ( strcmp( cpu, "x86-sse2" ) == 0 ) {
+ level = 1;
+ dmask = 1 << 26;
+ } else if ( strcmp( cpu, "x86-sse3" ) == 0 ) {
+ level = 1;
+ cmask = 1 << 0;
+ } else if ( strcmp( cpu, "x86-ssse3" ) == 0 ) {
+ level = 1;
+ cmask = 1 << 9;
+#if defined(VGA_amd64)
+ } else if ( strcmp( cpu, "amd64" ) == 0 ) {
+ return True;
+ } else if ( strcmp( cpu, "amd64-sse3" ) == 0 ) {
+ level = 1;
+ cmask = 1 << 0;
+ } else if ( strcmp( cpu, "amd64-ssse3" ) == 0 ) {
+ level = 1;
+ cmask = 1 << 9;
+#endif
+ } else {
+ return False;
+ }
+
+ assert( !(cmask != 0 && dmask != 0) );
+ assert( !(cmask == 0 && dmask == 0) );
+
+ cpuid( level & 0x80000000, &a, &b, &c, &d );
+
+ if ( a >= level ) {
+ cpuid( level, &a, &b, &c, &d );
+
+ if (dmask > 0 && (d & dmask) != 0) return True;
+ if (cmask > 0 && (c & cmask) != 0) return True;
+ }
+ return False;
+}
+#endif // VGP_x86_linux || VGP_amd64_linux ||
+ // VGP_x86_darwin || VGP_amd64_darwin
+
+
+//---------------------------------------------------------------------------
+// main
+//---------------------------------------------------------------------------
+int main(int argc, char **argv)
+{
+ int i;
+ if ( argc != 2 ) {
+ fprintf( stderr, "usage: arch_test <cpu-type>\n" );
+ exit( 2 );
+ }
+ if (go( argv[1] )) {
+ return 0; // matched
+ }
+ for (i = 0; NULL != all_archs[i]; i++) {
+ if ( strcmp( argv[1], all_archs[i] ) == 0 )
+ return 1;
+ }
+ return 2;
+}
Deleted: branches/DARWIN/tests/cputest.c
===================================================================
--- branches/DARWIN/tests/cputest.c 2009-02-15 22:04:20 UTC (rev 9174)
+++ branches/DARWIN/tests/cputest.c 2009-02-15 23:38:24 UTC (rev 9175)
@@ -1,207 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-
-// This file determines which architectures that this Valgrind installation
-// supports, which depends on the machine's architecture. It also depends
-// on the configuration options; for example, if Valgrind is installed on
-// an AMD64 machine but has been configured with --enable-only32bit then
-// this program will not match "amd64".
-//
-// We return:
-// - 0 if the machine matches the asked-for cpu
-// - 1 if it didn't match, but did match the name of another arch
-// - 2 otherwise
-
-// Nb: When updating this file for a new architecture, add the name to
-// 'all_archs' as well as adding go().
-
-#define False 0
-#define True 1
-typedef int Bool;
-
-char* all_archs[] = {
- "amd64",
- "ppc32",
- "ppc64",
- "x86",
- NULL
-};
-
-//-----------------------------------------------------------------------------
-// ppc32-linux
-//---------------------------------------------------------------------------
-#if defined(VGP_ppc32_linux)
-static Bool go(char* cpu)
-{
- if ( strcmp( cpu, "ppc32" ) == 0 )
- return True;
- return False;
-}
-#endif // VGP_ppc32_linux
-
-//---------------------------------------------------------------------------
-// ppc64-linux
-//---------------------------------------------------------------------------
-#if defined(VGP_ppc64_linux)
-static Bool go(char* cpu)
-{
- if ( strcmp( cpu, "ppc64" ) == 0 )
- return True;
- if ( strcmp( cpu, "ppc32" ) == 0 )
- return True;
- return False;
-}
-#endif // VGP_ppc64_linux
-
-//---------------------------------------------------------------------------
-// ppc{32,64}-aix
-//---------------------------------------------------------------------------
-#if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5)
-static Bool go(char* cpu)
-{
- if (sizeof(void*) == 8) {
- /* cpu is in 64-bit mode */
- if ( strcmp( cpu, "ppc64" ) == 0 )
- return True;
- if ( strcmp( cpu, "ppc32" ) == 0 )
- return True;
- } else {
- if ( strcmp( cpu, "ppc32" ) == 0 )
- return True;
- }
- return False;
-}
-#endif // VGP_ppc32_aix5 || VGP_ppc64_aix5
-
-//---------------------------------------------------------------------------
-// {x86,amd64}-linux (part 1 of 2)
-//---------------------------------------------------------------------------
-#if defined(VGP_x86_linux) || defined(VGP_amd64_linux)
-static void cpuid ( unsigned int n,
- unsigned int* a, unsigned int* b,
- unsigned int* c, unsigned int* d )
-{
- __asm__ __volatile__ (
- "cpuid"
- : "=a" (*a), "=b" (*b), "=c" (*c), "=d" (*d) /* output */
- : "0" (n) /* input */
- );
-}
-#endif // VGP_x86_linux || VGP_amd64_linux
-
-//---------------------------------------------------------------------------
-// {x86,amd64}-darwin (part 1 of 2)
-//---------------------------------------------------------------------------
-#if defined(VGP_x86_darwin) || defined(VGP_amd64_darwin)
-static void cpuid ( unsigned int n,
- unsigned int* a, unsigned int* b,
- unsigned int* c, unsigned int* d )
-{
- __asm__ __volatile__ (
- "pushl %%eax\n\t"
- "pushl %%ebx\n\t"
- "pushl %%ecx\n\t"
- "pushl %%edx\n\t"
- "movl %4, %%eax\n\t"
- "cpuid\n\t"
- "movl %%eax,%0\n\t"
- "movl %%ebx,%1\n\t"
- "movl %%ecx,%2\n\t"
- "movl %%edx,%3\n\t"
- "popl %%edx\n\t"
- "popl %%ecx\n\t"
- "popl %%ebx\n\t"
- "popl %%eax\n\t"
- : "=m" (*a), "=m" (*b), "=m" (*c), "=m" (*d)
- : "mr" (n)
- );
-}
-#endif // VGP_x86_darwin || VGP_amd64_darwin
-
-//---------------------------------------------------------------------------
-// {x86,amd64}-{linux,darwin} (part 2 of 2)
-//---------------------------------------------------------------------------
-#if defined(VGP_x86_linux) || defined(VGP_amd64_linux) || \
- defined(VGP_x86_darwin) || defined(VGP_amd64_darwin)
-static Bool go(char* cpu)
-{
- unsigned int level = 0, cmask = 0, dmask = 0, a, b, c, d;
-
- if ( strcmp( cpu, "x86" ) == 0 ) {
- return True;
- } else if ( strcmp( cpu, "x86-fpu" ) == 0 ) {
- level = 1;
- dmask = 1 << 0;
- } else if ( strcmp( cpu, "x86-cmov" ) == 0 ) {
- level = 1;
- dmask = 1 << 15;
- } else if ( strcmp( cpu, "x86-mmx" ) == 0 ) {
- level = 1;
- dmask = 1 << 23;
- } else if ( strcmp( cpu, "x86-mmxext" ) == 0 ) {
- level = 0x80000001;
- dmask = 1 << 22;
- } else if ( strcmp( cpu, "x86-sse" ) == 0 ) {
- level = 1;
- dmask = 1 << 25;
- } else if ( strcmp( cpu, "x86-sse2" ) == 0 ) {
- level = 1;
- dmask = 1 << 26;
- } else if ( strcmp( cpu, "x86-sse3" ) == 0 ) {
- level = 1;
- cmask = 1 << 0;
- } else if ( strcmp( cpu, "x86-ssse3" ) == 0 ) {
- level = 1;
- cmask = 1 << 9;
-#if defined(VGA_amd64)
- } else if ( strcmp( cpu, "amd64" ) == 0 ) {
- return True;
- } else if ( strcmp( cpu, "amd64-sse3" ) == 0 ) {
- level = 1;
- cmask = 1 << 0;
- } else if ( strcmp( cpu, "amd64-ssse3" ) == 0 ) {
- level = 1;
- cmask = 1 << 9;
-#endif
- } else {
- return False;
- }
-
- assert( !(cmask != 0 && dmask != 0) );
- assert( !(cmask == 0 && dmask == 0) );
-
- cpuid( level & 0x80000000, &a, &b, &c, &d );
-
- if ( a >= level ) {
- cpuid( level, &a, &b, &c, &d );
-
- if (dmask > 0 && (d & dmask) != 0) return True;
- if (cmask > 0 && (c & cmask) != 0) return True;
- }
- return False;
-}
-#endif // VGP_x86_linux || VGP_amd64_linux ||
- // VGP_x86_darwin || VGP_amd64_darwin
-
-
-//---------------------------------------------------------------------------
-// main
-//---------------------------------------------------------------------------
-int main(int argc, char **argv)
-{
- int i;
- if ( argc != 2 ) {
- fprintf( stderr, "usage: cputest <cpu-type>\n" );
- exit( 2 );
- }
- if (go( argv[1] )) {
- return 0; // matched
- }
- for (i = 0; NULL != all_archs[i]; i++) {
- if ( strcmp( argv[1], all_archs[i] ) == 0 )
- return 1;
- }
- return 2;
-}
Added: branches/DARWIN/tests/os_test.in
===================================================================
--- branches/DARWIN/tests/os_test.in (rev 0)
+++ branches/DARWIN/tests/os_test.in 2009-02-15 23:38:24 UTC (rev 9175)
@@ -0,0 +1,29 @@
+#! /bin/sh
+
+# This script determines which OSes that this Valgrind installation
+# supports, which depends on the machine's OS.
+# We return:
+# - 0 if the machine matches the asked-for OS
+# - 1 if it didn't match, but did match the name of another OS
+# - 2 otherwise
+
+# Nb: When updating this file for a new OS, add the name to 'all_OSes'.
+
+all_OSes="linux aix5 darwin"
+
+if [ $# -ne 1 ] ; then
+ echo "usage: os_test <os-type>"
+ exit 2;
+fi
+
+if [ $1 = @VGCONF_OS@ ] ; then
+ exit 0; # Matches this OS.
+fi
+
+for os in $all_OSes ; do
+ if [ $1 = $os ] ; then
+ exit 1; # Matches another Valgrind-supported OS.
+ fi
+done
+
+exit 2; # Doesn't match any Valgrind-supported OS.
Added: branches/DARWIN/tests/platform_test
===================================================================
--- branches/DARWIN/tests/platform_test (rev 0)
+++ branches/DARWIN/tests/platform_test 2009-02-15 23:38:24 UTC (rev 9175)
@@ -0,0 +1,37 @@
+#! /bin/sh
+
+# This script determines which platforms that this Valgrind installation
+# supports.
+# We return:
+# - 0 if the machine matches the asked-for platform
+# - 1 if it didn't match, but did match the name of another platform
+# - 2 otherwise
+
+# Nb: When updating this file for a new platform, add the name to
+# 'all_platforms'.
+
+all_platforms=
+all_platforms="$all_platforms x86-linux amd64-linux ppc32-linux ppc64-linux"
+all_platforms="$all_platforms ppc32-aix5 ppc64-aix5"
+all_platforms="$all_platforms x86-darwin amd64-darwin"
+
+if [ $# -ne 2 ] ; then
+ echo "usage: platform_test <arch-type> <OS-type>"
+ exit 2;
+fi
+
+# Get the directory holding the arch_test and os_test, which will be the same
+# as the one holding this script.
+dir=`dirname $0`
+
+if $dir/arch_test $1 && sh $dir/os_test $2 ; then
+ exit 0; # Matches this platform.
+fi
+
+for p in $all_platforms ; do
+ if [ $1-$2 = $p ] ; then
+ exit 1; # Matches another Valgrind-supported platform.
+ fi
+done
+
+exit 2; # Doesn't match any Valgrind-supported platform.
Modified: branches/DARWIN/tests/vg_regtest.in
===================================================================
--- branches/DARWIN/tests/vg_regtest.in 2009-02-15 22:04:20 UTC (rev 9174)
+++ branches/DARWIN/tests/vg_regtest.in 2009-02-15 23:38:24 UTC (rev 9175)
@@ -379,14 +379,18 @@
# Ignore dirs into which we should not recurse.
if ($dir =~ /^(BitKeeper|CVS|SCCS|docs|doc)$/) { return; }
- (-x "$tests_dir/tests/cputest") or die
- "vg_regtest: 'cputest' is missing. Did you forget to 'make check'?\n";
+ (-x "$tests_dir/tests/arch_test") or die
+ "vg_regtest: 'arch_test' is missing. Did you forget to 'make check'?\n";
# Ignore any dir whose name matches that of an architecture which is not
- # the architecture we are running on (eg. when running on x86, ignore ppc/
- # directories).
+ # the architecture we are running on. Eg. when running on x86, ignore
+ # ppc/ directories ('arch_test' returns 1 for this case). Likewise for
+ # the OS and platform.
# Nb: weird Perl-ism -- exit code of '1' is seen by Perl as 256...
- if (256 == system("$tests_dir/tests/cputest $dir")) { return; }
+ if (256 == system( "$tests_dir/tests/arch_test $dir")) { return; }
+ if (256 == system("sh $tests_dir/tests/os_test $dir")) { return; }
+ if ($dir =~ /(\w+)-(\w+)/ &&
+ 256 == system("sh $tests_dir/tests/platform_test $1 $2")) { return; }
chdir($dir) or die "Could not change into $dir\n";
|