// See LICENSE for license details.
+#pragma GCC optimize ("no-inline")
+
#include "dhrystone.h"
#ifndef REG
extern char Ch_1_Glob;
-void Proc_6(Enumeration Enum_Val_Par, Enumeration* Enum_Ref_Par)
+Proc_6 (Enum_Val_Par, Enum_Ref_Par)
/*********************************/
/* executed once */
/* Enum_Val_Par == Ident_3, Enum_Ref_Par becomes Ident_2 */
+
+Enumeration Enum_Val_Par;
+Enumeration *Enum_Ref_Par;
{
*Enum_Ref_Par = Enum_Val_Par;
if (! Func_3 (Enum_Val_Par))
} /* Proc_6 */
-void Proc_7(int Int_1_Par_Val, int Int_2_Par_Val, int* Int_Par_Ref)
+Proc_7 (Int_1_Par_Val, Int_2_Par_Val, Int_Par_Ref)
/**********************************************/
/* executed three times */
/* first call: Int_1_Par_Val == 2, Int_2_Par_Val == 3, */
/* Int_Par_Ref becomes 17 */
/* third call: Int_1_Par_Val == 6, Int_2_Par_Val == 10, */
/* Int_Par_Ref becomes 18 */
+One_Fifty Int_1_Par_Val;
+One_Fifty Int_2_Par_Val;
+One_Fifty *Int_Par_Ref;
{
One_Fifty Int_Loc;
} /* Proc_7 */
-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)
+Proc_8 (Arr_1_Par_Ref, Arr_2_Par_Ref, Int_1_Par_Val, Int_2_Par_Val)
/*********************************************************************/
/* executed once */
/* Int_Par_Val_1 == 3 */
/* Int_Par_Val_2 == 7 */
+Arr_1_Dim Arr_1_Par_Ref;
+Arr_2_Dim Arr_2_Par_Ref;
+int Int_1_Par_Val;
+int Int_2_Par_Val;
{
REG One_Fifty Int_Index;
REG One_Fifty Int_Loc;
} /* Proc_8 */
-Enumeration Func_1 (char Ch_1_Par_Val, char Ch_2_Par_Val)
+Enumeration Func_1 (Ch_1_Par_Val, Ch_2_Par_Val)
/*************************************************/
/* executed three times */
/* first call: Ch_1_Par_Val == 'H', Ch_2_Par_Val == 'R' */
/* second call: Ch_1_Par_Val == 'A', Ch_2_Par_Val == 'C' */
/* third call: Ch_1_Par_Val == 'B', Ch_2_Par_Val == 'C' */
+
+Capital_Letter Ch_1_Par_Val;
+Capital_Letter Ch_2_Par_Val;
{
Capital_Letter Ch_1_Loc;
Capital_Letter Ch_2_Loc;
} /* Func_1 */
-Boolean Func_2(Str_30 Str_1_Par_Ref, Str_30 Str_2_Par_Ref)
+Boolean Func_2 (Str_1_Par_Ref, Str_2_Par_Ref)
/*************************************************/
/* executed once */
/* Str_1_Par_Ref == "DHRYSTONE PROGRAM, 1'ST STRING" */
/* Str_2_Par_Ref == "DHRYSTONE PROGRAM, 2'ND STRING" */
+
+Str_30 Str_1_Par_Ref;
+Str_30 Str_2_Par_Ref;
{
REG One_Thirty Int_Loc;
Capital_Letter Ch_Loc;
} /* Func_2 */
-Boolean Func_3(Enumeration Enum_Par_Val)
+Boolean Func_3 (Enum_Par_Val)
/***************************/
/* executed once */
/* Enum_Par_Val == Ident_3 */
+Enumeration Enum_Par_Val;
{
Enumeration Enum_Loc;
else /* not executed */
return (false);
} /* Func_3 */
+
// You should not change anything except the HOST_DEBUG and
// PREALLOCATE macros for your timing run.
+#pragma GCC optimize ("no-inline")
+
#include "dhrystone.h"
//--------------------------------------------------------------------------
#endif
#if HOST_DEBUG
-# define do_fprintf fprintf
+# define debug_printf printf
#else
-int __attribute__((noinline)) do_fprintf(FILE* f, const char* str, ...)
+void debug_printf(const char* str, ...)
{
return 0;
}
int Arr_1_Glob [50];
int Arr_2_Glob [50] [50];
+extern char *malloc ();
+Enumeration Func_1 ();
+ /* forward declaration necessary since Enumeration may not simply be int */
+
#ifndef REG
Boolean Reg = false;
#define REG
long Begin_Time,
End_Time,
User_Time;
-float Microseconds,
+long Microseconds,
Dhrystones_Per_Second;
/* end of variables for time measurement */
#if HOST_DEBUG
if (argc > 2)
{
- do_fprintf (stdout, "Usage: %s [number of loops]\n", argv[0]);
+ printf("Usage: %s [number of loops]\n", argv[0]);
exit (1);
}
if (argc == 2)
{
Number_Of_Runs = atoi (argv[1]);
- } else
-#endif
- {
- Number_Of_Runs = NUMBER_OF_RUNS;
}
- if (Number_Of_Runs <= 0)
+ else if (Number_Of_Runs <= 0)
+#endif
{
Number_Of_Runs = NUMBER_OF_RUNS;
}
/* Warning: With 16-Bit processors and Number_Of_Runs > 32000, */
/* overflow may occur for this array element. */
-#if HOST_DEBUG
- do_fprintf (stdout, "\n");
- do_fprintf (stdout, "Dhrystone Benchmark, Version %s\n", Version);
+ debug_printf("\n");
+ debug_printf("Dhrystone Benchmark, Version %s\n", Version);
if (Reg)
{
- do_fprintf (stdout, "Program compiled with 'register' attribute\n");
+ debug_printf("Program compiled with 'register' attribute\n");
}
else
{
- do_fprintf (stdout, "Program compiled without 'register' attribute\n");
+ debug_printf("Program compiled without 'register' attribute\n");
}
- do_fprintf (stdout, "Using %s, HZ=%d\n", CLOCK_TYPE, HZ);
- do_fprintf (stdout, "\n");
-#endif
+ debug_printf("Using %s, HZ=%d\n", CLOCK_TYPE, HZ);
+ debug_printf("\n");
Done = false;
while (!Done) {
-#if HOST_DEBUG
- do_fprintf (stdout, "Trying %d runs through Dhrystone:\n", Number_Of_Runs);
-#endif
+ debug_printf("Trying %d runs through Dhrystone:\n", Number_Of_Runs);
/***************/
/* Start timer */
if (User_Time < Too_Small_Time)
{
- do_fprintf (stdout, "Measured time too small to obtain meaningful results\n");
+ printf("Measured time too small to obtain meaningful results\n");
Number_Of_Runs = Number_Of_Runs * 10;
- do_fprintf (stdout, "\n");
+ printf("\n");
} else Done = true;
}
- do_fprintf (stderr, "Final values of the variables used in the benchmark:\n");
- do_fprintf (stderr, "\n");
- do_fprintf (stderr, "Int_Glob: %d\n", Int_Glob);
- do_fprintf (stderr, " should be: %d\n", 5);
- do_fprintf (stderr, "Bool_Glob: %d\n", Bool_Glob);
- do_fprintf (stderr, " should be: %d\n", 1);
- do_fprintf (stderr, "Ch_1_Glob: %c\n", Ch_1_Glob);
- do_fprintf (stderr, " should be: %c\n", 'A');
- do_fprintf (stderr, "Ch_2_Glob: %c\n", Ch_2_Glob);
- do_fprintf (stderr, " should be: %c\n", 'B');
- do_fprintf (stderr, "Arr_1_Glob[8]: %d\n", Arr_1_Glob[8]);
- do_fprintf (stderr, " should be: %d\n", 7);
- do_fprintf (stderr, "Arr_2_Glob[8][7]: %d\n", Arr_2_Glob[8][7]);
- do_fprintf (stderr, " should be: Number_Of_Runs + 10\n");
- do_fprintf (stderr, "Ptr_Glob->\n");
- do_fprintf (stderr, " Ptr_Comp: %d\n", (long) Ptr_Glob->Ptr_Comp);
- do_fprintf (stderr, " should be: (implementation-dependent)\n");
- do_fprintf (stderr, " Discr: %d\n", Ptr_Glob->Discr);
- do_fprintf (stderr, " should be: %d\n", 0);
- do_fprintf (stderr, " Enum_Comp: %d\n", Ptr_Glob->variant.var_1.Enum_Comp);
- do_fprintf (stderr, " should be: %d\n", 2);
- do_fprintf (stderr, " Int_Comp: %d\n", Ptr_Glob->variant.var_1.Int_Comp);
- do_fprintf (stderr, " should be: %d\n", 17);
- do_fprintf (stderr, " Str_Comp: %s\n", Ptr_Glob->variant.var_1.Str_Comp);
- do_fprintf (stderr, " should be: DHRYSTONE PROGRAM, SOME STRING\n");
- do_fprintf (stderr, "Next_Ptr_Glob->\n");
- do_fprintf (stderr, " Ptr_Comp: %d\n", (long) Next_Ptr_Glob->Ptr_Comp);
- do_fprintf (stderr, " should be: (implementation-dependent), same as above\n");
- do_fprintf (stderr, " Discr: %d\n", Next_Ptr_Glob->Discr);
- do_fprintf (stderr, " should be: %d\n", 0);
- do_fprintf (stderr, " Enum_Comp: %d\n", Next_Ptr_Glob->variant.var_1.Enum_Comp);
- do_fprintf (stderr, " should be: %d\n", 1);
- do_fprintf (stderr, " Int_Comp: %d\n", Next_Ptr_Glob->variant.var_1.Int_Comp);
- do_fprintf (stderr, " should be: %d\n", 18);
- do_fprintf (stderr, " Str_Comp: %s\n",
+ debug_printf("Final values of the variables used in the benchmark:\n");
+ debug_printf("\n");
+ debug_printf("Int_Glob: %d\n", Int_Glob);
+ debug_printf(" should be: %d\n", 5);
+ debug_printf("Bool_Glob: %d\n", Bool_Glob);
+ debug_printf(" should be: %d\n", 1);
+ debug_printf("Ch_1_Glob: %c\n", Ch_1_Glob);
+ debug_printf(" should be: %c\n", 'A');
+ debug_printf("Ch_2_Glob: %c\n", Ch_2_Glob);
+ debug_printf(" should be: %c\n", 'B');
+ debug_printf("Arr_1_Glob[8]: %d\n", Arr_1_Glob[8]);
+ debug_printf(" should be: %d\n", 7);
+ debug_printf("Arr_2_Glob[8][7]: %d\n", Arr_2_Glob[8][7]);
+ debug_printf(" should be: Number_Of_Runs + 10\n");
+ debug_printf("Ptr_Glob->\n");
+ debug_printf(" Ptr_Comp: %d\n", (long) Ptr_Glob->Ptr_Comp);
+ debug_printf(" should be: (implementation-dependent)\n");
+ debug_printf(" Discr: %d\n", Ptr_Glob->Discr);
+ debug_printf(" should be: %d\n", 0);
+ debug_printf(" Enum_Comp: %d\n", Ptr_Glob->variant.var_1.Enum_Comp);
+ debug_printf(" should be: %d\n", 2);
+ debug_printf(" Int_Comp: %d\n", Ptr_Glob->variant.var_1.Int_Comp);
+ debug_printf(" should be: %d\n", 17);
+ debug_printf(" Str_Comp: %s\n", Ptr_Glob->variant.var_1.Str_Comp);
+ debug_printf(" should be: DHRYSTONE PROGRAM, SOME STRING\n");
+ debug_printf("Next_Ptr_Glob->\n");
+ debug_printf(" Ptr_Comp: %d\n", (long) Next_Ptr_Glob->Ptr_Comp);
+ debug_printf(" should be: (implementation-dependent), same as above\n");
+ debug_printf(" Discr: %d\n", Next_Ptr_Glob->Discr);
+ debug_printf(" should be: %d\n", 0);
+ debug_printf(" Enum_Comp: %d\n", Next_Ptr_Glob->variant.var_1.Enum_Comp);
+ debug_printf(" should be: %d\n", 1);
+ debug_printf(" Int_Comp: %d\n", Next_Ptr_Glob->variant.var_1.Int_Comp);
+ debug_printf(" should be: %d\n", 18);
+ debug_printf(" Str_Comp: %s\n",
Next_Ptr_Glob->variant.var_1.Str_Comp);
- do_fprintf (stderr, " should be: DHRYSTONE PROGRAM, SOME STRING\n");
- do_fprintf (stderr, "Int_1_Loc: %d\n", Int_1_Loc);
- do_fprintf (stderr, " should be: %d\n", 5);
- do_fprintf (stderr, "Int_2_Loc: %d\n", Int_2_Loc);
- do_fprintf (stderr, " should be: %d\n", 13);
- do_fprintf (stderr, "Int_3_Loc: %d\n", Int_3_Loc);
- do_fprintf (stderr, " should be: %d\n", 7);
- do_fprintf (stderr, "Enum_Loc: %d\n", Enum_Loc);
- do_fprintf (stderr, " should be: %d\n", 1);
- do_fprintf (stderr, "Str_1_Loc: %s\n", Str_1_Loc);
- do_fprintf (stderr, " should be: DHRYSTONE PROGRAM, 1'ST STRING\n");
- do_fprintf (stderr, "Str_2_Loc: %s\n", Str_2_Loc);
- do_fprintf (stderr, " should be: DHRYSTONE PROGRAM, 2'ND STRING\n");
- do_fprintf (stderr, "\n");
-
-
-#if HOST_DEBUG
- Microseconds = (float) User_Time * Mic_secs_Per_Second
- / ((float) HZ * ((float) Number_Of_Runs));
- Dhrystones_Per_Second = ((float) HZ * (float) Number_Of_Runs)
- / (float) User_Time;
-
- do_fprintf (stdout, "Microseconds for one run through Dhrystone: ");
- do_fprintf (stdout, "%10.1f \n", Microseconds);
- do_fprintf (stdout, "Dhrystones per Second: ");
- do_fprintf (stdout, "%10.0f \n", Dhrystones_Per_Second);
- do_fprintf (stdout, "\n");
-#endif
+ debug_printf(" should be: DHRYSTONE PROGRAM, SOME STRING\n");
+ debug_printf("Int_1_Loc: %d\n", Int_1_Loc);
+ debug_printf(" should be: %d\n", 5);
+ debug_printf("Int_2_Loc: %d\n", Int_2_Loc);
+ debug_printf(" should be: %d\n", 13);
+ debug_printf("Int_3_Loc: %d\n", Int_3_Loc);
+ debug_printf(" should be: %d\n", 7);
+ debug_printf("Enum_Loc: %d\n", Enum_Loc);
+ debug_printf(" should be: %d\n", 1);
+ debug_printf("Str_1_Loc: %s\n", Str_1_Loc);
+ debug_printf(" should be: DHRYSTONE PROGRAM, 1'ST STRING\n");
+ debug_printf("Str_2_Loc: %s\n", Str_2_Loc);
+ debug_printf(" should be: DHRYSTONE PROGRAM, 2'ND STRING\n");
+ debug_printf("\n");
+
+
+ Microseconds = ((User_Time / Number_Of_Runs) * Mic_secs_Per_Second) / HZ;
+ Dhrystones_Per_Second = (HZ * Number_Of_Runs) / User_Time;
+
+ printf("Microseconds for one run through Dhrystone: %ld\n", Microseconds);
+ printf("Dhrystones per Second: %ld\n", Dhrystones_Per_Second);
return 0;
}
-void Proc_1(Rec_Pointer Ptr_Val_Par)
+Proc_1 (Ptr_Val_Par)
/******************/
+
+REG Rec_Pointer Ptr_Val_Par;
/* executed once */
{
REG Rec_Pointer Next_Record = Ptr_Val_Par->Ptr_Comp;
} /* Proc_1 */
-void Proc_2(int* Int_Par_Ref)
+Proc_2 (Int_Par_Ref)
/******************/
/* executed once */
/* *Int_Par_Ref == 1, becomes 4 */
+
+One_Fifty *Int_Par_Ref;
{
One_Fifty Int_Loc;
Enumeration Enum_Loc;
} /* Proc_2 */
-void Proc_3(Rec_Pointer* Ptr_Ref_Par)
+Proc_3 (Ptr_Ref_Par)
/******************/
/* executed once */
/* Ptr_Ref_Par becomes Ptr_Glob */
+
+Rec_Pointer *Ptr_Ref_Par;
+
{
if (Ptr_Glob != Null)
/* then, executed */
} /* Proc_3 */
-void Proc_4()
+Proc_4 () /* without parameters */
/*******/
/* executed once */
{
} /* Proc_4 */
-void Proc_5()
+Proc_5 () /* without parameters */
/*******/
/* executed once */
{