From 5a7f0d2e7b4265153ccc70051bdae8b851617ede Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Tue, 11 Nov 2008 23:00:38 +0000 Subject: Remove stupid datatypes. Begin code cleanup git-svn-id: svn://mattst88.com/svn/cleanbench/trunk@5 0d43b9a7-5ab2-4d7b-af9d-f64450cef757 --- assignment.c | 60 ++++++++++++------------- bdoc.txt | 3 +- emfloat.c | 140 ++++++++++++++++++++++++++++----------------------------- emfloat.h | 50 ++++++++------------- fourier.c | 26 +++++------ idea.c | 92 +++++++++++++++++++------------------- linear.c | 74 +++++++++++++++--------------- misc.c | 24 +++++----- misc.h | 6 +-- nbench0.c | 10 ++--- neural.c | 16 +++---- nmglobal.h | 144 +++++++++++------------------------------------------------ sysspec.c | 48 ++++++++++---------- sysspec.h | 18 ++++---- 14 files changed, 303 insertions(+), 408 deletions(-) diff --git a/assignment.c b/assignment.c index 7313d78..a4f3b5f 100644 --- a/assignment.c +++ b/assignment.c @@ -27,10 +27,10 @@ void DoAssign(void) { AssignStruct *locassignstruct; /* Local structure ptr */ -farlong *arraybase; +long *arraybase; char *errorcontext; int systemerror; -ulong accumtime; +unsigned long accumtime; double iterations; /* @@ -60,12 +60,12 @@ if(locassignstruct->adjust==0) /* ** Allocate space for arrays */ - arraybase=(farlong *) AllocateMemory(sizeof(long)* + arraybase=(long *) AllocateMemory(sizeof(long)* ASSIGNROWS*ASSIGNCOLS*locassignstruct->numarrays, &systemerror); if(systemerror) { ReportError(errorcontext,systemerror); - FreeMemory((farvoid *)arraybase, + FreeMemory((void *)arraybase, &systemerror); ErrorExit(); } @@ -80,7 +80,7 @@ if(locassignstruct->adjust==0) locassignstruct->numarrays)>global_min_ticks) break; /* We're ok...exit */ - FreeMemory((farvoid *)arraybase, &systemerror); + FreeMemory((void *)arraybase, &systemerror); locassignstruct->numarrays++; } } @@ -88,12 +88,12 @@ else { /* ** Allocate space for arrays */ - arraybase=(farlong *)AllocateMemory(sizeof(long)* + arraybase=(long *)AllocateMemory(sizeof(long)* ASSIGNROWS*ASSIGNCOLS*locassignstruct->numarrays, &systemerror); if(systemerror) { ReportError(errorcontext,systemerror); - FreeMemory((farvoid *)arraybase, + FreeMemory((void *)arraybase, &systemerror); ErrorExit(); } @@ -115,7 +115,7 @@ do { ** Clean up, calculate results, and go home. Be sure to ** show that we don't have to rerun adjustment code. */ -FreeMemory((farvoid *)arraybase,&systemerror); +FreeMemory((void *)arraybase,&systemerror); locassignstruct->iterspersec=iterations * (double)locassignstruct->numarrays / TicksToFracSecs(accumtime); @@ -133,12 +133,12 @@ return; ** This routine executes one iteration of the assignment test. ** It returns the number of ticks elapsed in the iteration. */ -static ulong DoAssignIteration(farlong *arraybase, - ulong numarrays) +static unsigned long DoAssignIteration(long *arraybase, + unsigned long numarrays) { longptr abase; /* local pointer */ -ulong elapsed; /* Elapsed ticks */ -ulong i; +unsigned long elapsed; /* Elapsed ticks */ +unsigned long i; /* ** Set up local pointer @@ -177,11 +177,11 @@ return(StopStopwatch(elapsed)); ** Load the assignment arrays with random numbers. All positive. ** These numbers represent costs. */ -static void LoadAssignArrayWithRand(farlong *arraybase, - ulong numarrays) +static void LoadAssignArrayWithRand(long *arraybase, + unsigned long numarrays) { longptr abase,abase1; /* Local for array pointer */ -ulong i; +unsigned long i; /* ** Set local array pointer @@ -211,20 +211,20 @@ return; ** The array given by arraybase is loaded with positive random ** numbers. Elements in the array are capped at 5,000,000. */ -static void LoadAssign(farlong arraybase[][ASSIGNCOLS]) +static void LoadAssign(long arraybase[][ASSIGNCOLS]) { -ushort i,j; +unsigned short i,j; /* ** Reset random number generator so things repeat. */ /* randnum(13L); */ -randnum((int32)13); +randnum(13); for(i=0;i=0;i--) { accum=mantissa[i]; @@ -334,12 +334,12 @@ return; ** Shift a mantissa right by 1 bit. Provides carry, as ** above */ -static void ShiftMantRight1(u16 *carry, - u16 *mantissa) +static void ShiftMantRight1(uint16_t *carry, + uint16_t *mantissa) { int i; /* Index */ int new_carry; -u16 accum; +uint16_t accum; for(i=0;imantissa; @@ -409,7 +409,7 @@ return; */ static void normalize(InternalFPF *ptr) { -u16 carry; +uint16_t carry; /* ** As long as there's a highmost 0 bit, shift the significand @@ -561,14 +561,14 @@ return; ** Internal-representation numbers pointed to by x and y are ** added/subtracted and the result returned in z. */ -static void AddSubInternalFPF(uchar operation, +static void AddSubInternalFPF(unsigned char operation, InternalFPF *x, InternalFPF *y, InternalFPF *z) { int exponent_difference; -u16 borrow; -u16 carry; +uint16_t borrow; +uint16_t carry; int i; InternalFPF locx,locy; /* Needed since we alter them */ @@ -776,8 +776,8 @@ static void MultiplyInternalFPF(InternalFPF *x, { int i; int j; -u16 carry; -u16 extra_bits[INTERNAL_FPF_PRECISION]; +uint16_t carry; +uint16_t extra_bits[INTERNAL_FPF_PRECISION]; InternalFPF locy; /* Needed since this will be altered */ /* ** As in the preceding function, this large switch @@ -938,8 +938,8 @@ static void DivideInternalFPF(InternalFPF *x, { int i; int j; -u16 carry; -u16 extra_bits[INTERNAL_FPF_PRECISION]; +uint16_t carry; +uint16_t extra_bits[INTERNAL_FPF_PRECISION]; InternalFPF locx; /* Local for x number */ /* @@ -1091,20 +1091,20 @@ RoundInternalFPF(z); ** Convert a signed (long) 32-bit integer into an internal FPF number. */ /* static void LongToInternalFPF(long mylong, */ -static void Int32ToInternalFPF(int32 mylong, +static void Int32ToInternalFPF(int32_t mylong, InternalFPF *dest) { int i; /* Index */ -u16 myword; /* Used to hold converted stuff */ +uint16_t myword; /* Used to hold converted stuff */ /* ** Save the sign and get the absolute value. This will help us ** with 64-bit machines, since we use only the lower 32 ** bits just in case. (No longer necessary after we use int32.) */ /* if(mylong<0L) */ -if(mylong<(int32)0) +if(mylong<0) { dest->sign=1; - mylong=(int32)0-mylong; + mylong=0-mylong; } else dest->sign=0; @@ -1133,9 +1133,9 @@ if(mylong==0) ** up the exponent properly. */ dest->exp=32; -myword=(u16)((mylong >> 16) & 0xFFFFL); +myword=(uint16_t)((mylong >> 16) & 0xFFFFL); dest->mantissa[0]=myword; -myword=(u16)(mylong & 0xFFFFL); +myword=(uint16_t)(mylong & 0xFFFFL); dest->mantissa[1]=myword; normalize(dest); return; @@ -1168,8 +1168,8 @@ int msign; /* Holding for mantissa sign */ int expcount; /* Exponent counter */ int ccount; /* Character counter */ int i,j,k; /* Index */ -u16 carryaccum; /* Carry accumulator */ -u16 mycarry; /* Local for carry */ +uint16_t carryaccum; /* Carry accumulator */ +uint16_t mycarry; /* Local for carry */ /* ** Check first for the simple things...Nan, Infinity, Zero. @@ -1206,7 +1206,7 @@ memcpy((void *)&locFPFNum,(void *)src,sizeof(InternalFPF)); ** Set up a floating-point 10...which we'll use a lot in a minute. */ /* LongToInternalFPF(10L,&IFPF10); */ -Int32ToInternalFPF((int32)10,&IFPF10); +Int32ToInternalFPF((int32_t)10,&IFPF10); /* ** Save the mantissa sign and make it positive. diff --git a/emfloat.h b/emfloat.h index 7699c1e..2761ae5 100644 --- a/emfloat.h +++ b/emfloat.h @@ -26,19 +26,7 @@ */ #include - -/* -** DEFINES -*/ -#define u8 unsigned char -#define u16 unsigned short -#ifdef LONG64 -#define u32 unsigned int -#else -#define u32 unsigned long -#endif -#define uchar unsigned char -#define ulong unsigned long +#include #define MAX_EXP 32767L #define MIN_EXP (-32767L) @@ -97,44 +85,44 @@ typedef struct { - u8 type; /* Indicates, NORMAL, SUBNORMAL, etc. */ - u8 sign; /* Mantissa sign */ + uint8_t type; /* Indicates, NORMAL, SUBNORMAL, etc. */ + uint8_t sign; /* Mantissa sign */ short exp; /* Signed exponent...no bias */ - u16 mantissa[INTERNAL_FPF_PRECISION]; + uint16_t mantissa[INTERNAL_FPF_PRECISION]; } InternalFPF; /* ** PROTOTYPES */ void SetupCPUEmFloatArrays(InternalFPF *abase, - InternalFPF *bbase, InternalFPF *cbase, ulong arraysize); -ulong DoEmFloatIteration(InternalFPF *abase, + InternalFPF *bbase, InternalFPF *cbase, unsigned long arraysize); +unsigned long DoEmFloatIteration(InternalFPF *abase, InternalFPF *bbase, InternalFPF *cbase, - ulong arraysize, ulong loops); + unsigned long arraysize, unsigned long loops); static void SetInternalFPFZero(InternalFPF *dest, - uchar sign); + unsigned char sign); static void SetInternalFPFInfinity(InternalFPF *dest, - uchar sign); + unsigned char sign); static void SetInternalFPFNaN(InternalFPF *dest); -static int IsMantissaZero(u16 *mant); -static void Add16Bits(u16 *carry,u16 *a,u16 b,u16 c); -static void Sub16Bits(u16 *borrow,u16 *a,u16 b,u16 c); -static void ShiftMantLeft1(u16 *carry,u16 *mantissa); -static void ShiftMantRight1(u16 *carry,u16 *mantissa); +static int IsMantissaZero(uint16_t *mant); +static void Add16Bits(uint16_t *carry,uint16_t *a,uint16_t b,uint16_t c); +static void Sub16Bits(uint16_t *borrow,uint16_t *a,uint16_t b,uint16_t c); +static void ShiftMantLeft1(uint16_t *carry,uint16_t *mantissa); +static void ShiftMantRight1(uint16_t *carry,uint16_t *mantissa); static void StickyShiftRightMant(InternalFPF *ptr,int amount); static void normalize(InternalFPF *ptr); static void denormalize(InternalFPF *ptr,int minimum_exponent); void RoundInternalFPF(InternalFPF *ptr); static void choose_nan(InternalFPF *x,InternalFPF *y,InternalFPF *z, int intel_flag); -static void AddSubInternalFPF(uchar operation,InternalFPF *x, +static void AddSubInternalFPF(unsigned char operation,InternalFPF *x, InternalFPF *y,InternalFPF *z); static void MultiplyInternalFPF(InternalFPF *x,InternalFPF *y, InternalFPF *z); static void DivideInternalFPF(InternalFPF *x,InternalFPF *y, InternalFPF *z); /* static void LongToInternalFPF(long mylong, */ -static void Int32ToInternalFPF(int32 mylong, +static void Int32ToInternalFPF(int32_t mylong, InternalFPF *dest); #ifdef DEBUG static int InternalFPFToString(char *dest, @@ -144,7 +132,7 @@ static int InternalFPFToString(char *dest, /* ** EXTERNALS */ -extern ulong StartStopwatch(); -extern ulong StopStopwatch(ulong elapsed); +extern unsigned long StartStopwatch(); +extern unsigned long StopStopwatch(unsigned long elapsed); /* extern long randwc(long num); */ -extern int32 randwc(int32 num); +extern int32_t randwc(int32_t num); diff --git a/fourier.c b/fourier.c index 1c95cb7..b6f40c8 100644 --- a/fourier.c +++ b/fourier.c @@ -22,8 +22,8 @@ void DoFourier(void) { FourierStruct *locfourierstruct; /* Local fourier struct */ -fardouble *abase; /* Base of A[] coefficients array */ -fardouble *bbase; /* Base of B[] coefficients array */ +double *abase; /* Base of A[] coefficients array */ +double *bbase; /* Base of B[] coefficients array */ unsigned long accumtime; /* Accumulated time in ticks */ double iterations; /* # of iterations */ char *errorcontext; /* Error context string pointer */ @@ -48,14 +48,14 @@ if(locfourierstruct->adjust==0) while(1) { - abase=(fardouble *)AllocateMemory(locfourierstruct->arraysize*sizeof(double), + abase=(double *)AllocateMemory(locfourierstruct->arraysize*sizeof(double), &systemerror); if(systemerror) { ReportError(errorcontext,systemerror); ErrorExit(); } - bbase=(fardouble *)AllocateMemory(locfourierstruct->arraysize*sizeof(double), + bbase=(double *)AllocateMemory(locfourierstruct->arraysize*sizeof(double), &systemerror); if(systemerror) { ReportError(errorcontext,systemerror); @@ -74,8 +74,8 @@ if(locfourierstruct->adjust==0) /* ** Make bigger arrays and try again. */ - FreeMemory((farvoid *)abase,&systemerror); - FreeMemory((farvoid *)bbase,&systemerror); + FreeMemory((void *)abase,&systemerror); + FreeMemory((void *)bbase,&systemerror); locfourierstruct->arraysize+=50L; } } @@ -84,14 +84,14 @@ else ** Don't need self-adjustment. Just allocate the ** arrays, and go. */ - abase=(fardouble *)AllocateMemory(locfourierstruct->arraysize*sizeof(double), + abase=(double *)AllocateMemory(locfourierstruct->arraysize*sizeof(double), &systemerror); if(systemerror) { ReportError(errorcontext,systemerror); ErrorExit(); } - bbase=(fardouble *)AllocateMemory(locfourierstruct->arraysize*sizeof(double), + bbase=(double *)AllocateMemory(locfourierstruct->arraysize*sizeof(double), &systemerror); if(systemerror) { ReportError(errorcontext,systemerror); @@ -116,8 +116,8 @@ do { ** Clean up, calculate results, and go home. ** Also set adjustment flag to indicate no adjust code needed. */ -FreeMemory((farvoid *)abase,&systemerror); -FreeMemory((farvoid *)bbase,&systemerror); +FreeMemory((void *)abase,&systemerror); +FreeMemory((void *)bbase,&systemerror); locfourierstruct->fflops=iterations/(double)TicksToFracSecs(accumtime); @@ -137,9 +137,9 @@ return; ** NOTE: The # of integration steps is fixed at ** 200. */ -static ulong DoFPUTransIteration(fardouble *abase, /* A coeffs. */ - fardouble *bbase, /* B coeffs. */ - ulong arraysize) /* # of coeffs */ +static unsigned long DoFPUTransIteration(double *abase, /* A coeffs. */ + double *bbase, /* B coeffs. */ + unsigned long arraysize) /* # of coeffs */ { double omega; /* Fundamental frequency */ unsigned long i; /* Index */ diff --git a/idea.c b/idea.c index 43abad9..464dc74 100644 --- a/idea.c +++ b/idea.c @@ -22,14 +22,14 @@ void DoIDEA(void) IDEAStruct *locideastruct; /* Loc pointer to global structure */ int i; IDEAkey Z,DK; -u16 userkey[8]; -ulong accumtime; +uint16_t userkey[8]; +unsigned long accumtime; double iterations; char *errorcontext; int systemerror; -faruchar *plain1; /* First plaintext buffer */ -faruchar *crypt1; /* Encryption buffer */ -faruchar *plain2; /* Second plaintext buffer */ +unsigned char *plain1; /* First plaintext buffer */ +unsigned char *crypt1; /* Encryption buffer */ +unsigned char *plain2; /* Second plaintext buffer */ /* ** Link to global data @@ -45,14 +45,14 @@ errorcontext="CPU:IDEA"; ** Re-init random-number generator. */ /* randnum(3L); */ -randnum((int32)3); +randnum(3); /* ** Build an encryption/decryption key */ for (i=0;i<8;i++) - /* userkey[i]=(u16)(abs_randwc(60000L) & 0xFFFF); */ - userkey[i]=(u16)(abs_randwc((int32)60000) & 0xFFFF); + /* userkey[i]=(uint16_t)(abs_randwc(60000L) & 0xFFFF); */ + userkey[i]=(uint16_t)(abs_randwc((int32_t)60000) & 0xFFFF); for(i=0;iarraysize,&systemerror); +plain1=(unsigned char *)AllocateMemory(locideastruct->arraysize,&systemerror); if(systemerror) { ReportError(errorcontext,systemerror); ErrorExit(); } -crypt1=(faruchar *)AllocateMemory(locideastruct->arraysize,&systemerror); +crypt1=(unsigned char *)AllocateMemory(locideastruct->arraysize,&systemerror); if(systemerror) { ReportError(errorcontext,systemerror); - FreeMemory((farvoid *)plain1,&systemerror); + FreeMemory((void *)plain1,&systemerror); ErrorExit(); } -plain2=(faruchar *)AllocateMemory(locideastruct->arraysize,&systemerror); +plain2=(unsigned char *)AllocateMemory(locideastruct->arraysize,&systemerror); if(systemerror) { ReportError(errorcontext,systemerror); - FreeMemory((farvoid *)plain1,&systemerror); - FreeMemory((farvoid *)crypt1,&systemerror); + FreeMemory((void *)plain1,&systemerror); + FreeMemory((void *)crypt1,&systemerror); ErrorExit(); } /* @@ -97,7 +97,7 @@ if(systemerror) ** the array up with random numbers. */ for(i=0;iarraysize;i++) - plain1[i]=(uchar)(abs_randwc(255) & 0xFF); + plain1[i]=(unsigned char)(abs_randwc(255) & 0xFF); /* ** See if we need to perform self adjustment loop. @@ -135,9 +135,9 @@ do { ** Clean up, calculate results, and go home. Be sure to ** show that we don't have to rerun adjustment code. */ -FreeMemory((farvoid *)plain1,&systemerror); -FreeMemory((farvoid *)crypt1,&systemerror); -FreeMemory((farvoid *)plain2,&systemerror); +FreeMemory((void *)plain1,&systemerror); +FreeMemory((void *)crypt1,&systemerror); +FreeMemory((void *)plain2,&systemerror); locideastruct->iterspersec=iterations / TicksToFracSecs(accumtime); if(locideastruct->adjust==0) @@ -154,17 +154,17 @@ return; ** Actually, a single iteration is one encryption and one ** decryption. */ -static ulong DoIDEAIteration(faruchar *plain1, - faruchar *crypt1, - faruchar *plain2, - ulong arraysize, - ulong nloops, +static unsigned long DoIDEAIteration(unsigned char *plain1, + unsigned char *crypt1, + unsigned char *plain2, + unsigned long arraysize, + unsigned long nloops, IDEAkey Z, IDEAkey DK) { -register ulong i; -register ulong j; -ulong elapsed; +register unsigned long i; +register unsigned long j; +unsigned long elapsed; #ifdef DEBUG int status=0; #endif @@ -179,11 +179,11 @@ elapsed=StartStopwatch(); */ for(i=0;i>16); + a=(uint16_t)(p>>16); return(b-a+(badjust==0) loclustruct->numarrays=0; for(i=1;i<=MAXLUARRAYS;i++) { - abase=(fardouble *)AllocateMemory(sizeof(double) * + abase=(double *)AllocateMemory(sizeof(double) * LUARRAYCOLS*LUARRAYROWS*(i+1),&systemerror); if(systemerror) { ReportError(errorcontext,systemerror); - LUFreeMem(a,b,(fardouble *)NULL,(fardouble *)NULL); + LUFreeMem(a,b,(double *)NULL,(double *)NULL); ErrorExit(); } - bbase=(fardouble *)AllocateMemory(sizeof(double) * + bbase=(double *)AllocateMemory(sizeof(double) * LUARRAYROWS*(i+1),&systemerror); if(systemerror) { ReportError(errorcontext,systemerror); - LUFreeMem(a,b,abase,(fardouble *)NULL); + LUFreeMem(a,b,abase,(double *)NULL); ErrorExit(); } if(DoLUIteration(a,b,abase,bbase,i)>global_min_ticks) @@ -105,8 +105,8 @@ if(loclustruct->adjust==0) /* ** Not enough arrays...free them all and try again */ - FreeMemory((farvoid *)abase,&systemerror); - FreeMemory((farvoid *)bbase,&systemerror); + FreeMemory((void *)abase,&systemerror); + FreeMemory((void *)bbase,&systemerror); } /* ** Were we able to do it? @@ -122,20 +122,20 @@ else ** Don't need to adjust -- just allocate the proper ** number of arrays and proceed. */ - abase=(fardouble *)AllocateMemory(sizeof(double) * + abase=(double *)AllocateMemory(sizeof(double) * LUARRAYCOLS*LUARRAYROWS*loclustruct->numarrays, &systemerror); if(systemerror) { ReportError(errorcontext,systemerror); - LUFreeMem(a,b,(fardouble *)NULL,(fardouble *)NULL); + LUFreeMem(a,b,(double *)NULL,(double *)NULL); ErrorExit(); } - bbase=(fardouble *)AllocateMemory(sizeof(double) * + bbase=(double *)AllocateMemory(sizeof(double) * LUARRAYROWS*loclustruct->numarrays,&systemerror); if(systemerror) { ReportError(errorcontext,systemerror); - LUFreeMem(a,b,abase,(fardouble *)NULL); + LUFreeMem(a,b,abase,(double *)NULL); ErrorExit(); } } @@ -169,17 +169,17 @@ return; *************** ** Release memory associated with LU benchmark. */ -static void LUFreeMem(fardouble *a, fardouble *b, - fardouble *abase,fardouble *bbase) +static void LUFreeMem(double *a, double *b, + double *abase,double *bbase) { int systemerror; -FreeMemory((farvoid *)a,&systemerror); -FreeMemory((farvoid *)b,&systemerror); -FreeMemory((farvoid *)LUtempvv,&systemerror); +FreeMemory((void *)a,&systemerror); +FreeMemory((void *)b,&systemerror); +FreeMemory((void *)LUtempvv,&systemerror); -if(abase!=(fardouble *)NULL) FreeMemory((farvoid *)abase,&systemerror); -if(bbase!=(fardouble *)NULL) FreeMemory((farvoid *)bbase,&systemerror); +if(abase!=(double *)NULL) FreeMemory((void *)abase,&systemerror); +if(bbase!=(double *)NULL) FreeMemory((void *)bbase,&systemerror); return; } @@ -190,15 +190,15 @@ return; ** An iteration refers to the repeated solution of several ** identical matrices. */ -static ulong DoLUIteration(fardouble *a,fardouble *b, - fardouble *abase, fardouble *bbase, - ulong numarrays) +static unsigned long DoLUIteration(double *a,double *b, + double *abase, double *bbase, + unsigned long numarrays) { -fardouble *locabase; -fardouble *locbbase; +double *locabase; +double *locbbase; LUdblptr ptra; /* For converting ptr to 2D array */ -ulong elapsed; -ulong j,i; /* Indexes */ +unsigned long elapsed; +unsigned long j,i; /* Indexes */ /* @@ -250,7 +250,7 @@ double rcon; /* Random constant */ ** Reset random number generator */ /* randnum(13L); */ -randnum((int32)13); +randnum((int32_t)13); /* ** Build an identity matrix. @@ -259,11 +259,11 @@ randnum((int32)13); */ for(i=0;iadjust==0) locnnetstruct->loopsloops++) { /*randnum(3L); */ - randnum((int32)3); + randnum((int32_t)3); if(DoNNetIteration(locnnetstruct->loops) >global_min_ticks) break; } @@ -111,7 +111,7 @@ iterations=(double)0.0; do { /* randnum(3L); */ /* Gotta do this for Neural Net */ - randnum((int32)3); /* Gotta do this for Neural Net */ + randnum((int32_t)3); /* Gotta do this for Neural Net */ accumtime+=DoNNetIteration(locnnetstruct->loops); iterations+=(double)locnnetstruct->loops; } while(TicksToSecs(accumtime)request_secs); @@ -135,9 +135,9 @@ return; ** Do a single iteration of the neural net benchmark. ** By iteration, we mean a "learning" pass. */ -static ulong DoNNetIteration(ulong nloops) +static unsigned long DoNNetIteration(unsigned long nloops) { -ulong elapsed; /* Elapsed time */ +unsigned long elapsed; /* Elapsed time */ int patt; /* @@ -602,7 +602,7 @@ for (neurode = 0; neurode /* +++ MEMORY +++ */ @@ -96,46 +97,6 @@ */ /* #define WIN31TIMER */ -/* +++ MISCELLANEOUS +++ */ - -/* -** Define DOS16 if you'll be compiling under DOS in 16-bit -** (non DOS-extended) mode. This will enable proper definitions -** for the far*** typedefs -*/ -/* #define DOS16 */ - -/* -** Define MAC if you're compiling on a Macintosh. This -** does a number of things: -** includes unix.h -** Incorporates code to mimic the command line via either -** the console library (Symantec/Think) or the SIOUX -** library (Code Warrior). -*/ -/* #define MAC */ - -/* -** Define LONG64 if your compiler emits 64-bit longs. -** This is typically true of Alpha compilers on Unix -** systems...though, who knows, this may change in the -** future. I MOVED THIS DEFINTION INTO THE FILE pointer.h. DO NOT -** DEFINE IT HERE. IT WILL AUTOMATICALLY BE DEFINED IF NECESSARY. -** Uwe F. Mayer, Dec 15, 1996, Nov 15, 1997 -*/ -/* #define LONG64 */ - -/* -** Define MACCWPROF if you are profiling on the Mac using -** Code Warrior. This enables code that turns off the -** profiler in an evern of an error exit. -*/ -/* #define MACCWPROF */ - -#ifdef MAC -#include -#endif - /* ** ERROR CODES */ @@ -174,7 +135,7 @@ ** ** This is the maximum positive long. */ -#ifdef LONG64 +#ifdef _LP64 #define MAXPOSLONG 0x7FFFFFFFFFFFFFFFL #else #define MAXPOSLONG 0x7FFFFFFFL @@ -194,59 +155,6 @@ */ #define MEM_ARRAY_SIZE 20 -/* -** TYPEDEFS -*/ -#define ulong unsigned long -#define uchar unsigned char -#define uint unsigned int -#define ushort unsigned short -/* -typedef unsigned char uchar; -typedef unsigned int uint; -typedef unsigned short ushort; -typedef unsigned long ulong; -*/ -/* -** The 'farxxx' typedefs were added in deference to DOS, which -** requires far pointers to handle some of the bigger -** memory structures. Other systems will simply -** map 'farxxx' to 'xxx' -*/ -#ifdef DOS16 -typedef void huge farvoid; -typedef double huge fardouble; -typedef long huge farlong; -typedef unsigned long huge farulong; -typedef char huge farchar; -typedef unsigned char huge faruchar; - -#else - -typedef void farvoid; -typedef double fardouble; -typedef long farlong; -typedef unsigned long farulong; -typedef char farchar; -typedef unsigned char faruchar; - -#endif - -/* -** The following typedefs are used when element size -** is critical. You'll have to alter these for -** your specifical platform/compiler. -*/ -typedef unsigned char u8; /* Unsigned 8-bits */ -typedef unsigned short u16; /* Unsigned 16 bits */ -#ifdef LONG64 -typedef unsigned int u32; /* Unsigned 32 bits */ -typedef int int32; /* Signed 32 bit integer */ -#else -typedef unsigned long u32; /* Unsigned 32 bits */ -typedef long int32; /* Signed 32 bit integer */ -#endif - /***************** ** NUMERIC SORT ** *****************/ @@ -278,10 +186,10 @@ typedef long int32; /* Signed 32 bit integer */ */ typedef struct { int adjust; /* Set adjust code */ - ulong request_secs; /* # of seconds requested */ + unsigned long request_secs; /* # of seconds requested */ double sortspersec; /* # of sort iterations per sec */ - ushort numarrays; /* # of arrays */ - ulong arraysize; /* # of elements in array */ + unsigned short numarrays; /* # of arrays */ + unsigned long arraysize; /* # of elements in array */ } SortStruct; /**************** @@ -315,7 +223,7 @@ typedef struct { /* ** Following field sets the size of the bitfield array (in longs). */ -#ifdef LONG64 +#ifdef _LP64 #define BITFARRAYSIZE 16384L #else #define BITFARRAYSIZE 32768L @@ -326,10 +234,10 @@ typedef struct { */ typedef struct { int adjust; /* Set adjust code */ - ulong request_secs; /* # of seconds requested */ + unsigned long request_secs; /* # of seconds requested */ double bitopspersec; /* # of bitfield ops per sec */ - ulong bitoparraysize; /* Total # of bitfield ops */ - ulong bitfieldarraysize; /* Bit field array size */ + unsigned long bitoparraysize; /* Total # of bitfield ops */ + unsigned long bitfieldarraysize; /* Bit field array size */ } BitOpStruct; /**************************** @@ -360,9 +268,9 @@ typedef struct { */ typedef struct { int adjust; /* Set adjust code */ - ulong request_secs; /* # of seconds requested */ - ulong arraysize; /* Size of array */ - ulong loops; /* Loops per iterations */ + unsigned long request_secs; /* # of seconds requested */ + unsigned long arraysize; /* Size of array */ + unsigned long loops; /* Loops per iterations */ double emflops; /* Results */ } EmFloatStruct; @@ -375,8 +283,8 @@ typedef struct { */ typedef struct { int adjust; /* Set adjust code */ - ulong request_secs; /* # of requested seconds */ - ulong arraysize; /* Size of coeff. arrays */ + unsigned long request_secs; /* # of requested seconds */ + unsigned long arraysize; /* Size of coeff. arrays */ double fflops; /* Results */ } FourierStruct; @@ -389,8 +297,8 @@ typedef struct { */ typedef struct { int adjust; /* Set adjust code */ - ulong request_secs; /* Requested # of seconds */ - ulong numarrays; /* # of arrays */ + unsigned long request_secs; /* Requested # of seconds */ + unsigned long numarrays; /* # of arrays */ double iterspersec; /* Results */ } AssignStruct; @@ -419,9 +327,9 @@ typedef struct { */ typedef struct { int adjust; /* Set adjust code */ - ulong request_secs; /* Requested # of seconds */ - ulong arraysize; /* Size of array */ - ulong loops; /* # of times to convert */ + unsigned long request_secs; /* Requested # of seconds */ + unsigned long arraysize; /* Size of array */ + unsigned long loops; /* # of times to convert */ double iterspersec; /* Results */ } IDEAStruct; @@ -457,9 +365,9 @@ typedef struct { typedef struct { int adjust; /* Set adjust code */ - ulong request_secs; /* Requested # of seconds */ - ulong arraysize; /* Size of array */ - ulong loops; /* # of times to compress/decompress */ + unsigned long request_secs; /* Requested # of seconds */ + unsigned long arraysize; /* Size of array */ + unsigned long loops; /* # of times to compress/decompress */ double iterspersec; /* Results */ } HuffStruct; @@ -483,8 +391,8 @@ typedef struct { */ typedef struct { int adjust; /* Set adjust code */ - ulong request_secs; /* Requested # of seconds */ - ulong loops; /* # of times to learn */ + unsigned long request_secs; /* Requested # of seconds */ + unsigned long loops; /* # of times to learn */ double iterspersec; /* Results */ } NNetStruct; @@ -509,8 +417,8 @@ typedef struct { */ typedef struct { int adjust; /* Set adjust code */ - ulong request_secs; /* Requested # of seconds */ - ulong numarrays; /* # of arrays */ + unsigned long request_secs; /* Requested # of seconds */ + unsigned long numarrays; /* # of arrays */ double iterspersec; /* Results */ } LUStruct; diff --git a/sysspec.c b/sysspec.c index a97010d..ab6dc88 100644 --- a/sysspec.c +++ b/sysspec.c @@ -60,7 +60,7 @@ ** Currently, mem_array[][] is only used if you use malloc; ** it is not used for the 16-bit DOS and MAC versions. */ -farvoid *AllocateMemory(unsigned long nbytes, /* # of bytes to alloc */ +void *AllocateMemory(unsigned long nbytes, /* # of bytes to alloc */ int *errorcode) /* Returned error code */ { #ifdef DOS16MEM @@ -88,14 +88,14 @@ intdos(®isters,®isters); /* Call DOS */ if(registers.x.cflag) { printf("error: %d Lgst: %d\n",registers.x.ax,registers.x.bx); *errorcode=ERROR_MEMORY; - return((farvoid *)NULL); + return((void *)NULL); } /* -** Create a farvoid pointer to return. +** Create a void pointer to return. */ *errorcode=0; -return((farvoid *)MK_FP(registers.x.ax,0)); +return((void *)MK_FP(registers.x.ax,0)); #endif @@ -103,9 +103,9 @@ return((farvoid *)MK_FP(registers.x.ax,0)); /* ** For MAC CodeWarrior, we'll use the MacOS NewPtr call */ -farvoid *returnval; -returnval=(farvoid *)NewPtr((Size)nbytes); -if(returnval==(farvoid *)NULL) +void *returnval; +returnval=(void *)NewPtr((Size)nbytes); +if(returnval==(void *)NULL) *errorcode=ERROR_MEMORY; else *errorcode=0; @@ -118,12 +118,12 @@ return(returnval); ** that you use a 32-bit compiler which treats size_t as ** a 4-byte entity. */ -farvoid *returnval; /* Return value */ +void *returnval; /* Return value */ ulong true_addr; /* True address */ ulong adj_addr; /* Adjusted address */ -returnval=(farvoid *)malloc((size_t)(nbytes+2L*(long)global_align)); -if(returnval==(farvoid *)NULL) +returnval=(void *)malloc((size_t)(nbytes+2L*(long)global_align)); +if(returnval==(void *)NULL) *errorcode=ERROR_MEMORY; else *errorcode=0; @@ -163,7 +163,7 @@ return(returnval); ** block passed in is freed. Should an error occur, ** that error is returned in errorcode. */ -void FreeMemory(farvoid *mempointer, /* Pointer to memory block */ +void FreeMemory(void *mempointer, /* Pointer to memory block */ int *errorcode) { #ifdef DOS16MEM @@ -176,7 +176,7 @@ union REGS registers; struct SREGS sregisters; /* -** First get the segment/offset of the farvoid pointer. +** First get the segment/offset of the void pointer. */ segment=FP_SEG(mempointer); offset=FP_OFF(mempointer); @@ -238,8 +238,8 @@ return; ** In most cases, this is just a memmove operation. ** But, not in DOS....noooo.... */ -void MoveMemory( farvoid *destination, /* Destination address */ - farvoid *source, /* Source address */ +void MoveMemory( void *destination, /* Destination address */ + void *source, /* Source address */ unsigned long nbytes) { @@ -262,8 +262,8 @@ memmove(destination, source, nbytes); ** Performs the same function as memmove for DOS when ** the arrays are defined with far pointers. */ -void FarDOSmemmove(farvoid *destination, /* Destination pointer */ - farvoid *source, /* Source pointer */ +void FarDOSmemmove(void *destination, /* Destination pointer */ + void *source, /* Source pointer */ unsigned long nbytes) /* # of bytes to move */ { unsigned char huge *uchsource; /* Temp source */ @@ -293,8 +293,8 @@ if(saddr > daddr) ** We'll move 65535 bytes at a time. */ while(nbytes>=65535L) - { _fmemmove((farvoid *)uchdest, - (farvoid *)uchsource, + { _fmemmove((void *)uchdest, + (void *)uchsource, (size_t) 65535); uchsource+=65535; /* Advance pointers */ uchdest+=65535; @@ -305,8 +305,8 @@ if(saddr > daddr) ** Move remaining bytes */ if(nbytes!=0L) - _fmemmove((farvoid *)uchdest, - (farvoid *)uchsource, + _fmemmove((void *)uchdest, + (void *)uchsource, (size_t)(nbytes & 0xFFFF)); } @@ -329,8 +329,8 @@ else { uchsource-=65535; uchdest-=65535; - _fmemmove((farvoid *)uchdest, - (farvoid *)uchsource, + _fmemmove((void *)uchdest, + (void *)uchsource, (size_t) 65535); nbytes-=65535; } @@ -341,8 +341,8 @@ else if(nbytes!=0L) { uchsource-=nbytes; uchdest-=nbytes; - _fmemmove((farvoid *)uchdest, - (farvoid *)uchsource, + _fmemmove((void *)uchdest, + (void *)uchsource, (size_t)(nbytes & 0xFFFF)); } } diff --git a/sysspec.h b/sysspec.h index ba57a96..d612b78 100644 --- a/sysspec.h +++ b/sysspec.h @@ -80,7 +80,7 @@ FARPROC lpfn; /************** ** EXTERNALS ** **************/ -extern ulong mem_array[2][MEM_ARRAY_SIZE]; +extern unsigned long mem_array[2][MEM_ARRAY_SIZE]; extern int mem_array_ents; extern int global_align; @@ -88,27 +88,27 @@ extern int global_align; ** FUNCTION PROTOTYPES ** ****************************/ -farvoid *AllocateMemory(unsigned long nbytes, +void *AllocateMemory(unsigned long nbytes, int *errorcode); -void FreeMemory(farvoid *mempointer, +void FreeMemory(void *mempointer, int *errorcode); -void MoveMemory( farvoid *destination, - farvoid *source, +void MoveMemory( void *destination, + void *source, unsigned long nbytes); #ifdef DOS16MEM -void FarDOSmemmove(farvoid *destination, - farvoid *source, +void FarDOSmemmove(void *destination, + void *source, unsigned long nbytes); #endif void InitMemArray(void); -int AddMemArray(ulong true_addr, ulong adj_addr); +int AddMemArray(unsigned long true_addr, unsigned long adj_addr); -int RemoveMemArray(ulong adj_addr,ulong *true_addr); +int RemoveMemArray(unsigned long adj_addr,unsigned long *true_addr); void ReportError(char *context, int errorcode); -- cgit v1.2.3