summaryrefslogtreecommitdiff
path: root/emfloat.c
diff options
context:
space:
mode:
authorMatt Turner <mattst88@gmail.com>2008-11-11 23:00:38 +0000
committerMatt Turner <mattst88@gmail.com>2008-11-11 23:00:38 +0000
commit5a7f0d2e7b4265153ccc70051bdae8b851617ede (patch)
treeb29e974f32a1ddba669359100bb6748c72cbfd1e /emfloat.c
parentbef5cb4c61e44ee8784f233eb2ec230c776dbda6 (diff)
Remove stupid datatypes. Begin code cleanup
git-svn-id: svn://mattst88.com/svn/cleanbench/trunk@5 0d43b9a7-5ab2-4d7b-af9d-f64450cef757
Diffstat (limited to 'emfloat.c')
-rw-r--r--emfloat.c140
1 files changed, 70 insertions, 70 deletions
diff --git a/emfloat.c b/emfloat.c
index 5e73890..0f9793b 100644
--- a/emfloat.c
+++ b/emfloat.c
@@ -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.