1 //=============================================================================
2 //####UNSUPPORTEDBEGIN####
4 // -------------------------------------------
5 // This source file has been contributed to eCos/Red Hat. It may have been
6 // changed slightly to provide an interface consistent with those of other
9 // The functionality and contents of this file is supplied "AS IS"
10 // without any form of support and will not necessarily be kept up
11 // to date by Red Hat.
13 // The style of programming used in this file may not comply with the
14 // eCos programming guidelines. Please do not use as a base for other
17 // All inquiries about this file, or the functionality provided by it,
18 // should be directed to the 'ecos-discuss' mailing list (see
19 // http://ecos.sourceware.org/ecos/intouch.html for details).
21 // -------------------------------------------
23 //####UNSUPPORTEDEND####
24 //=============================================================================
25 // Originally three different files, dhry.h, dhry21a.c and dhry21b.c
26 // Merged into one file and changed a little to avoid compilation warnings.
27 // The files were found at:
28 // FTP ftp.nosc.mil/pub/aburto/dhrystone
29 //=============================================================================
31 #include <pkgconf/system.h>
32 #include <pkgconf/infra.h>
33 #include <pkgconf/kernel.h>
34 #include <cyg/infra/cyg_type.h>
35 #include <cyg/infra/testcase.h>
37 #if !defined(CYGPKG_ISOINFRA)
38 # define NA_MSG "Requires CYGPKG_ISOINFRA"
40 # include <pkgconf/isoinfra.h>
42 # if !defined(CYGFUN_KERNEL_API_C) \
43 || !defined(CYGINT_ISO_STDIO_FORMATTED_IO) \
44 || CYGINT_ISO_MALLOC == 0 \
45 || !defined(CYGINT_ISO_STRING_STRFUNCS)
47 # define NA_MSG "Requires CYGFUN_KERNEL_API_C && CYGINT_ISO_STDIO_FORMATTED_IO && CYGINT_ISO_MALLOC && CYGINT_ISO_STRING_STRFUNCS"
49 # elif !defined(__OPTIMIZE__) \
50 || defined(CYGPKG_INFRA_DEBUG) \
51 || defined(CYGPKG_KERNEL_INSTRUMENT)
52 # define NA_MSG "Only runs with optimized code, no tracing and no asserts"
53 # elif defined(CYGDBG_INFRA_DIAG_USE_DEVICE)
54 # define NA_MSG "Must use HAL diag output to avoid background DSR activity"
60 #include <cyg/hal/hal_cache.h>
61 #include <cyg/kernel/kapi.h>
69 return (double) cyg_current_time() / 100;
72 // Number of loops to run.
73 #if defined(CYGPRI_KERNEL_TESTS_DHRYSTONE_PASSES)
74 # define PASSES CYGPRI_KERNEL_TESTS_DHRYSTONE_PASSES
76 # define PASSES 400000
79 // Used in the code below to mark changes to the code.
87 *************************************************************************
89 * "DHRYSTONE" Benchmark Program
90 * -----------------------------
92 * Version: C, Version 2.1
94 * File: dhry.h (part 1 of 3)
98 * Author: Reinhold P. Weicker
99 * Siemens Nixdorf Inf. Syst.
104 * Phone: [+49]-89-636-42436
105 * (8-17 Central European Time)
106 * UUCP: weicker@ztivax.uucp@unido.uucp
107 * Internet: weicker@ztivax.siemens.com
109 * Original Version (in Ada) published in
110 * "Communications of the ACM" vol. 27., no. 10 (Oct. 1984),
111 * pp. 1013 - 1030, together with the statistics
112 * on which the distribution of statements etc. is based.
114 * In this C version, the following C library functions are
116 * - strcpy, strcmp (inside the measurement loop)
117 * - printf, scanf (outside the measurement loop)
119 * Collection of Results:
120 * Reinhold Weicker (address see above) and
124 * 94 Apple Orchard Drive
125 * Tinton Falls, NJ 07724
126 * Phone: (201) 834-1378 (9-17 EST)
127 * UUCP: ...!uunet!pcrat!rick
129 * Please send results to Rick Richardson and/or Reinhold Weicker.
130 * Complete information should be given on hardware and software
131 * used. Hardware information includes: Machine type, CPU, type and
132 * size of caches; for microprocessors: clock frequency, memory speed
133 * (number of wait states). Software information includes: Compiler
134 * (and runtime library) manufacturer and version, compilation
135 * switches, OS version. The Operating System version may give an
136 * indication about the compiler; Dhrystone itself performs no OS
137 * calls in the measurement loop.
139 * The complete output generated by the program should be mailed
140 * such that at least some checks for correctness can be made.
142 *************************************************************************
144 * History: This version C/2.1 has been made for two reasons:
146 * 1) There is an obvious need for a common C version of
147 * Dhrystone, since C is at present the most popular system
148 * programming language for the class of processors
149 * (microcomputers, minicomputers) where Dhrystone is used
150 * most. There should be, as far as possible, only one C
151 * version of Dhrystone such that results can be compared
152 * without restrictions. In the past, the C versions
153 * distributed by Rick Richardson (Version 1.1) and by
154 * Reinhold Weicker had small (though not significant)
157 * 2) As far as it is possible without changes to the
158 * Dhrystone statistics, optimizing compilers should be
159 * prevented from removing significant statements.
161 * This C version has been developed in cooperation with
162 * Rick Richardson (Tinton Falls, NJ), it incorporates many
163 * ideas from the "Version 1.1" distributed previously by
164 * him over the UNIX network Usenet.
165 * I also thank Chaim Benedelac (National Semiconductor),
166 * David Ditzel (SUN), Earl Killian and John Mashey (MIPS),
167 * Alan Smith and Rafael Saavedra-Barrera (UC at Berkeley)
168 * for their help with comments on earlier versions of the
171 * Changes: In the initialization part, this version follows mostly
172 * Rick Richardson's version distributed via Usenet, not the
173 * version distributed earlier via floppy disk by Reinhold
174 * Weicker. As a concession to older compilers, names have
175 * been made unique within the first 8 characters. Inside the
176 * measurement loop, this version follows the version
177 * previously distributed by Reinhold Weicker.
179 * At several places in the benchmark, code has been added,
180 * but within the measurement loop only in branches that
181 * are not executed. The intention is that optimizing
182 * compilers should be prevented from moving code out of the
183 * measurement loop, or from removing code altogether. Since
184 * the statements that are executed within the measurement
185 * loop have NOT been changed, the numbers defining the
186 * "Dhrystone distribution" (distribution of statements,
187 * operand types and locality) still hold. Except for
188 * sophisticated optimizing compilers, execution times for
189 * this version should be the same as for previous versions.
191 * Since it has proven difficult to subtract the time for the
192 * measurement loop overhead in a correct way, the loop check
193 * has been made a part of the benchmark. This does have
194 * an impact - though a very minor one - on the distribution
195 * statistics which have been updated for this version.
197 * All changes within the measurement loop are described
198 * and discussed in the companion paper "Rationale for
199 * Dhrystone version 2".
201 * Because of the self-imposed limitation that the order and
202 * distribution of the executed statements should not be
203 * changed, there are still cases where optimizing compilers
204 * may not generate code for some statements. To a certain
205 * degree, this is unavoidable for small synthetic
206 * benchmarks. Users of the benchmark are advised to check
207 * code listings whether code is generated for all statements
210 * Version 2.1 is identical to version 2.0 distributed via
211 * the UNIX network Usenet in March 1988 except that it
212 * corrects some minor deficiencies that were found by users
213 * of version 2.0. The only change within the measurement
214 * loop is that a non-executed "else" part was added to the
215 * "if" statement in Func_3, and a non-executed "else" part
216 * removed from Proc_3.
218 *************************************************************************
220 * Defines: The following "Defines" are possible:
221 * -DROPT (default: Not defined)
222 * As an approximation to what an average C
223 * programmer might do, the "register" storage class
224 * is applied (if enabled by -DROPT)
225 * - for local variables, if they are used
226 * (dynamically) five or more times
227 * - for parameters if they are used (dynamically)
229 * Note that an optimal "register" strategy is
230 * compiler-dependent, and that "register"
231 * declarations do not necessarily lead to faster
233 * -DNOSTRUCTASSIGN (default: Not defined)
234 * Define if the C compiler does not support
235 * assignment of structures.
236 * -DNOENUMS (default: Not defined)
237 * Define if the C compiler does not support
240 *************************************************************************
242 * Compilation model and measurement (IMPORTANT):
244 * This C version of Dhrystone consists of three files:
245 * - dhry.h (this file, containing global definitions and comments)
246 * - dhry_1.c (containing the code corresponding to Ada package Pack_1)
247 * - dhry_2.c (containing the code corresponding to Ada package Pack_2)
249 * The following "ground rules" apply for measurements:
250 * - Separate compilation
251 * - No procedure merging
252 * - Otherwise, compiler optimizations are allowed but should be
254 * - Default results are those without register declarations
255 * See the companion paper "Rationale for Dhrystone Version 2" for a more
256 * detailed discussion of these ground rules.
258 * For 16-Bit processors (e.g. 80186, 80286), times for all compilation
259 * models ("small", "medium", "large" etc.) should be given if possible,
260 * together with a definition of these models for the compiler system
263 *************************************************************************
265 * Dhrystone (C version) statistics:
267 * [Comment from the first distribution, updated for version 2.
268 * Note that because of language differences, the numbers are slightly
269 * different from the Ada version.]
271 * The following program contains statements of a high level programming
272 * language (here: C) in a distribution considered representative:
274 * assignments 52 (51.0 %)
275 * control statements 33 (32.4 %)
276 * procedure, function calls 17 (16.7 %)
278 * 103 statements are dynamically executed. The program is balanced with
279 * respect to the three aspects:
284 * operand global, local, parameter, or constant.
286 * The combination of these three aspects is balanced only approximately.
289 * ----------------- number
297 * with record component
301 * X = Y +|-|"&&"|"|" Z 5
302 * X = Y +|-|"==" Constant 6
317 * for ... 7 | counted every time
318 * while ... 4 | the loop condition
319 * do ... while 1 | is evaluated
327 * P (...) procedure call 11
329 * library procedure 1
339 * The average number of parameters in procedure or function calls
340 * is 1.82 (not counting the function values as implicit parameters).
366 * && (AND-THEN) 1 1.6
374 * 3. Operand Type (counted once per operand reference):
380 * Character 45 18.6 %
388 * When there is an access path leading to the final operand (e.g. a
389 * record component), only the final data type on the access path is
393 * 4. Operand Locality:
394 * -------------------
398 * local variable 114 47.1 %
399 * global variable 22 9.1 %
400 * parameter 45 18.6 %
403 * function result 6 2.5 %
409 * The program does not compute anything meaningful, but it is
410 * syntactically and semantically correct. All variables have a value
411 * assigned to them before they are used as a source operand.
413 * There has been no explicit effort to account for the effects of a
414 * cache, or to balance the use of long or short displacements for code
417 *************************************************************************
420 /* Compiler and system dependent definitions: */
422 #define Mic_secs_Per_Second 1000000.0
423 /* Berkeley UNIX C returns process times in seconds/HZ */
425 #ifdef NOSTRUCTASSIGN
426 #define structassign(d, s) memcpy(&(d), &(s), sizeof(d))
428 #define structassign(d, s) d = s
437 typedef int Enumeration;
439 typedef enum {Ident_1, Ident_2, Ident_3, Ident_4, Ident_5}
442 /* for boolean and enumeration types in Ada, Pascal */
444 /* General definitions: */
447 /* for strcpy, strcmp */
450 /* Value of a Null pointer */
454 typedef int One_Thirty;
455 typedef int One_Fifty;
456 typedef char Capital_Letter;
458 typedef char Str_30 [31];
459 typedef int Arr_1_Dim [50];
460 typedef int Arr_2_Dim [50] [50];
462 typedef struct record
464 struct record *Ptr_Comp;
468 Enumeration Enum_Comp;
473 Enumeration E_Comp_2;
474 char Str_2_Comp [31];
481 } Rec_Type, *Rec_Pointer;
487 /* REG becomes defined as empty */
488 /* i.e. no register variables */
493 Boolean Func_2 (Str_30 Str_1_Par_Ref, Str_30 Str_2_Par_Ref);
494 Boolean Func_3 (Enumeration Enum_Par_Val);
496 void Proc_1 (REG Rec_Pointer Ptr_Val_Par);
497 void Proc_2 (One_Fifty* Int_Par_Ref);
498 void Proc_3 (Rec_Pointer *Ptr_Ref_Par);
501 void Proc_6 (Enumeration Enum_Val_Par, Enumeration* Enum_Ref_Par);
502 void Proc_7 (One_Fifty Int_1_Par_Val, One_Fifty Int_2_Par_Val,
503 One_Fifty* Int_Par_Ref);
504 void Proc_8 (Arr_1_Dim Arr_1_Par_Ref, Arr_2_Dim Arr_2_Par_Ref,
505 int Int_1_Par_Val, int Int_2_Par_Val);
506 Enumeration Func_1 (Capital_Letter Ch_1_Par_Val, Capital_Letter Ch_2_Par_Val);
511 *************************************************************************
513 * "DHRYSTONE" Benchmark Program
514 * -----------------------------
516 * Version: C, Version 2.1
518 * File: dhry_1.c (part 2 of 3)
522 * Author: Reinhold P. Weicker
524 *************************************************************************
532 /* Global Variables: */
534 Rec_Pointer Ptr_Glob,
541 int Arr_2_Glob [50] [50];
543 char Reg_Define[] = "Register option selected.";
546 extern char *malloc ();
547 Enumeration Func_1 ();
550 forward declaration necessary since Enumeration may not simply be int
556 /* REG becomes defined as empty */
557 /* i.e. no register variables */
563 /* variables for time measurement: */
565 #define Too_Small_Time 2
566 /* Measurements should last at least 2 seconds */
573 Dhrystones_Per_Second,
576 /* end of variables for time measurement */
586 /* main program, corresponds to procedures */
587 /* Main and Proc_0 in the Ada version */
594 REG One_Fifty Int_2_Loc;
597 Enumeration Enum_Loc;
601 REG int Number_Of_Runs;
608 #ifdef CYG_HAL_I386_LINUX
609 CYG_TEST_NA("Only runs on hardware...");
611 if (cyg_test_is_simulator)
612 CYG_TEST_NA("Only runs on hardware...");
618 /* Initializations */
620 if ((Ap = fopen("dhry.res","a+")) == NULL)
622 printf("Can not open dhry.res\n\n");
627 Next_Ptr_Glob = (Rec_Pointer) malloc (sizeof (Rec_Type));
628 Ptr_Glob = (Rec_Pointer) malloc (sizeof (Rec_Type));
630 Ptr_Glob->Ptr_Comp = Next_Ptr_Glob;
631 Ptr_Glob->Discr = Ident_1;
632 Ptr_Glob->variant.var_1.Enum_Comp = Ident_3;
633 Ptr_Glob->variant.var_1.Int_Comp = 40;
634 strcpy (Ptr_Glob->variant.var_1.Str_Comp,
635 "DHRYSTONE PROGRAM, SOME STRING");
636 strcpy (Str_1_Loc, "DHRYSTONE PROGRAM, 1'ST STRING");
638 Arr_2_Glob [8][7] = 10;
639 /* Was missing in published program. Without this statement, */
640 /* Arr_2_Glob [8][7] would have an undefined value. */
641 /* Warning: With 16-Bit processors and Number_Of_Runs > 32000, */
642 /* overflow may occur for this array element. */
645 printf ("Dhrystone Benchmark, Version 2.1 (Language: C)\n");
650 printf ("Program compiled with 'register' attribute\n");
655 printf ("Program compiled without 'register' attribute\n");
660 Number_Of_Runs = PASSES;
662 printf ("Please give the number of runs through the benchmark: ");
671 printf ("Execution starts, %d runs through Dhrystone\n",Number_Of_Runs);
677 Begin_Time = dtime();
679 for (Run_Index = 1; Run_Index <= Number_Of_Runs; ++Run_Index)
684 /* Ch_1_Glob == 'A', Ch_2_Glob == 'B', Bool_Glob == true */
687 strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 2'ND STRING");
689 Bool_Glob = ! Func_2 (Str_1_Loc, Str_2_Loc);
691 while (Int_1_Loc < Int_2_Loc) /* loop body executed once */
693 Int_3_Loc = 5 * Int_1_Loc - Int_2_Loc;
695 Proc_7 (Int_1_Loc, Int_2_Loc, &Int_3_Loc);
699 /* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
700 Proc_8 (Arr_1_Glob, Arr_2_Glob, Int_1_Loc, Int_3_Loc);
703 for (Ch_Index = 'A'; Ch_Index <= Ch_2_Glob; ++Ch_Index)
704 /* loop body executed twice */
706 if (Enum_Loc == Func_1 (Ch_Index, 'C'))
707 /* then, not executed */
709 Proc_6 (Ident_1, &Enum_Loc);
710 strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 3'RD STRING");
711 Int_2_Loc = Run_Index;
712 Int_Glob = Run_Index;
715 /* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
716 Int_2_Loc = Int_2_Loc * Int_1_Loc;
717 Int_1_Loc = Int_2_Loc / Int_3_Loc;
718 Int_2_Loc = 7 * (Int_2_Loc - Int_3_Loc) - Int_1_Loc;
719 /* Int_1_Loc == 1, Int_2_Loc == 13, Int_3_Loc == 7 */
723 } /* loop "for Run_Index" */
731 printf ("Execution ends\n");
733 printf ("Final values of the variables used in the benchmark:\n");
735 printf ("Int_Glob: %d\n", Int_Glob);
736 printf (" should be: %d\n", 5);
737 printf ("Bool_Glob: %d\n", Bool_Glob);
738 printf (" should be: %d\n", 1);
739 printf ("Ch_1_Glob: %c\n", Ch_1_Glob);
740 printf (" should be: %c\n", 'A');
741 printf ("Ch_2_Glob: %c\n", Ch_2_Glob);
742 printf (" should be: %c\n", 'B');
743 printf ("Arr_1_Glob[8]: %d\n", Arr_1_Glob[8]);
744 printf (" should be: %d\n", 7);
745 printf ("Arr_2_Glob[8][7]: %d\n", Arr_2_Glob[8][7]);
746 printf (" should be: Number_Of_Runs + 10\n");
747 printf ("Ptr_Glob->\n");
748 printf (" Ptr_Comp: %d\n", (int) Ptr_Glob->Ptr_Comp);
749 printf (" should be: (implementation-dependent)\n");
750 printf (" Discr: %d\n", Ptr_Glob->Discr);
751 printf (" should be: %d\n", 0);
752 printf (" Enum_Comp: %d\n", Ptr_Glob->variant.var_1.Enum_Comp);
753 printf (" should be: %d\n", 2);
754 printf (" Int_Comp: %d\n", Ptr_Glob->variant.var_1.Int_Comp);
755 printf (" should be: %d\n", 17);
756 printf (" Str_Comp: %s\n", Ptr_Glob->variant.var_1.Str_Comp);
757 printf (" should be: DHRYSTONE PROGRAM, SOME STRING\n");
758 printf ("Next_Ptr_Glob->\n");
759 printf (" Ptr_Comp: %d\n", (int) Next_Ptr_Glob->Ptr_Comp);
760 printf (" should be: (implementation-dependent), same as above\n");
761 printf (" Discr: %d\n", Next_Ptr_Glob->Discr);
762 printf (" should be: %d\n", 0);
763 printf (" Enum_Comp: %d\n", Next_Ptr_Glob->variant.var_1.Enum_Comp);
764 printf (" should be: %d\n", 1);
765 printf (" Int_Comp: %d\n", Next_Ptr_Glob->variant.var_1.Int_Comp);
766 printf (" should be: %d\n", 18);
767 printf (" Str_Comp: %s\n", Next_Ptr_Glob->variant.var_1.Str_Comp);
768 printf (" should be: DHRYSTONE PROGRAM, SOME STRING\n");
769 printf ("Int_1_Loc: %d\n", Int_1_Loc);
770 printf (" should be: %d\n", 5);
771 printf ("Int_2_Loc: %d\n", Int_2_Loc);
772 printf (" should be: %d\n", 13);
773 printf ("Int_3_Loc: %d\n", Int_3_Loc);
774 printf (" should be: %d\n", 7);
775 printf ("Enum_Loc: %d\n", Enum_Loc);
776 printf (" should be: %d\n", 1);
777 printf ("Str_1_Loc: %s\n", Str_1_Loc);
778 printf (" should be: DHRYSTONE PROGRAM, 1'ST STRING\n");
779 printf ("Str_2_Loc: %s\n", Str_2_Loc);
780 printf (" should be: DHRYSTONE PROGRAM, 2'ND STRING\n");
783 User_Time = End_Time - Begin_Time;
785 if (User_Time < Too_Small_Time)
787 printf ("Measured time too small to obtain meaningful results\n");
788 printf ("Please increase number of runs\n");
793 Microseconds = User_Time * Mic_secs_Per_Second
794 / (double) Number_Of_Runs;
795 Dhrystones_Per_Second = (double) Number_Of_Runs / User_Time;
796 Vax_Mips = Dhrystones_Per_Second / 1757.0;
799 printf ("Register option selected? YES\n");
801 printf ("Register option selected? NO\n");
803 strcpy(Reg_Define, "Register option not selected.");
806 printf ("Microseconds for one run through Dhrystone: ");
808 printf ("%7.1f \n", Microseconds);
809 printf ("Dhrystones per Second: ");
810 printf ("%10.1f \n", Dhrystones_Per_Second);
811 printf ("VAX MIPS rating = %10.3f \n",Vax_Mips);
814 printf ("%7.1lf \n", Microseconds);
815 printf ("Dhrystones per Second: ");
816 printf ("%10.1lf \n", Dhrystones_Per_Second);
817 printf ("VAX MIPS rating = %10.3lf \n",Vax_Mips);
821 fprintf(Ap,"Dhrystone Benchmark, Version 2.1 (Language: C)\n");
822 fprintf(Ap,"%s\n",Reg_Define);
823 fprintf(Ap,"Microseconds for one loop: %7.1lf\n",Microseconds);
824 fprintf(Ap,"Dhrystones per second: %10.1lf\n",Dhrystones_Per_Second);
825 fprintf(Ap,"VAX MIPS rating: %10.3lf\n",Vax_Mips);
831 CYG_TEST_PASS_FINISH("Dhrystone test");
842 REG Rec_Pointer Ptr_Val_Par;
845 REG Rec_Pointer Next_Record = Ptr_Val_Par->Ptr_Comp;
846 /* == Ptr_Glob_Next */
847 /* Local variable, initialized with Ptr_Val_Par->Ptr_Comp, */
848 /* corresponds to "rename" in Ada, "with" in Pascal */
850 structassign (*Ptr_Val_Par->Ptr_Comp, *Ptr_Glob);
851 Ptr_Val_Par->variant.var_1.Int_Comp = 5;
852 Next_Record->variant.var_1.Int_Comp
853 = Ptr_Val_Par->variant.var_1.Int_Comp;
854 Next_Record->Ptr_Comp = Ptr_Val_Par->Ptr_Comp;
855 Proc_3 (&Next_Record->Ptr_Comp);
856 /* Ptr_Val_Par->Ptr_Comp->Ptr_Comp
857 == Ptr_Glob->Ptr_Comp */
858 if (Next_Record->Discr == Ident_1)
861 Next_Record->variant.var_1.Int_Comp = 6;
862 Proc_6 (Ptr_Val_Par->variant.var_1.Enum_Comp,
863 &Next_Record->variant.var_1.Enum_Comp);
864 Next_Record->Ptr_Comp = Ptr_Glob->Ptr_Comp;
865 Proc_7 (Next_Record->variant.var_1.Int_Comp, 10,
866 &Next_Record->variant.var_1.Int_Comp);
868 else /* not executed */
869 structassign (*Ptr_Val_Par, *Ptr_Val_Par->Ptr_Comp);
879 /* *Int_Par_Ref == 1, becomes 4 */
881 One_Fifty *Int_Par_Ref;
885 Enumeration Enum_Loc = Ident_1;
887 Enumeration Enum_Loc;
890 Int_Loc = *Int_Par_Ref + 10;
891 do /* executed once */
892 if (Ch_1_Glob == 'A')
896 *Int_Par_Ref = Int_Loc - Int_Glob;
899 while (Enum_Loc != Ident_1); /* true */
909 /* Ptr_Ref_Par becomes Ptr_Glob */
911 Rec_Pointer *Ptr_Ref_Par;
914 if (Ptr_Glob != Null)
916 *Ptr_Ref_Par = Ptr_Glob->Ptr_Comp;
917 Proc_7 (10, Int_Glob, &Ptr_Glob->variant.var_1.Int_Comp);
924 Proc_4 () /* without parameters */
930 Bool_Loc = Ch_1_Glob == 'A';
931 Bool_Glob = Bool_Loc | Bool_Glob;
939 Proc_5 () /* without parameters */
948 /* Procedure for the assignment of structures, */
949 /* if the C compiler doesn't support this feature */
950 #ifdef NOSTRUCTASSIGN
956 while (l--) *d++ = *s++;
961 *************************************************************************
963 * "DHRYSTONE" Benchmark Program
964 * -----------------------------
966 * Version: C, Version 2.1
968 * File: dhry_2.c (part 3 of 3)
972 * Author: Reinhold P. Weicker
974 *************************************************************************
982 /* REG becomes defined as empty */
983 /* i.e. no register variables */
990 extern char Ch_1_Glob;
995 Proc_6 (Enum_Val_Par, Enum_Ref_Par)
996 /*********************************/
998 /* Enum_Val_Par == Ident_3, Enum_Ref_Par becomes Ident_2 */
1000 Enumeration Enum_Val_Par;
1001 Enumeration *Enum_Ref_Par;
1003 *Enum_Ref_Par = Enum_Val_Par;
1004 if (! Func_3 (Enum_Val_Par))
1005 /* then, not executed */
1006 *Enum_Ref_Par = Ident_4;
1007 switch (Enum_Val_Par)
1010 *Enum_Ref_Par = Ident_1;
1015 *Enum_Ref_Par = Ident_1;
1016 else *Enum_Ref_Par = Ident_4;
1018 case Ident_3: /* executed */
1019 *Enum_Ref_Par = Ident_2;
1021 case Ident_4: break;
1023 *Enum_Ref_Par = Ident_3;
1032 Proc_7 (Int_1_Par_Val, Int_2_Par_Val, Int_Par_Ref)
1033 /**********************************************/
1034 /* executed three times */
1035 /* first call: Int_1_Par_Val == 2, Int_2_Par_Val == 3, */
1036 /* Int_Par_Ref becomes 7 */
1037 /* second call: Int_1_Par_Val == 10, Int_2_Par_Val == 5, */
1038 /* Int_Par_Ref becomes 17 */
1039 /* third call: Int_1_Par_Val == 6, Int_2_Par_Val == 10, */
1040 /* Int_Par_Ref becomes 18 */
1041 One_Fifty Int_1_Par_Val;
1042 One_Fifty Int_2_Par_Val;
1043 One_Fifty *Int_Par_Ref;
1047 Int_Loc = Int_1_Par_Val + 2;
1048 *Int_Par_Ref = Int_2_Par_Val + Int_Loc;
1055 Proc_8 (Arr_1_Par_Ref, Arr_2_Par_Ref, Int_1_Par_Val, Int_2_Par_Val)
1056 /*********************************************************************/
1058 /* Int_Par_Val_1 == 3 */
1059 /* Int_Par_Val_2 == 7 */
1060 Arr_1_Dim Arr_1_Par_Ref;
1061 Arr_2_Dim Arr_2_Par_Ref;
1065 REG One_Fifty Int_Index;
1066 REG One_Fifty Int_Loc;
1068 Int_Loc = Int_1_Par_Val + 5;
1069 Arr_1_Par_Ref [Int_Loc] = Int_2_Par_Val;
1070 Arr_1_Par_Ref [Int_Loc+1] = Arr_1_Par_Ref [Int_Loc];
1071 Arr_1_Par_Ref [Int_Loc+30] = Int_Loc;
1072 for (Int_Index = Int_Loc; Int_Index <= Int_Loc+1; ++Int_Index)
1073 Arr_2_Par_Ref [Int_Loc] [Int_Index] = Int_Loc;
1074 Arr_2_Par_Ref [Int_Loc] [Int_Loc-1] += 1;
1075 Arr_2_Par_Ref [Int_Loc+20] [Int_Loc] = Arr_1_Par_Ref [Int_Loc];
1080 Enumeration Func_1 (Ch_1_Par_Val, Ch_2_Par_Val)
1081 /*************************************************/
1082 /* executed three times */
1083 /* first call: Ch_1_Par_Val == 'H', Ch_2_Par_Val == 'R' */
1084 /* second call: Ch_1_Par_Val == 'A', Ch_2_Par_Val == 'C' */
1085 /* third call: Ch_1_Par_Val == 'B', Ch_2_Par_Val == 'C' */
1087 Capital_Letter Ch_1_Par_Val;
1088 Capital_Letter Ch_2_Par_Val;
1090 Capital_Letter Ch_1_Loc;
1091 Capital_Letter Ch_2_Loc;
1093 Ch_1_Loc = Ch_1_Par_Val;
1094 Ch_2_Loc = Ch_1_Loc;
1095 if (Ch_2_Loc != Ch_2_Par_Val)
1096 /* then, executed */
1098 else /* not executed */
1100 Ch_1_Glob = Ch_1_Loc;
1106 Boolean Func_2 (Str_1_Par_Ref, Str_2_Par_Ref)
1107 /*************************************************/
1109 /* Str_1_Par_Ref == "DHRYSTONE PROGRAM, 1'ST STRING" */
1110 /* Str_2_Par_Ref == "DHRYSTONE PROGRAM, 2'ND STRING" */
1112 Str_30 Str_1_Par_Ref;
1113 Str_30 Str_2_Par_Ref;
1115 REG One_Thirty Int_Loc;
1117 Capital_Letter Ch_Loc = 'A';
1119 Capital_Letter Ch_Loc;
1123 while (Int_Loc <= 2) /* loop body executed once */
1124 if (Func_1 (Str_1_Par_Ref[Int_Loc],
1125 Str_2_Par_Ref[Int_Loc+1]) == Ident_1)
1126 /* then, executed */
1131 if (Ch_Loc >= 'W' && Ch_Loc < 'Z')
1132 /* then, not executed */
1135 /* then, not executed */
1139 if (strcmp (Str_1_Par_Ref, Str_2_Par_Ref) > 0)
1140 /* then, not executed */
1152 Boolean Func_3 (Enum_Par_Val)
1153 /***************************/
1155 /* Enum_Par_Val == Ident_3 */
1156 Enumeration Enum_Par_Val;
1158 Enumeration Enum_Loc;
1160 Enum_Loc = Enum_Par_Val;
1161 if (Enum_Loc == Ident_3)
1162 /* then, executed */
1164 else /* not executed */
1168 #else /* ifndef NA_MSG */
1174 CYG_TEST_NA(NA_MSG);