Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1 | dhrystone: fix compilation problems |
| 2 | |
| 3 | This patch fixes two compilation errors with original |
| 4 | dhrystone sources: |
| 5 | * Redefinition of times() with wrong return type |
| 6 | - Fixed by commenting out the unnecessary redefinition |
| 7 | * Undefined identifier HZ |
| 8 | - Originally HZ was supposed to be the clock frequency |
| 9 | value for times() |
| 10 | - For Linux, the frequency should come from sysconf |
| 11 | - This patch defines global varible HZ and initializes |
| 12 | it from sysconf |
| 13 | |
| 14 | Additionally, this patch adds a simple Makefile. |
| 15 | |
| 16 | Upstream-status: Pending |
| 17 | |
| 18 | Sign-off-by: Kimmo Surakka <kimmo.surakka@ge.com> |
| 19 | Signed-off-by: Jose Alarcon <jose.alarcon@ge.com> |
| 20 | --- |
| 21 | |
| 22 | diff -Naur dhry.orig/dhry_1.c dhry/dhry_1.c |
| 23 | --- dhry.orig/dhry_1.c 2015-07-20 14:25:58.059945353 +0300 |
| 24 | +++ dhry/dhry_1.c 2015-07-20 12:43:25.318945353 +0300 |
| 25 | @@ -45,11 +45,15 @@ |
| 26 | |
| 27 | #ifdef TIMES |
| 28 | struct tms time_info; |
| 29 | -extern int times (); |
| 30 | +/* extern int times (); */ |
| 31 | /* see library function "times" */ |
| 32 | #define Too_Small_Time 120 |
| 33 | /* Measurements should last at least about 2 seconds */ |
| 34 | #endif |
| 35 | +#ifndef HZ |
| 36 | +#include <unistd.h> /* sysconf */ |
| 37 | + long HZ; |
| 38 | +#endif |
| 39 | #ifdef TIME |
| 40 | extern long time(); |
| 41 | /* see library function "time" */ |
| 42 | @@ -84,6 +88,9 @@ |
| 43 | |
| 44 | /* Initializations */ |
| 45 | |
| 46 | +#ifndef HZ |
| 47 | + HZ = sysconf(_SC_CLK_TCK); |
| 48 | +#endif |
| 49 | Next_Ptr_Glob = (Rec_Pointer) malloc (sizeof (Rec_Type)); |
| 50 | Ptr_Glob = (Rec_Pointer) malloc (sizeof (Rec_Type)); |
| 51 | |
| 52 | diff -Naur dhry.orig/dhry.h dhry/dhry.h |
| 53 | --- dhry.orig/dhry.h 2015-07-20 14:25:58.054945353 +0300 |
| 54 | +++ dhry/dhry.h 2015-07-20 12:42:59.903945353 +0300 |
| 55 | @@ -420,4 +420,6 @@ |
| 56 | } variant; |
| 57 | } Rec_Type, *Rec_Pointer; |
| 58 | |
| 59 | - |
| 60 | +#ifndef HZ |
| 61 | + extern long HZ; |
| 62 | +#endif |
| 63 | diff -Naur dhry.orig/Makefile dhry/Makefile |
| 64 | --- dhry.orig/Makefile 1970-01-01 02:00:00.000000000 +0200 |
| 65 | +++ dhry/Makefile 2015-07-20 14:10:45.832945353 +0300 |
| 66 | @@ -0,0 +1,15 @@ |
| 67 | +CC=gcc |
| 68 | + |
| 69 | +all: dhry |
| 70 | + |
| 71 | +dhry: dhry_1.o dhry_2.o |
| 72 | + $(CC) $(LDFLAGS) -o $@ $^ $(LOADLIBES) $(LDLIBS) |
| 73 | + |
| 74 | +dhry_1.o: dhry_1.c dhry.h |
| 75 | + |
| 76 | +dhry_2.o: dhry_2.c dhry.h |
| 77 | + |
| 78 | +clean: |
| 79 | + rm -f *.o *~ |
| 80 | + |
| 81 | +.PHONY: all clean |