Initialize static TLS for the benchmarks
[riscv-tests.git] / benchmarks / dhrystone / dhrystone.c
1 #include "dhrystone.h"
2
3 #ifndef REG
4 #define REG
5 /* REG becomes defined as empty */
6 /* i.e. no register variables */
7 #else
8 #undef REG
9 #define REG register
10 #endif
11
12 extern int Int_Glob;
13 extern char Ch_1_Glob;
14
15
16 void Proc_6(Enumeration Enum_Val_Par, Enumeration* Enum_Ref_Par)
17 /*********************************/
18 /* executed once */
19 /* Enum_Val_Par == Ident_3, Enum_Ref_Par becomes Ident_2 */
20 {
21 *Enum_Ref_Par = Enum_Val_Par;
22 if (! Func_3 (Enum_Val_Par))
23 /* then, not executed */
24 *Enum_Ref_Par = Ident_4;
25 switch (Enum_Val_Par)
26 {
27 case Ident_1:
28 *Enum_Ref_Par = Ident_1;
29 break;
30 case Ident_2:
31 if (Int_Glob > 100)
32 /* then */
33 *Enum_Ref_Par = Ident_1;
34 else *Enum_Ref_Par = Ident_4;
35 break;
36 case Ident_3: /* executed */
37 *Enum_Ref_Par = Ident_2;
38 break;
39 case Ident_4: break;
40 case Ident_5:
41 *Enum_Ref_Par = Ident_3;
42 break;
43 } /* switch */
44 } /* Proc_6 */
45
46
47 void Proc_7(int Int_1_Par_Val, int Int_2_Par_Val, int* Int_Par_Ref)
48 /**********************************************/
49 /* executed three times */
50 /* first call: Int_1_Par_Val == 2, Int_2_Par_Val == 3, */
51 /* Int_Par_Ref becomes 7 */
52 /* second call: Int_1_Par_Val == 10, Int_2_Par_Val == 5, */
53 /* Int_Par_Ref becomes 17 */
54 /* third call: Int_1_Par_Val == 6, Int_2_Par_Val == 10, */
55 /* Int_Par_Ref becomes 18 */
56 {
57 One_Fifty Int_Loc;
58
59 Int_Loc = Int_1_Par_Val + 2;
60 *Int_Par_Ref = Int_2_Par_Val + Int_Loc;
61 } /* Proc_7 */
62
63
64 void Proc_8(Arr_1_Dim Arr_1_Par_Ref, Arr_2_Dim Arr_2_Par_Ref, int Int_1_Par_Val, int Int_2_Par_Val)
65 /*********************************************************************/
66 /* executed once */
67 /* Int_Par_Val_1 == 3 */
68 /* Int_Par_Val_2 == 7 */
69 {
70 REG One_Fifty Int_Index;
71 REG One_Fifty Int_Loc;
72
73 Int_Loc = Int_1_Par_Val + 5;
74 Arr_1_Par_Ref [Int_Loc] = Int_2_Par_Val;
75 Arr_1_Par_Ref [Int_Loc+1] = Arr_1_Par_Ref [Int_Loc];
76 Arr_1_Par_Ref [Int_Loc+30] = Int_Loc;
77 for (Int_Index = Int_Loc; Int_Index <= Int_Loc+1; ++Int_Index)
78 Arr_2_Par_Ref [Int_Loc] [Int_Index] = Int_Loc;
79 Arr_2_Par_Ref [Int_Loc] [Int_Loc-1] += 1;
80 Arr_2_Par_Ref [Int_Loc+20] [Int_Loc] = Arr_1_Par_Ref [Int_Loc];
81 Int_Glob = 5;
82 } /* Proc_8 */
83
84
85 Enumeration Func_1 (char Ch_1_Par_Val, char Ch_2_Par_Val)
86 /*************************************************/
87 /* executed three times */
88 /* first call: Ch_1_Par_Val == 'H', Ch_2_Par_Val == 'R' */
89 /* second call: Ch_1_Par_Val == 'A', Ch_2_Par_Val == 'C' */
90 /* third call: Ch_1_Par_Val == 'B', Ch_2_Par_Val == 'C' */
91 {
92 Capital_Letter Ch_1_Loc;
93 Capital_Letter Ch_2_Loc;
94
95 Ch_1_Loc = Ch_1_Par_Val;
96 Ch_2_Loc = Ch_1_Loc;
97 if (Ch_2_Loc != Ch_2_Par_Val)
98 /* then, executed */
99 return (Ident_1);
100 else /* not executed */
101 {
102 Ch_1_Glob = Ch_1_Loc;
103 return (Ident_2);
104 }
105 } /* Func_1 */
106
107
108 Boolean Func_2(Str_30 Str_1_Par_Ref, Str_30 Str_2_Par_Ref)
109 /*************************************************/
110 /* executed once */
111 /* Str_1_Par_Ref == "DHRYSTONE PROGRAM, 1'ST STRING" */
112 /* Str_2_Par_Ref == "DHRYSTONE PROGRAM, 2'ND STRING" */
113 {
114 REG One_Thirty Int_Loc;
115 Capital_Letter Ch_Loc;
116
117 Int_Loc = 2;
118 while (Int_Loc <= 2) /* loop body executed once */
119 if (Func_1 (Str_1_Par_Ref[Int_Loc],
120 Str_2_Par_Ref[Int_Loc+1]) == Ident_1)
121 /* then, executed */
122 {
123 Ch_Loc = 'A';
124 Int_Loc += 1;
125 } /* if, while */
126 if (Ch_Loc >= 'W' && Ch_Loc < 'Z')
127 /* then, not executed */
128 Int_Loc = 7;
129 if (Ch_Loc == 'R')
130 /* then, not executed */
131 return (true);
132 else /* executed */
133 {
134 if (strcmp (Str_1_Par_Ref, Str_2_Par_Ref) > 0)
135 /* then, not executed */
136 {
137 Int_Loc += 7;
138 Int_Glob = Int_Loc;
139 return (true);
140 }
141 else /* executed */
142 return (false);
143 } /* if Ch_Loc */
144 } /* Func_2 */
145
146
147 Boolean Func_3(Enumeration Enum_Par_Val)
148 /***************************/
149 /* executed once */
150 /* Enum_Par_Val == Ident_3 */
151 {
152 Enumeration Enum_Loc;
153
154 Enum_Loc = Enum_Par_Val;
155 if (Enum_Loc == Ident_3)
156 /* then, executed */
157 return (true);
158 else /* not executed */
159 return (false);
160 } /* Func_3 */