ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/Solaris/which_sparc
Revision: 1.2
Committed: 1999-10-21T15:27:07Z (25 years, 1 month ago) by cebix
Branch: MAIN
CVS Tags: nigel-build-19, nigel-build-12, nigel-build-13, nigel-build-16, nigel-build-17, nigel-build-15, snapshot-21101999, snapshot-13072000, snapshot-22121999, snapshot-17022001, release-0_8-1, snapshot-15012002, snapshot-02111999, snapshot-29052001, release-0_9-1, HEAD
Changes since 1.1: +11 -7 lines
Log Message:
- integrated SPARC assembly optimizations

File Contents

# Content
1 #!/bin/sh
2
3 # which_sparc
4 #
5 # This script generates a program that tests for a SPARC processor class
6 # Program returns:
7 # 0 unknown SPARC processor
8 # 8 SPARC V8 `compliant' processor (umul instruction is legal)
9 # 9 SPARC V9 `compliant' processor (popc instruction is legal)
10 #
11 # The script prints:
12 # "unknown SPARC architecture"
13 # SPARC_V8
14 # SPARC_V9
15 #
16 # I hope this works for other machines and OS. Tested machines are:
17 # Sun Ultra 10 (Solaris 7), SPARC Station 5 (Solaris 2.5.1)
18 #
19 # Gwenole Beauchesne
20 # gb@dial.oleane.com
21
22 CC=gcc
23 PROG=./conftest
24 SOURCE=./conftest.c
25
26 if [ ! -x $PROG ]; then
27 cat > $SOURCE << EOF
28 #include <stdio.h>
29 #include <signal.h>
30
31 typedef unsigned int uint32;
32 typedef uint32 (*sparc_code_func)(void);
33
34 #define SPARC_UNKNOWN 0
35 #define SPARC_V8 8
36 #define SPARC_V9 9
37
38 #define MAX_CODE_SIZE 16
39 struct sparc_code_struct {
40 int version;
41 uint32 code[MAX_CODE_SIZE];
42 struct sparc_code_struct * next;
43 };
44 typedef struct sparc_code_struct sparc_code_struct;
45
46 static sparc_code_struct *current_test_code;
47
48 static sparc_code_struct unknown_sparc_code =
49 {
50 SPARC_UNKNOWN,
51 {
52 0x81C3E008, /* retl */
53 0x01000000 /* nop */
54 }
55 };
56
57 static sparc_code_struct sparc_v9_code =
58 {
59 SPARC_V9,
60 {
61 0x81C3E008, /* retl */
62 0x81702007 /* popc 7, %g0 */
63 }
64 };
65
66 static sparc_code_struct sparc_v8_code =
67 {
68 SPARC_V8,
69 {
70 0x90102002, /* mov 2, %o0 */
71 0x81C3E008, /* retl */
72 0x90520008 /* umul %o0, %o0, %o0 */
73 }
74 };
75
76 static void test_sparc_code(int unused_int)
77 {
78 sparc_code_struct *tested_code = current_test_code;
79
80 if (current_test_code == NULL)
81 exit(SPARC_UNKNOWN);
82
83 signal(SIGILL, test_sparc_code);
84 current_test_code = current_test_code->next;
85 (void) ((sparc_code_func)(tested_code->code))();
86 exit(tested_code->version);
87 }
88
89 int main(void)
90 {
91 sparc_v9_code.next = &sparc_v8_code;
92 sparc_v8_code.next = &unknown_sparc_code;
93 unknown_sparc_code.next = NULL;
94
95 signal(SIGILL, test_sparc_code);
96 current_test_code = &sparc_v9_code;
97 raise(SIGILL);
98
99 return 0;
100 }
101 EOF
102
103 $CC -o $PROG $SOURCE
104 if [ $? -ne 0 ]; then
105 echo "Error: could not compile the test program"
106 exit 1
107 fi
108
109 fi
110
111 $PROG
112 case $? in
113 0) echo "unknown SPARC architecture";;
114 8) echo "SPARC_V8";;
115 9) echo "SPARC_V9";;
116 esac
117
118 rm -f $PROG
119 rm -f $SOURCE
120
121 exit 0