dhry_2.c 6.2 KB

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