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