From 974755deb9bbea37752d2202844a1f485e59c8e7 Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Tue, 11 Nov 2008 23:17:11 +0000 Subject: -- Rename misc.c randnum.c -- Delete misc.h git-svn-id: svn://mattst88.com/svn/cleanbench/trunk@8 0d43b9a7-5ab2-4d7b-af9d-f64450cef757 --- Makefile | 8 ++++---- misc.c | 55 ------------------------------------------------------- misc.h | 41 ----------------------------------------- randnum.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 59 insertions(+), 100 deletions(-) delete mode 100644 misc.c delete mode 100644 misc.h create mode 100644 randnum.c diff --git a/Makefile b/Makefile index 311e55d..024a4d7 100644 --- a/Makefile +++ b/Makefile @@ -122,8 +122,8 @@ nbench0.o: nbench0.h nbench0.c nmglobal.h hardware.h Makefile sysinfo.c sysinfoc emfloat.o: emfloat.h emfloat.c nmglobal.h Makefile $(CCC) $(DEFINES) $(CCCFLAGS) -c emfloat.c -misc.o: misc.c Makefile - $(CCC) $(DEFINES) $(CCCFLAGS) -c misc.c +randnum.o: randnum.c Makefile + $(CCC) $(DEFINES) $(CCCFLAGS) -c randnum.c numsort.o: numsort.c $(CCC) $(DEFINES) $(CCCFLAGS) -c numsort.c @@ -183,8 +183,8 @@ linear.o: linear.c sysspec.o: sysspec.h sysspec.c nmglobal.h Makefile $(GCC) $(DEFINES) $(GCCFLAGS) -c sysspec.c -nbench: emfloat.o misc.o nbench0.o numsort.o sysspec.o hardware.o stringsort.o bitfield.o fpemulation.o fourier.o assignment.o idea.o huffman.o neural.o linear.o - $(GCC) emfloat.o misc.o nbench0.o numsort.o sysspec.o hardware.o stringsort.o bitfield.o fpemulation.o fourier.o assignment.o idea.o huffman.o neural.o linear.o -o nbench -lm +nbench: emfloat.o randnum.o nbench0.o numsort.o sysspec.o hardware.o stringsort.o bitfield.o fpemulation.o fourier.o assignment.o idea.o huffman.o neural.o linear.o + $(GCC) emfloat.o randnum.o nbench0.o numsort.o sysspec.o hardware.o stringsort.o bitfield.o fpemulation.o fourier.o assignment.o idea.o huffman.o neural.o linear.o -o nbench -lm ########################################################################## diff --git a/misc.c b/misc.c deleted file mode 100644 index 7d2620f..0000000 --- a/misc.c +++ /dev/null @@ -1,55 +0,0 @@ -#include -#include - -/**************************** -** RANDOM NUMBER GENERATOR ** -***************************** -** This is a second-order linear congruential random number -** generator. Its advantage is (of course) that it can be -** seeded and will thus produce repeatable sequences of -** random numbers. -*/ - -/**************************** -* randnum() * -***************************** -** Second order linear congruential generator. -** Constants suggested by J. G. Skellam. -** If val==0, returns next member of sequence. -** val!=0, restart generator. -*/ - -int32_t randnum(int32_t val) { - static int32_t randw[2] = { 13 , 117 }; - int32_t interm; - - if (val != 0) { - randw[0] = 13; - randw[1] = 117; - } - - interm = (randw[0]* (int32_t)254754 + randw[1]*(int32_t)529562) % (int32_t)999563; - randw[1] = randw[0]; - randw[0] = interm; - return(interm); -} - -/**************************** -* randwc() * -***************************** -** Returns signed 32-bit random modulo num. -*/ -int32_t randwc(int32_t num) { - return(randnum(0) % num); -} - -/*************************** -** abs_randwc() ** -**************************** -** Same as randwc(), only this routine returns only -** positive numbers. -*/ -uint32_t abs_randwc(uint32_t num) { - return abs(randwc(num)); -} - diff --git a/misc.h b/misc.h deleted file mode 100644 index 2fe70aa..0000000 --- a/misc.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -** misc.h -** Header for misc.c -** BYTEmark (tm) -** BYTE's Native Mode Benchmarks -** Rick Grehan, BYTE Magazine -** -** Creation: -** Revision: 3/95 -** -** DISCLAIMER -** The source, executable, and documentation files that comprise -** the BYTEmark benchmarks are made available on an "as is" basis. -** This means that we at BYTE Magazine have made every reasonable -** effort to verify that the there are no errors in the source and -** executable code. We cannot, however, guarantee that the programs -** are error-free. Consequently, McGraw-HIll and BYTE Magazine make -** no claims in regard to the fitness of the source code, executable -** code, and documentation of the BYTEmark. -** Furthermore, BYTE Magazine, McGraw-Hill, and all employees -** of McGraw-Hill cannot be held responsible for any damages resulting -** from the use of this code or the results obtained from using -** this code. -*/ - -/************************ -** FUNCTION PROTOTYPES ** -************************/ - -/* -long randwc(long num); -unsigned long abs_randwc(unsigned long num); -long randnum(long lngval); -*/ - -#include "nmglobal.h" -int32_t randwc(int32_t num); -uint32_t abs_randwc(uint32_t num); -int32_t randnum(int32_t lngval); - - diff --git a/randnum.c b/randnum.c new file mode 100644 index 0000000..7d2620f --- /dev/null +++ b/randnum.c @@ -0,0 +1,55 @@ +#include +#include + +/**************************** +** RANDOM NUMBER GENERATOR ** +***************************** +** This is a second-order linear congruential random number +** generator. Its advantage is (of course) that it can be +** seeded and will thus produce repeatable sequences of +** random numbers. +*/ + +/**************************** +* randnum() * +***************************** +** Second order linear congruential generator. +** Constants suggested by J. G. Skellam. +** If val==0, returns next member of sequence. +** val!=0, restart generator. +*/ + +int32_t randnum(int32_t val) { + static int32_t randw[2] = { 13 , 117 }; + int32_t interm; + + if (val != 0) { + randw[0] = 13; + randw[1] = 117; + } + + interm = (randw[0]* (int32_t)254754 + randw[1]*(int32_t)529562) % (int32_t)999563; + randw[1] = randw[0]; + randw[0] = interm; + return(interm); +} + +/**************************** +* randwc() * +***************************** +** Returns signed 32-bit random modulo num. +*/ +int32_t randwc(int32_t num) { + return(randnum(0) % num); +} + +/*************************** +** abs_randwc() ** +**************************** +** Same as randwc(), only this routine returns only +** positive numbers. +*/ +uint32_t abs_randwc(uint32_t num) { + return abs(randwc(num)); +} + -- cgit v1.2.3