]>
Commit | Line | Data |
---|---|---|
d1389403 SG |
1 | /* |
2 | * (C) Copyright 2015 Google, Inc | |
3 | * | |
4 | * SPDX-License-Identifier: GPL-2.0+ | |
5 | * | |
6 | * Dhrystone is widely available in the public domain. A GPL license is | |
7 | * chosen for U-Boot. | |
8 | */ | |
9 | ||
10 | /***************************************************************************** | |
11 | * The BYTE UNIX Benchmarks - Release 3 | |
12 | * Module: dhry_2.c SID: 3.4 5/15/91 19:30:22 | |
13 | * | |
14 | ***************************************************************************** | |
15 | * Bug reports, patches, comments, suggestions should be sent to: | |
16 | * | |
17 | * Ben Smith, Rick Grehan or Tom Yager | |
18 | * ben@bytepb.byte.com rick_g@bytepb.byte.com tyager@bytepb.byte.com | |
19 | * | |
20 | ***************************************************************************** | |
21 | * Modification Log: | |
22 | * 10/22/97 - code cleanup to remove ANSI C compiler warnings | |
23 | * Andy Kahn <kahn@zk3.dec.com> | |
24 | * | |
25 | * Adapted from: | |
26 | * | |
27 | * "DHRYSTONE" Benchmark Program | |
28 | * ----------------------------- | |
29 | * | |
30 | * **** WARNING **** See warning in n.dhry_1.c | |
31 | * | |
32 | * Version: C, Version 2.1 | |
33 | * | |
34 | * File: dhry_2.c (part 3 of 3) | |
35 | * | |
36 | * Date: May 25, 1988 | |
37 | * | |
38 | * Author: Reinhold P. Weicker | |
39 | * | |
40 | ****************************************************************************/ | |
41 | /* SCCSid is defined in dhry_1.c */ | |
42 | ||
43 | #include <common.h> | |
44 | #include "dhry.h" | |
45 | ||
46 | #ifndef REG | |
47 | #define REG | |
48 | /* REG becomes defined as empty */ | |
49 | /* i.e. no register variables */ | |
50 | #endif | |
51 | ||
52 | extern int Int_Glob; | |
53 | extern char Ch_1_Glob; | |
54 | ||
55 | void Proc_6(Enumeration, Enumeration *); | |
56 | void Proc_7(One_Fifty, One_Fifty, One_Fifty *); | |
57 | void Proc_8(Arr_1_Dim, Arr_2_Dim, int, int); | |
58 | Enumeration Func_1(Capital_Letter, Capital_Letter); | |
59 | Boolean Func_2(Str_30, Str_30); | |
60 | Boolean Func_3(Enumeration); | |
61 | ||
62 | void Proc_6 (Enumeration Enum_Val_Par, Enumeration *Enum_Ref_Par) | |
63 | /* executed once */ | |
64 | /* Enum_Val_Par == Ident_3, Enum_Ref_Par becomes Ident_2 */ | |
65 | { | |
66 | *Enum_Ref_Par = Enum_Val_Par; | |
67 | if (! Func_3 (Enum_Val_Par)) | |
68 | /* then, not executed */ | |
69 | *Enum_Ref_Par = Ident_4; | |
70 | switch (Enum_Val_Par) | |
71 | { | |
72 | case Ident_1: | |
73 | *Enum_Ref_Par = Ident_1; | |
74 | break; | |
75 | case Ident_2: | |
76 | if (Int_Glob > 100) | |
77 | /* then */ | |
78 | *Enum_Ref_Par = Ident_1; | |
79 | else *Enum_Ref_Par = Ident_4; | |
80 | break; | |
81 | case Ident_3: /* executed */ | |
82 | *Enum_Ref_Par = Ident_2; | |
83 | break; | |
84 | case Ident_4: break; | |
85 | case Ident_5: | |
86 | *Enum_Ref_Par = Ident_3; | |
87 | break; | |
88 | } /* switch */ | |
89 | } /* Proc_6 */ | |
90 | ||
91 | void Proc_7 (Int_1_Par_Val, Int_2_Par_Val, Int_Par_Ref) | |
92 | One_Fifty Int_1_Par_Val; | |
93 | One_Fifty Int_2_Par_Val; | |
94 | One_Fifty *Int_Par_Ref; | |
95 | /**********************************************/ | |
96 | /* executed three times */ | |
97 | /* first call: Int_1_Par_Val == 2, Int_2_Par_Val == 3, */ | |
98 | /* Int_Par_Ref becomes 7 */ | |
99 | /* second call: Int_1_Par_Val == 10, Int_2_Par_Val == 5, */ | |
100 | /* Int_Par_Ref becomes 17 */ | |
101 | /* third call: Int_1_Par_Val == 6, Int_2_Par_Val == 10, */ | |
102 | /* Int_Par_Ref becomes 18 */ | |
103 | { | |
104 | One_Fifty Int_Loc; | |
105 | ||
106 | Int_Loc = Int_1_Par_Val + 2; | |
107 | *Int_Par_Ref = Int_2_Par_Val + Int_Loc; | |
108 | } /* Proc_7 */ | |
109 | ||
110 | ||
111 | void Proc_8 (Arr_1_Par_Ref, Arr_2_Par_Ref, Int_1_Par_Val, Int_2_Par_Val) | |
112 | /*********************************************************************/ | |
113 | /* executed once */ | |
114 | /* Int_Par_Val_1 == 3 */ | |
115 | /* Int_Par_Val_2 == 7 */ | |
116 | Arr_1_Dim Arr_1_Par_Ref; | |
117 | Arr_2_Dim Arr_2_Par_Ref; | |
118 | int Int_1_Par_Val; | |
119 | int Int_2_Par_Val; | |
120 | { | |
121 | REG One_Fifty Int_Index; | |
122 | REG One_Fifty Int_Loc; | |
123 | ||
124 | Int_Loc = Int_1_Par_Val + 5; | |
125 | Arr_1_Par_Ref [Int_Loc] = Int_2_Par_Val; | |
126 | Arr_1_Par_Ref [Int_Loc+1] = Arr_1_Par_Ref [Int_Loc]; | |
127 | Arr_1_Par_Ref [Int_Loc+30] = Int_Loc; | |
128 | for (Int_Index = Int_Loc; Int_Index <= Int_Loc+1; ++Int_Index) | |
129 | Arr_2_Par_Ref [Int_Loc] [Int_Index] = Int_Loc; | |
130 | Arr_2_Par_Ref [Int_Loc] [Int_Loc-1] += 1; | |
131 | Arr_2_Par_Ref [Int_Loc+20] [Int_Loc] = Arr_1_Par_Ref [Int_Loc]; | |
132 | Int_Glob = 5; | |
133 | } /* Proc_8 */ | |
134 | ||
135 | ||
136 | Enumeration Func_1 (Capital_Letter Ch_1_Par_Val, Capital_Letter Ch_2_Par_Val) | |
137 | /*************************************************/ | |
138 | /* executed three times */ | |
139 | /* first call: Ch_1_Par_Val == 'H', Ch_2_Par_Val == 'R' */ | |
140 | /* second call: Ch_1_Par_Val == 'A', Ch_2_Par_Val == 'C' */ | |
141 | /* third call: Ch_1_Par_Val == 'B', Ch_2_Par_Val == 'C' */ | |
142 | { | |
143 | Capital_Letter Ch_1_Loc; | |
144 | Capital_Letter Ch_2_Loc; | |
145 | ||
146 | Ch_1_Loc = Ch_1_Par_Val; | |
147 | Ch_2_Loc = Ch_1_Loc; | |
148 | if (Ch_2_Loc != Ch_2_Par_Val) | |
149 | /* then, executed */ | |
150 | return (Ident_1); | |
151 | else /* not executed */ | |
152 | { | |
153 | Ch_1_Glob = Ch_1_Loc; | |
154 | return (Ident_2); | |
155 | } | |
156 | } /* Func_1 */ | |
157 | ||
158 | ||
159 | ||
160 | Boolean Func_2 (Str_1_Par_Ref, Str_2_Par_Ref) | |
161 | /*************************************************/ | |
162 | /* executed once */ | |
163 | /* Str_1_Par_Ref == "DHRYSTONE PROGRAM, 1'ST STRING" */ | |
164 | /* Str_2_Par_Ref == "DHRYSTONE PROGRAM, 2'ND STRING" */ | |
165 | ||
166 | Str_30 Str_1_Par_Ref; | |
167 | Str_30 Str_2_Par_Ref; | |
168 | { | |
169 | REG One_Thirty Int_Loc; | |
170 | Capital_Letter Ch_Loc; | |
171 | ||
172 | Ch_Loc = 'A'; | |
173 | Int_Loc = 2; | |
174 | while (Int_Loc <= 2) /* loop body executed once */ | |
175 | if (Func_1 (Str_1_Par_Ref[Int_Loc], | |
176 | Str_2_Par_Ref[Int_Loc+1]) == Ident_1) | |
177 | /* then, executed */ | |
178 | { | |
179 | Ch_Loc = 'A'; | |
180 | Int_Loc += 1; | |
181 | } /* if, while */ | |
182 | if (Ch_Loc >= 'W' && Ch_Loc < 'Z') | |
183 | /* then, not executed */ | |
184 | Int_Loc = 7; | |
185 | if (Ch_Loc == 'R') | |
186 | /* then, not executed */ | |
187 | return (true); | |
188 | else /* executed */ | |
189 | { | |
190 | if (strcmp (Str_1_Par_Ref, Str_2_Par_Ref) > 0) | |
191 | /* then, not executed */ | |
192 | { | |
193 | Int_Loc += 7; | |
194 | Int_Glob = Int_Loc; | |
195 | return (true); | |
196 | } | |
197 | else /* executed */ | |
198 | return (false); | |
199 | } /* if Ch_Loc */ | |
200 | } /* Func_2 */ | |
201 | ||
202 | ||
203 | Boolean Func_3 (Enum_Par_Val) | |
204 | /***************************/ | |
205 | /* executed once */ | |
206 | /* Enum_Par_Val == Ident_3 */ | |
207 | Enumeration Enum_Par_Val; | |
208 | { | |
209 | Enumeration Enum_Loc; | |
210 | ||
211 | Enum_Loc = Enum_Par_Val; | |
212 | if (Enum_Loc == Ident_3) | |
213 | /* then, executed */ | |
214 | return (true); | |
215 | else /* not executed */ | |
216 | return (false); | |
217 | } /* Func_3 */ |