summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Turner <mattst88@gmail.com>2008-11-11 23:15:13 +0000
committerMatt Turner <mattst88@gmail.com>2008-11-11 23:15:13 +0000
commit4400334ffbffba2462d7e049c79907ff0b148a52 (patch)
tree037494c6a3d3941d12e9df47f18b6349667eb2ab
parentec90e4c13bdbf8bac159f5e71b5e5f91c71dfa0f (diff)
-- Move randnum defines to nbench0.h
-- Clean misc.c nicely git-svn-id: svn://mattst88.com/svn/cleanbench/trunk@7 0d43b9a7-5ab2-4d7b-af9d-f64450cef757
-rw-r--r--misc.c123
-rw-r--r--nbench0.h4
2 files changed, 32 insertions, 95 deletions
diff --git a/misc.c b/misc.c
index aca70bc..7d2620f 100644
--- a/misc.c
+++ b/misc.c
@@ -1,30 +1,5 @@
-
-/*
-** misc.c
-** BYTEmark (tm)
-** BYTE's Native Mode Benchmarks
-** Rick Grehan, BYTE Magazine
-** 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.
-*/
-
-#include <stdio.h>
-#include "misc.h"
-
-/***********************************************************
-** MISCELLANEOUS BUT OTHERWISE NECESSARY ROUTINES **
-***********************************************************/
+#include <stdint.h>
+#include <math.h>
/****************************
** RANDOM NUMBER GENERATOR **
@@ -36,52 +11,6 @@
*/
/****************************
-* randwc() *
-*****************************
-** Returns signed long random modulo num.
-*/
-/*
-long randwc(long num)
-{
- return(randnum(0L)%num);
-}
-*/
-/*
-** Returns signed 32-bit random modulo num.
-*/
-int32_t randwc(int32_t num)
-{
- return(randnum((int32_t)0)%num);
-}
-
-/***************************
-** abs_randwc() **
-****************************
-** Same as randwc(), only this routine returns only
-** positive numbers.
-*/
-/*
-unsigned long abs_randwc(unsigned long num)
-{
-long temp;
-
-temp=randwc(num);
-if(temp<0) temp=0L-temp;
-
-return((unsigned long)temp);
-}
-*/
-uint32_t abs_randwc(uint32_t num)
-{
-int32_t temp; /* Temporary storage */
-
-temp=randwc(num);
-if(temp<0) temp=(int32_t)0-temp;
-
-return((uint32_t)temp);
-}
-
-/****************************
* randnum() *
*****************************
** Second order linear congruential generator.
@@ -89,32 +18,38 @@ return((uint32_t)temp);
** If val==0, returns next member of sequence.
** val!=0, restart generator.
*/
-/*
-long randnum(long lngval)
-{
- register long interm;
- static long randw[2] = { 13L , 117L };
- if (lngval!=0L)
- { randw[0]=13L; randw[1]=117L; }
+int32_t randnum(int32_t val) {
+ static int32_t randw[2] = { 13 , 117 };
+ int32_t interm;
- interm=(randw[0]*254754L+randw[1]*529562L)%999563L;
- randw[1]=randw[0];
- randw[0]=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);
}
-*/
-int32_t randnum(int32_t lngval)
-{
- register int32_t interm;
- static int32_t randw[2] = { (int32_t)13 , (int32_t)117 };
- if (lngval!=(int32_t)0)
- { randw[0]=(int32_t)13; randw[1]=(int32_t)117; }
+/****************************
+* randwc() *
+*****************************
+** Returns signed 32-bit random modulo num.
+*/
+int32_t randwc(int32_t num) {
+ return(randnum(0) % num);
+}
- interm=(randw[0]*(int32_t)254754+randw[1]*(int32_t)529562)%(int32_t)999563;
- randw[1]=randw[0];
- randw[0]=interm;
- return(interm);
+/***************************
+** 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/nbench0.h b/nbench0.h
index 46ef994..5db3855 100644
--- a/nbench0.h
+++ b/nbench0.h
@@ -351,4 +351,6 @@ void (*funcpointer[])(void) =
DoNNET,
DoLU };
-
+int32_t randwc(int32_t num);
+uint32_t abs_randwc(uint32_t num);
+int32_t randnum(int32_t lngval);