diff options
author | deraadt <> | 1995-10-18 08:49:34 +0000 |
---|---|---|
committer | deraadt <> | 1995-10-18 08:49:34 +0000 |
commit | a4f79641824cbf9f60ca9d1168d1fcc46717a82a (patch) | |
tree | 3a9a60a6831189695ecfa7eb6904bce69aec0bcb /src/regress/lib/libc/arch | |
parent | 0527d29da443886d92e9a418180c5b25a5f8d270 (diff) | |
download | openbsd-a4f79641824cbf9f60ca9d1168d1fcc46717a82a.tar.gz openbsd-a4f79641824cbf9f60ca9d1168d1fcc46717a82a.tar.bz2 openbsd-a4f79641824cbf9f60ca9d1168d1fcc46717a82a.zip |
initial import of NetBSD tree
Diffstat (limited to 'src/regress/lib/libc/arch')
-rw-r--r-- | src/regress/lib/libc/arch/alpha/Makefile | 10 | ||||
-rw-r--r-- | src/regress/lib/libc/arch/alpha/divremtest/Makefile | 29 | ||||
-rw-r--r-- | src/regress/lib/libc/arch/alpha/divremtest/divremtest.c | 183 | ||||
-rw-r--r-- | src/regress/lib/libc/arch/alpha/divremtest/mkcases.c | 63 | ||||
-rw-r--r-- | src/regress/lib/libc/arch/alpha/divremtest/mktestcases.c | 67 |
5 files changed, 352 insertions, 0 deletions
diff --git a/src/regress/lib/libc/arch/alpha/Makefile b/src/regress/lib/libc/arch/alpha/Makefile new file mode 100644 index 0000000000..b79a82b0e2 --- /dev/null +++ b/src/regress/lib/libc/arch/alpha/Makefile | |||
@@ -0,0 +1,10 @@ | |||
1 | # $NetBSD: Makefile,v 1.1 1995/04/24 05:53:31 cgd Exp $ | ||
2 | |||
3 | # do nothing here; none of the tests here can be run automatically | ||
4 | SUBDIR= | ||
5 | |||
6 | regress: _SUBDIRUSE | ||
7 | |||
8 | install: | ||
9 | |||
10 | .include <bsd.subdir.mk> | ||
diff --git a/src/regress/lib/libc/arch/alpha/divremtest/Makefile b/src/regress/lib/libc/arch/alpha/divremtest/Makefile new file mode 100644 index 0000000000..bd3b12f537 --- /dev/null +++ b/src/regress/lib/libc/arch/alpha/divremtest/Makefile | |||
@@ -0,0 +1,29 @@ | |||
1 | # $NetBSD: Makefile,v 1.1 1995/04/24 05:53:34 cgd Exp $ | ||
2 | |||
3 | PROG= divremtest | ||
4 | NOMAN= | ||
5 | |||
6 | CLEANFILES+= mkcases cases.c mktestcases testcases | ||
7 | |||
8 | divremtest.c: cases.c | ||
9 | |||
10 | cases.c: mkcases | ||
11 | /bin/rm -f cases.c | ||
12 | mkcases > cases.c | ||
13 | |||
14 | # a typical strategy to use this: | ||
15 | # compile a NetBSD divremtest binary, an OSF/1 divremtest binary, and an | ||
16 | # OSF/1 mktestcases binary. You then run mktestecases | divremtest -g | ||
17 | # on an OSF/1 machine, and pipe the output to an rsh to a NetBSD machine | ||
18 | # which then runs divremtest. You can test an infinite number of random | ||
19 | # values that way; I like to put a 'dd' in, so I can see how much I've done. | ||
20 | |||
21 | testcases: mktestcases divremtest | ||
22 | /bin/rm -f testcases | ||
23 | mktestcases | divremtest -g > testcases | ||
24 | |||
25 | regress: | ||
26 | @echo THIS TEST CANNOT BE RUN AUTOMATICALLY. | ||
27 | @false | ||
28 | |||
29 | .include <bsd.prog.mk> | ||
diff --git a/src/regress/lib/libc/arch/alpha/divremtest/divremtest.c b/src/regress/lib/libc/arch/alpha/divremtest/divremtest.c new file mode 100644 index 0000000000..fcf64c9384 --- /dev/null +++ b/src/regress/lib/libc/arch/alpha/divremtest/divremtest.c | |||
@@ -0,0 +1,183 @@ | |||
1 | /* $NetBSD: divremtest.c,v 1.1 1995/04/24 05:53:35 cgd Exp $ */ | ||
2 | |||
3 | /* | ||
4 | * Copyright (c) 1995 Christopher G. Demetriou | ||
5 | * All rights reserved. | ||
6 | * | ||
7 | * Redistribution and use in source and binary forms, with or without | ||
8 | * modification, are permitted provided that the following conditions | ||
9 | * are met: | ||
10 | * 1. Redistributions of source code must retain the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer. | ||
12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer in the | ||
14 | * documentation and/or other materials provided with the distribution. | ||
15 | * 3. All advertising materials mentioning features or use of this software | ||
16 | * must display the following acknowledgement: | ||
17 | * This product includes software developed by Christopher G. Demetriou | ||
18 | * for the NetBSD Project. | ||
19 | * 4. The name of the author may not be used to endorse or promote products | ||
20 | * derived from this software without specific prior written permission | ||
21 | * | ||
22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
23 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
24 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
25 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
27 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
31 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
32 | */ | ||
33 | |||
34 | #include <stdio.h> | ||
35 | #include <unistd.h> | ||
36 | #include <signal.h> | ||
37 | |||
38 | void testfile(); | ||
39 | void usage(); | ||
40 | |||
41 | int generate; | ||
42 | |||
43 | int | ||
44 | main(argc, argv) | ||
45 | int argc; | ||
46 | char **argv; | ||
47 | { | ||
48 | int c; | ||
49 | |||
50 | signal(SIGFPE, SIG_IGN); | ||
51 | |||
52 | while ((c = getopt(argc, argv, "g")) != -1) | ||
53 | switch (c) { | ||
54 | case 'g': | ||
55 | generate = 1; | ||
56 | break; | ||
57 | |||
58 | default: | ||
59 | usage(); | ||
60 | break; | ||
61 | } | ||
62 | |||
63 | argc -= optind; | ||
64 | argv += optind; | ||
65 | |||
66 | if (argc == 0) | ||
67 | testfile(); | ||
68 | else | ||
69 | for (; argc != 0; argc--, argv++) { | ||
70 | if (freopen(argv[0], "r", stdin) == NULL) { | ||
71 | fprintf(stderr, | ||
72 | "divremtest: couldn't open %s\n", | ||
73 | argv[0]); | ||
74 | exit(1); | ||
75 | } | ||
76 | |||
77 | testfile(); | ||
78 | } | ||
79 | |||
80 | exit(0); | ||
81 | } | ||
82 | |||
83 | void | ||
84 | testfile() | ||
85 | { | ||
86 | union operand { | ||
87 | unsigned long input; | ||
88 | int op_int; | ||
89 | unsigned int op_u_int; | ||
90 | long op_long; | ||
91 | unsigned long op_u_long; | ||
92 | } op1, op2, divres, modres, divwant, modwant; | ||
93 | char opspec[6]; | ||
94 | int encoded, i; | ||
95 | |||
96 | while (scanf("%6c %lx %lx %lx %lx\n", opspec, &op1.input, | ||
97 | &op2.input, &divwant.input, &modwant.input) != EOF) { | ||
98 | |||
99 | encoded = 0; | ||
100 | |||
101 | for (i = 0; i < 6; i += 2) { | ||
102 | int posval; | ||
103 | |||
104 | switch (opspec[i]) { | ||
105 | case '.': | ||
106 | posval = 0; | ||
107 | break; | ||
108 | case '-': | ||
109 | posval = 1; | ||
110 | break; | ||
111 | default: | ||
112 | fprintf(stderr, | ||
113 | "unknown signedness spec %c\n", | ||
114 | opspec[i]); | ||
115 | exit(1); | ||
116 | } | ||
117 | encoded |= posval << ((5 - i) * 4); | ||
118 | } | ||
119 | |||
120 | for (i = 1; i < 6; i += 2) { | ||
121 | int posval; | ||
122 | |||
123 | switch (opspec[i]) { | ||
124 | case 'i': | ||
125 | posval = 0; | ||
126 | break; | ||
127 | case 'l': | ||
128 | posval = 1; | ||
129 | break; | ||
130 | default: | ||
131 | fprintf(stderr, "unknown length spec %c\n", | ||
132 | opspec[i]); | ||
133 | exit(1); | ||
134 | } | ||
135 | encoded |= posval << ((5 - i) * 4); | ||
136 | } | ||
137 | |||
138 | /* KILL ME!!! */ | ||
139 | switch (encoded) { | ||
140 | |||
141 | #define TRY_IT(a, b, c) \ | ||
142 | divres.a = op1.b / op2.c; \ | ||
143 | modres.a = op1.b % op2.c; \ | ||
144 | if (generate) { \ | ||
145 | printf("%6s 0x%016lx 0x%016lx 0x%016lx 0x%016lx\n", \ | ||
146 | opspec, op1.input, op2.input, \ | ||
147 | divres.a, modres.a); \ | ||
148 | } else { \ | ||
149 | if ((divres.a != divwant.a) || \ | ||
150 | (modres.a != modwant.a)) { \ | ||
151 | fprintf(stderr, "%6s 0x%016lx 0x%016lx\n", \ | ||
152 | opspec, op1.input, op2.input); \ | ||
153 | fprintf(stderr, "FAILED:\n"); \ | ||
154 | fprintf(stderr, \ | ||
155 | "div:\twanted 0x%16lx, got 0x%16lx\n", \ | ||
156 | divwant.a, divres.a); \ | ||
157 | fprintf(stderr, \ | ||
158 | "mod:\twanted 0x%16lx, got 0x%16lx\n", \ | ||
159 | modwant.a, modres.a); \ | ||
160 | \ | ||
161 | exit(1); \ | ||
162 | } \ | ||
163 | } | ||
164 | |||
165 | #include "cases.c" | ||
166 | |||
167 | #undef TRY_IT | ||
168 | |||
169 | default: | ||
170 | fprintf(stderr, | ||
171 | "INTERNAL ERROR: unknown encoding %x\n", encoded); | ||
172 | exit(1); | ||
173 | } | ||
174 | } | ||
175 | } | ||
176 | |||
177 | void | ||
178 | usage() | ||
179 | { | ||
180 | |||
181 | fprintf(stderr, "usage: divremtest [-v] [testfile ...]\n"); | ||
182 | exit(1); | ||
183 | } | ||
diff --git a/src/regress/lib/libc/arch/alpha/divremtest/mkcases.c b/src/regress/lib/libc/arch/alpha/divremtest/mkcases.c new file mode 100644 index 0000000000..65ca17af4c --- /dev/null +++ b/src/regress/lib/libc/arch/alpha/divremtest/mkcases.c | |||
@@ -0,0 +1,63 @@ | |||
1 | /* $NetBSD: mkcases.c,v 1.1 1995/04/24 05:53:36 cgd Exp $ */ | ||
2 | |||
3 | /* | ||
4 | * Copyright (c) 1995 Christopher G. Demetriou | ||
5 | * All rights reserved. | ||
6 | * | ||
7 | * Redistribution and use in source and binary forms, with or without | ||
8 | * modification, are permitted provided that the following conditions | ||
9 | * are met: | ||
10 | * 1. Redistributions of source code must retain the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer. | ||
12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer in the | ||
14 | * documentation and/or other materials provided with the distribution. | ||
15 | * 3. All advertising materials mentioning features or use of this software | ||
16 | * must display the following acknowledgement: | ||
17 | * This product includes software developed by Christopher G. Demetriou | ||
18 | * for the NetBSD Project. | ||
19 | * 4. The name of the author may not be used to endorse or promote products | ||
20 | * derived from this software without specific prior written permission | ||
21 | * | ||
22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
23 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
24 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
25 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
27 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
31 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
32 | */ | ||
33 | |||
34 | char *tab[4] = { "u_int", "int", "u_long", "long" }; | ||
35 | |||
36 | int | ||
37 | main() | ||
38 | { | ||
39 | int i; | ||
40 | |||
41 | for (i = 0; i < 64; i++) { | ||
42 | printf( | ||
43 | " case 0x%d%d%d%d%d%d: /* %s <= %s op %s */\n", | ||
44 | (i >> 5) & 1, | ||
45 | (i >> 4) & 1, | ||
46 | (i >> 3) & 1, | ||
47 | (i >> 2) & 1, | ||
48 | (i >> 1) & 1, | ||
49 | (i >> 0) & 1, | ||
50 | tab[(i >> 4) & 0x3], | ||
51 | tab[(i >> 2) & 0x3], | ||
52 | tab[(i >> 0) & 0x3]); | ||
53 | printf( | ||
54 | " TRY_IT(op_%s, op_%s, op_%s);\n", | ||
55 | tab[(i >> 4) & 0x3], | ||
56 | tab[(i >> 2) & 0x3], | ||
57 | tab[(i >> 0) & 0x3]); | ||
58 | printf( | ||
59 | " break;\n\n"); | ||
60 | } | ||
61 | |||
62 | exit(0); | ||
63 | } | ||
diff --git a/src/regress/lib/libc/arch/alpha/divremtest/mktestcases.c b/src/regress/lib/libc/arch/alpha/divremtest/mktestcases.c new file mode 100644 index 0000000000..ef02d61d70 --- /dev/null +++ b/src/regress/lib/libc/arch/alpha/divremtest/mktestcases.c | |||
@@ -0,0 +1,67 @@ | |||
1 | /* $NetBSD: mktestcases.c,v 1.1 1995/04/24 05:53:37 cgd Exp $ */ | ||
2 | |||
3 | /* | ||
4 | * Copyright (c) 1995 Christopher G. Demetriou | ||
5 | * All rights reserved. | ||
6 | * | ||
7 | * Redistribution and use in source and binary forms, with or without | ||
8 | * modification, are permitted provided that the following conditions | ||
9 | * are met: | ||
10 | * 1. Redistributions of source code must retain the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer. | ||
12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer in the | ||
14 | * documentation and/or other materials provided with the distribution. | ||
15 | * 3. All advertising materials mentioning features or use of this software | ||
16 | * must display the following acknowledgement: | ||
17 | * This product includes software developed by Christopher G. Demetriou | ||
18 | * for the NetBSD Project. | ||
19 | * 4. The name of the author may not be used to endorse or promote products | ||
20 | * derived from this software without specific prior written permission | ||
21 | * | ||
22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
23 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
24 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
25 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
27 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
31 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
32 | */ | ||
33 | |||
34 | #include <stdio.h> | ||
35 | |||
36 | int | ||
37 | main() | ||
38 | { | ||
39 | int i, j; | ||
40 | unsigned long n1, n2; | ||
41 | |||
42 | srandom(time(NULL)); | ||
43 | |||
44 | for (i = 1; /* i < 10240 */ 1; i++) { | ||
45 | n1 = (unsigned) | ||
46 | (random() & ((random() & random()) | 0x80000000)); | ||
47 | n1 <<= 32; | ||
48 | n1 |= (unsigned)(random() & random() & random()); | ||
49 | |||
50 | n2 = (unsigned) | ||
51 | (random() & ((random() & random()) | 0x80000000)); | ||
52 | n2 <<= 32; | ||
53 | n2 |= (unsigned)(random() & random() & random()); | ||
54 | |||
55 | for (j = 0; j < 64; j++) { | ||
56 | char *tab[] = { ".i", ".l", "-i", "-l" }; | ||
57 | |||
58 | printf("%s%s%s 0x%lx 0x%lx 0 0\n", | ||
59 | tab[(j >> 4) & 0x3], | ||
60 | tab[(j >> 2) & 0x3], | ||
61 | tab[(j >> 0) & 0x3], | ||
62 | n1, n2); | ||
63 | } | ||
64 | } | ||
65 | |||
66 | exit(0); | ||
67 | } | ||