diff options
-rw-r--r-- | assignment.c | 60 | ||||
-rw-r--r-- | bdoc.txt | 3 | ||||
-rw-r--r-- | emfloat.c | 140 | ||||
-rw-r--r-- | emfloat.h | 50 | ||||
-rw-r--r-- | fourier.c | 26 | ||||
-rw-r--r-- | idea.c | 92 | ||||
-rw-r--r-- | linear.c | 74 | ||||
-rw-r--r-- | misc.c | 24 | ||||
-rw-r--r-- | misc.h | 6 | ||||
-rw-r--r-- | nbench0.c | 10 | ||||
-rw-r--r-- | neural.c | 16 | ||||
-rw-r--r-- | nmglobal.h | 144 | ||||
-rw-r--r-- | sysspec.c | 48 | ||||
-rw-r--r-- | 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<ASSIGNROWS;i++) for(j=0;j<ASSIGNROWS;j++){ /* arraybase[i][j]=abs_randwc(5000000L);*/ - arraybase[i][j]=abs_randwc((int32)5000000); + arraybase[i][j]=abs_randwc((int32_t)5000000); } return; @@ -237,10 +237,10 @@ return; ** the routine that builds the initial array, and is used to copy ** the contents of the intial array into all following arrays. */ -static void CopyToAssign(farlong arrayfrom[ASSIGNROWS][ASSIGNCOLS], - farlong arrayto[ASSIGNROWS][ASSIGNCOLS]) +static void CopyToAssign(long arrayfrom[ASSIGNROWS][ASSIGNCOLS], + long arrayto[ASSIGNROWS][ASSIGNCOLS]) { -ushort i,j; +unsigned short i,j; for(i=0;i<ASSIGNROWS;i++) for(j=0;j<ASSIGNCOLS;j++) @@ -252,7 +252,7 @@ return; /*************** ** Assignment ** ***************/ -static void Assignment(farlong arraybase[][ASSIGNCOLS]) +static void Assignment(long arraybase[][ASSIGNCOLS]) { short assignedtableau[ASSIGNROWS][ASSIGNCOLS]; @@ -295,7 +295,7 @@ return; */ static void calc_minimum_costs(long tableau[][ASSIGNCOLS]) { -ushort i,j; /* Index variables */ +unsigned short i,j; /* Index variables */ long currentmin; /* Current minimum */ /* ** Determine minimum costs on row basis. This is done by @@ -355,10 +355,10 @@ return; static int first_assignments(long tableau[][ASSIGNCOLS], short assignedtableau[][ASSIGNCOLS]) { -ushort i,j,k; /* Index variables */ -ushort numassigns; /* # of assignments */ -ushort totnumassigns; /* Total # of assignments */ -ushort numzeros; /* # of zeros in row */ +unsigned short i,j,k; /* Index variables */ +unsigned short numassigns; /* # of assignments */ +unsigned short totnumassigns; /* Total # of assignments */ +unsigned short numzeros; /* # of zeros in row */ int selected=0; /* Flag used to indicate selection */ /* @@ -474,8 +474,8 @@ int i,j; /* Indexes */ short linesrow[ASSIGNROWS]; short linescol[ASSIGNCOLS]; long smallest; /* Holds smallest value */ -ushort numassigns; /* Number of assignments */ -ushort newrows; /* New rows to be considered */ +unsigned short numassigns; /* Number of assignments */ +unsigned short newrows; /* New rows to be considered */ /* ** Clear the linesrow and linescol arrays. */ @@ -1104,8 +1104,7 @@ Porting Considerations The bitfield operations benchmark is dependent on the size of the long datatype. On most systems, this is 32 bits. However, on some of the newer -RISC chips, a long can be 64 bits long. If your system does use 64-bit -longs, you'll need to #define the symbol LONG64. +RISC chips, a long can be 64 bits long. If you are unsure of the size of a long in your system (some C compiler manuals make it difficult to discover), simply place an ALLSTATS=T line in @@ -58,24 +58,24 @@ void SetupCPUEmFloatArrays(InternalFPF *abase, InternalFPF *bbase, InternalFPF *cbase, - ulong arraysize) + unsigned long arraysize) { -ulong i; +unsigned long i; InternalFPF locFPF1,locFPF2; /* ** Reset random number generator so things repeat. Inserted by Uwe F. Mayer. */ -extern int32 randnum(int32 lngval); -randnum((int32)13); +extern int32_t randnum(int32_t lngval); +randnum(13); for(i=0;i<arraysize;i++) {/* LongToInternalFPF(randwc(50000L),&locFPF1); */ - Int32ToInternalFPF(randwc((int32)50000),&locFPF1); + Int32ToInternalFPF(randwc(50000),&locFPF1); /* LongToInternalFPF(randwc(50000L)+1L,&locFPF2); */ - Int32ToInternalFPF(randwc((int32)50000)+(int32)1,&locFPF2); + Int32ToInternalFPF(randwc(50000)+1,&locFPF2); DivideInternalFPF(&locFPF1,&locFPF2,abase+i); /* LongToInternalFPF(randwc(50000L)+1L,&locFPF2); */ - Int32ToInternalFPF(randwc((int32)50000)+(int32)1,&locFPF2); + Int32ToInternalFPF(randwc(50000)+1,&locFPF2); DivideInternalFPF(&locFPF1,&locFPF2,bbase+i); } return; @@ -88,14 +88,14 @@ return; ** benchmark. Note that "an iteration" can involve multiple ** loops through the benchmark. */ -ulong DoEmFloatIteration(InternalFPF *abase, +unsigned long DoEmFloatIteration(InternalFPF *abase, InternalFPF *bbase, InternalFPF *cbase, - ulong arraysize, ulong loops) + unsigned long arraysize, unsigned long loops) { -ulong elapsed; /* For the stopwatch */ -static uchar jtable[16] = {0,0,0,0,1,1,1,1,2,2,2,2,2,3,3,3}; -ulong i; +unsigned long elapsed; /* For the stopwatch */ +static unsigned char jtable[16] = {0,0,0,0,1,1,1,1,2,2,2,2,2,3,3,3}; +unsigned long i; #ifdef DEBUG int number_of_loops; #endif @@ -141,20 +141,20 @@ while(loops--) } #ifdef DEBUG { - ulong j[8]; /* we test 8 entries */ + unsigned long j[8]; /* we test 8 entries */ int k; - ulong i; + unsigned long i; char buffer[1024]; if (number_of_loops==loops) /* the first loop */ { - j[0]=(ulong)2; - j[1]=(ulong)6; - j[2]=(ulong)10; - j[3]=(ulong)14; - j[4]=(ulong)(arraysize-14); - j[5]=(ulong)(arraysize-10); - j[6]=(ulong)(arraysize-6); - j[7]=(ulong)(arraysize-2); + j[0]=(unsigned long)2; + j[1]=(unsigned long)6; + j[2]=(unsigned long)10; + j[3]=(unsigned long)14; + j[4]=(unsigned long)(arraysize-14); + j[5]=(unsigned long)(arraysize-10); + j[6]=(unsigned long)(arraysize-6); + j[7]=(unsigned long)(arraysize-2); for(k=0;k<8;k++){ i=j[k]; InternalFPFToString(buffer,abase+i); @@ -186,7 +186,7 @@ return(StopStopwatch(elapsed)); ** sign determines the sign of the zero. */ static void SetInternalFPFZero(InternalFPF *dest, - uchar sign) + unsigned char sign) { int i; /* Index */ @@ -206,7 +206,7 @@ return; ** As above, sign picks the sign of infinity. */ static void SetInternalFPFInfinity(InternalFPF *dest, - uchar sign) + unsigned char sign) { int i; /* Index */ @@ -246,7 +246,7 @@ return; ** number's mantissa. It checks for an all-zero mantissa. ** Returns 0 if it is NOT all zeros, !=0 otherwise. */ -static int IsMantissaZero(u16 *mant) +static int IsMantissaZero(uint16_t *mant) { int i; /* Index */ int n; /* Return value */ @@ -263,22 +263,22 @@ return(!n); *************** ** Add b, c, and carry. Retult in a. New carry in carry. */ -static void Add16Bits(u16 *carry, - u16 *a, - u16 b, - u16 c) +static void Add16Bits(uint16_t *carry, + uint16_t *a, + uint16_t b, + uint16_t c) { -u32 accum; /* Accumulator */ +uint32_t accum; /* Accumulator */ /* ** Do the work in the 32-bit accumulator so we can return ** the carry. */ -accum=(u32)b; -accum+=(u32)c; -accum+=(u32)*carry; -*carry=(u16)((accum & 0x00010000) ? 1 : 0); /* New carry */ -*a=(u16)(accum & 0xFFFF); /* Result is lo 16 bits */ +accum=(uint32_t)b; +accum+=(uint32_t)c; +accum+=(uint32_t)*carry; +*carry=(uint16_t)((accum & 0x00010000) ? 1 : 0); /* New carry */ +*a=(uint16_t)(accum & 0xFFFF); /* Result is lo 16 bits */ return; } @@ -287,18 +287,18 @@ return; *************** ** Additive inverse of above. */ -static void Sub16Bits(u16 *borrow, - u16 *a, - u16 b, - u16 c) +static void Sub16Bits(uint16_t *borrow, + uint16_t *a, + uint16_t b, + uint16_t c) { -u32 accum; /* Accumulator */ +uint32_t accum; /* Accumulator */ -accum=(u32)b; -accum-=(u32)c; -accum-=(u32)*borrow; -*borrow=(u32)((accum & 0x00010000) ? 1 : 0); /* New borrow */ -*a=(u16)(accum & 0xFFFF); +accum=(uint32_t)b; +accum-=(uint32_t)c; +accum-=(uint32_t)*borrow; +*borrow=(uint32_t)((accum & 0x00010000) ? 1 : 0); /* New borrow */ +*a=(uint16_t)(accum & 0xFFFF); return; } @@ -309,12 +309,12 @@ return; ** a carry bit, which is shifted in at the beginning, and ** shifted out at the end. */ -static void ShiftMantLeft1(u16 *carry, - u16 *mantissa) +static void ShiftMantLeft1(uint16_t *carry, + uint16_t *mantissa) { int i; /* Index */ int new_carry; -u16 accum; /* Temporary holding placed */ +uint16_t accum; /* Temporary holding placed */ for(i=INTERNAL_FPF_PRECISION-1;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;i<INTERNAL_FPF_PRECISION;i++) { accum=mantissa[i]; @@ -365,8 +365,8 @@ static void StickyShiftRightMant(InternalFPF *ptr, int amount) { int i; /* Index */ -u16 carry; /* Self-explanatory */ -u16 *mantissa; +uint16_t carry; /* Self-explanatory */ +uint16_t *mantissa; mantissa=ptr->mantissa; @@ -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. @@ -26,19 +26,7 @@ */ #include <stdio.h> - -/* -** 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 <stdint.h> #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); @@ -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 */ @@ -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;i<KEYLEN;i++) Z[i]=0; @@ -69,27 +69,27 @@ de_key_idea(Z,DK); ** So, plain1 and plain2 should match. ** Also, fill up plain1 with sample text. */ -plain1=(faruchar *)AllocateMemory(locideastruct->arraysize,&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;i<locideastruct->arraysize;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<nloops;i++) { - for(j=0;j<arraysize;j+=(sizeof(u16)*4)) - cipher_idea((u16 *)(plain1+j),(u16 *)(crypt1+j),Z); /* Encrypt */ + for(j=0;j<arraysize;j+=(sizeof(uint16_t)*4)) + cipher_idea((uint16_t *)(plain1+j),(uint16_t *)(crypt1+j),Z); /* Encrypt */ - for(j=0;j<arraysize;j+=(sizeof(u16)*4)) - cipher_idea((u16 *)(crypt1+j),(u16 *)(plain2+j),DK); /* Decrypt */ + for(j=0;j<arraysize;j+=(sizeof(uint16_t)*4)) + cipher_idea((uint16_t *)(crypt1+j),(uint16_t *)(plain2+j),DK); /* Decrypt */ } #ifdef DEBUG @@ -208,14 +208,14 @@ return(StopStopwatch(elapsed)); ** on the assumption that untaken branches are cheaper than taken ** branches, and that the compiler doesn't schedule branches. */ -static u16 mul(register u16 a, register u16 b) +static uint16_t mul(register uint16_t a, register uint16_t b) { -register u32 p; +register uint32_t p; if(a) { if(b) - { p=(u32)(a*b); + { p=(uint32_t)(a*b); b=low16(p); - a=(u16)(p>>16); + a=(uint16_t)(p>>16); return(b-a+(b<a)); } else @@ -233,10 +233,10 @@ else ** to avoid swapping the meaning of the registers. And ** some subtracts are changed to adds. */ -static u16 inv(u16 x) +static uint16_t inv(uint16_t x) { -u16 t0, t1; -u16 q, y; +uint16_t t0, t1; +uint16_t q, y; if(x<=1) return(x); /* 0 and 1 are self-inverse */ @@ -262,7 +262,7 @@ return(low16(1-t1)); ***************** ** Compute IDEA encryption subkeys Z */ -static void en_key_idea(u16 *userkey, u16 *Z) +static void en_key_idea(uint16_t *userkey, uint16_t *Z) { int i,j; @@ -290,9 +290,9 @@ static void de_key_idea(IDEAkey Z, IDEAkey DK) { IDEAkey TT; int j; -u16 t1, t2, t3; -u16 *p; -p=(u16 *)(TT+KEYLEN); +uint16_t t1, t2, t3; +uint16_t *p; +p=(uint16_t *)(TT+KEYLEN); t1=inv(*Z++); t2=-*Z++; @@ -349,13 +349,13 @@ return; ***************** ** IDEA encryption/decryption algorithm. */ -static void cipher_idea(u16 in[4], - u16 out[4], +static void cipher_idea(uint16_t in[4], + uint16_t out[4], register IDEAkey Z) { -register u16 x1, x2, x3, x4, t1, t2; -/* register u16 t16; -register u16 t32; */ +register uint16_t x1, x2, x3, x4, t1, t2; +/* register uint16_t t16; +register uint16_t t32; */ int r=ROUNDS; x1=*in++; @@ -28,14 +28,14 @@ void DoLU(void) LUStruct *loclustruct; /* Local pointer to global data */ char *errorcontext; int systemerror; -fardouble *a; -fardouble *b; -fardouble *abase; -fardouble *bbase; +double *a; +double *b; +double *abase; +double *bbase; LUdblptr ptra; int n; int i; -ulong accumtime; +unsigned long accumtime; double iterations; /* @@ -54,9 +54,9 @@ errorcontext="FPU:LU"; ** derived from. (I.E., we'll simply copy these arrays ** into the others. */ -a=(fardouble *)AllocateMemory(sizeof(double) * LUARRAYCOLS * LUARRAYROWS, +a=(double *)AllocateMemory(sizeof(double) * LUARRAYCOLS * LUARRAYROWS, &systemerror); -b=(fardouble *)AllocateMemory(sizeof(double) * LUARRAYROWS, +b=(double *)AllocateMemory(sizeof(double) * LUARRAYROWS, &systemerror); n=LUARRAYROWS; @@ -65,7 +65,7 @@ n=LUARRAYROWS; ** algorithm. This removes the allocation routine from the ** timing. */ -LUtempvv=(fardouble *)AllocateMemory(sizeof(double)*LUARRAYROWS, +LUtempvv=(double *)AllocateMemory(sizeof(double)*LUARRAYROWS, &systemerror); /* @@ -84,18 +84,18 @@ if(loclustruct->adjust==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;i<n;i++) { /* b[i]=(double)(abs_randwc(100L)+1L); */ - b[i]=(double)(abs_randwc((int32)100)+(int32)1); + b[i]=(double)(abs_randwc((int32_t)100)+(int32_t)1); for(j=0;j<n;j++) if(i==j) /* a[i][j]=(double)(abs_randwc(1000L)+1L); */ - a[i][j]=(double)(abs_randwc((int32)1000)+(int32)1); + a[i][j]=(double)(abs_randwc((int32_t)1000)+(int32_t)1); else a[i][j]=(double)0.0; } @@ -307,8 +307,8 @@ for(i=0;i<8*n;i++) */ /* k=abs_randwc((long)n); */ /* k1=abs_randwc((long)n); */ - k=abs_randwc((int32)n); - k1=abs_randwc((int32)n); + k=abs_randwc((int32_t)n); + k1=abs_randwc((int32_t)n); if(k!=k1) { if(k<k1) rcon=(double)1.0; @@ -49,9 +49,9 @@ long randwc(long num) /* ** Returns signed 32-bit random modulo num. */ -int32 randwc(int32 num) +int32_t randwc(int32_t num) { - return(randnum((int32)0)%num); + return(randnum((int32_t)0)%num); } /*************************** @@ -71,14 +71,14 @@ if(temp<0) temp=0L-temp; return((unsigned long)temp); } */ -u32 abs_randwc(u32 num) +uint32_t abs_randwc(uint32_t num) { -int32 temp; /* Temporary storage */ +int32_t temp; /* Temporary storage */ temp=randwc(num); -if(temp<0) temp=(int32)0-temp; +if(temp<0) temp=(int32_t)0-temp; -return((u32)temp); +return((uint32_t)temp); } /**************************** @@ -104,15 +104,15 @@ long randnum(long lngval) return(interm); } */ -int32 randnum(int32 lngval) +int32_t randnum(int32_t lngval) { - register int32 interm; - static int32 randw[2] = { (int32)13 , (int32)117 }; + register int32_t interm; + static int32_t randw[2] = { (int32_t)13 , (int32_t)117 }; - if (lngval!=(int32)0) - { randw[0]=(int32)13; randw[1]=(int32)117; } + if (lngval!=(int32_t)0) + { randw[0]=(int32_t)13; randw[1]=(int32_t)117; } - interm=(randw[0]*(int32)254754+randw[1]*(int32)529562)%(int32)999563; + interm=(randw[0]*(int32_t)254754+randw[1]*(int32_t)529562)%(int32_t)999563; randw[1]=randw[0]; randw[0]=interm; return(interm); @@ -34,8 +34,8 @@ long randnum(long lngval); */ #include "nmglobal.h" -int32 randwc(int32 num); -u32 abs_randwc(u32 num); -int32 randnum(int32 lngval); +int32_t randwc(int32_t num); +uint32_t abs_randwc(uint32_t num); +int32_t randnum(int32_t lngval); @@ -205,15 +205,15 @@ if(global_allstats) loctime=localtime(&time_and_date); sprintf(buffer,"**Date and time of benchmark run: %s",asctime(loctime)); output_string(buffer); - sprintf(buffer,"**Sizeof: char:%u short:%u int:%u long:%u u8:%u u16:%u u32:%u int32:%u\n", + sprintf(buffer,"**Sizeof: char:%u short:%u int:%u long:%u uint8_t:%u uint16_t:%u uint32_t:%u int32:%u\n", (unsigned int)sizeof(char), (unsigned int)sizeof(short), (unsigned int)sizeof(int), (unsigned int)sizeof(long), - (unsigned int)sizeof(u8), - (unsigned int)sizeof(u16), - (unsigned int)sizeof(u32), - (unsigned int)sizeof(int32)); + (unsigned int)sizeof(uint8_t), + (unsigned int)sizeof(uint16_t), + (unsigned int)sizeof(uint32_t), + (unsigned int)sizeof(int32_t)); output_string(buffer); #ifdef LINUX #include "sysinfo.c" @@ -50,7 +50,7 @@ void DoNNET(void) { NNetStruct *locnnetstruct; /* Local ptr to global data */ char *errorcontext; -ulong accumtime; +unsigned long accumtime; double iterations; /* @@ -72,7 +72,7 @@ errorcontext="CPU:NNET"; ** the initial neural net state. */ /* randnum(3L); */ -randnum((int32)3); +randnum((int32_t)3); /* ** Read in the input and output patterns. We'll do this @@ -97,7 +97,7 @@ if(locnnetstruct->adjust==0) locnnetstruct->loops<MAXNNETLOOPS; locnnetstruct->loops++) { /*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)<locnnetstruct->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<MID_SIZE; neurode++) for(i=0; i<IN_SIZE; i++) { /* value=(double)abs_randwc(100000L); */ - value=(double)abs_randwc((int32)100000); + value=(double)abs_randwc((int32_t)100000); value=value/(double)100000.0 - (double) 0.5; mid_wts[neurode][i] = value/2; } @@ -612,7 +612,7 @@ for (neurode=0; neurode<OUT_SIZE; neurode++) for(i=0; i<MID_SIZE; i++) { /* value=(double)abs_randwc(100000L); */ - value=(double)abs_randwc((int32)100000); + value=(double)abs_randwc((int32_t)100000); value=value/(double)10000.0 - (double) 0.5; out_wts[neurode][i] = value/2; } @@ -28,6 +28,7 @@ /* ** SYSTEM DEFINES */ +#include <stdint.h> /* +++ 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 <unix.h> -#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; @@ -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)); } } @@ -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); |