summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Turner <mattst88@gmail.com>2008-11-16 03:13:38 +0000
committerMatt Turner <mattst88@gmail.com>2008-11-16 03:13:38 +0000
commit1df846b3f94aa7ca9a6622577c367c864131bd04 (patch)
tree4ada2450229a22d5d3d0a2a67d780ffcc7bd0e27
parent761470f9b51f2df8d25baf6060a7acfd333ba698 (diff)
Fix ansi/pedantic warnings
git-svn-id: svn://mattst88.com/svn/cleanbench/trunk@65 0d43b9a7-5ab2-4d7b-af9d-f64450cef757
-rw-r--r--Makefile8
-rw-r--r--cleanbench.c2
-rw-r--r--emfloat.c4
-rw-r--r--fourier.c5
-rw-r--r--hardware.c2
-rw-r--r--huffman.c2
-rw-r--r--numsort.c8
-rw-r--r--randnum.c15
-rw-r--r--randnum.h8
-rw-r--r--stringsort.c10
10 files changed, 31 insertions, 33 deletions
diff --git a/Makefile b/Makefile
index 0d388d7..d77d86d 100644
--- a/Makefile
+++ b/Makefile
@@ -1,13 +1,13 @@
CC=gcc
-CFLAGS=-O3 -march=k8 -msse3 -ftree-vectorize -funroll-loops -pipe -static -Wunused
+CFLAGS=-O3 -march=k8 -msse3 -ftree-vectorize -funroll-loops -pipe -static -Wunused -Wextra -Wall -pedantic
#CC=icc
#CFLAGS=-O3 -ipo -xP -gcc -static
-LINKFLAGS=
+LIBS=-lm
OBJS=emfloat.o randnum.o hardware.o cleanbench.o numsort.o stringsort.o bitfield.o fpemulation.o fourier.o assignment.o idea.o huffman.o neural.o linear.o
-all: ${OBJS}
- $(CC) ${OBJS} -o cleanbench -lm
+all: $(OBJS)
+ $(CC) $(OBJS) -o cleanbench $(LIBS)
clean:
/bin/rm -f *.o cleanbench sysinfo.c
diff --git a/cleanbench.c b/cleanbench.c
index 3d14e54..2cbd357 100644
--- a/cleanbench.c
+++ b/cleanbench.c
@@ -42,7 +42,7 @@ enum {
} tests_t;
int
-main(int argc, char *argv[])
+main()
{
const char* benchmark_name[] = {
"NUMERIC SORT ",
diff --git a/emfloat.c b/emfloat.c
index 39e9c40..4a68fe2 100644
--- a/emfloat.c
+++ b/emfloat.c
@@ -344,7 +344,6 @@ if (exponent_difference < 0)
StickyShiftRightMant(ptr, exponent_difference);
}
}
-return;
}
@@ -355,7 +354,8 @@ return;
** The kind of rounding we do here is simplest...referred to as
** "chop". "Extraneous" rightmost bits are simply hacked off.
*/
-void static RoundInternalFPF(InternalFPF *ptr)
+static void
+RoundInternalFPF(InternalFPF *ptr)
{
/* int i; */
diff --git a/fourier.c b/fourier.c
index e52bce8..af81436 100644
--- a/fourier.c
+++ b/fourier.c
@@ -15,6 +15,11 @@
** FOURIER COEFFICIENTS **
*************************/
+/* M_PI isn't defined if compiled with -ansi */
+#ifndef M_PI
+#define M_PI 3.14159265358979323846 /* pi */
+#endif
+
static clock_t DoFPUTransIteration(double *abase,
double *bbase,
unsigned long arraysize);
diff --git a/hardware.c b/hardware.c
index 4faafbd..06b0096 100644
--- a/hardware.c
+++ b/hardware.c
@@ -147,10 +147,10 @@ static void readProcCpuInfo (char *model, char *cache) {
*/
void hardware(void) {
+ const char os_command[] = "uname -s -r";
char os[BUF_SIZ];
char model[BUF_SIZ];
char cache[BUF_SIZ];
- char os_command[] = "uname -s -r";
#ifdef NO_UNAME
os[0] = '\0';
#else
diff --git a/huffman.c b/huffman.c
index cccb07b..57daa05 100644
--- a/huffman.c
+++ b/huffman.c
@@ -318,7 +318,7 @@ for(i=0;i<256;i++)
** was arbitrarily assigned led to an underflow error at runtime. We
** use that zeroed-out bits are in fact 0 as a float.
** Uwe F. Mayer */
-bzero((char *)&(hufftree[256]),sizeof(huff_node)*256); /* FIXME: replace bzero with memset? */
+memset(&(hufftree[256]), 0, sizeof(huff_node) * 256);
/*
** Build the huffman tree. First clear all the parent
** pointers and left/right pointers. Also, discard all
diff --git a/numsort.c b/numsort.c
index 8f94c00..36dbff6 100644
--- a/numsort.c
+++ b/numsort.c
@@ -26,8 +26,8 @@
static clock_t DoNumSortIteration(long *array, unsigned int num_arrays);
static void LoadNumArrayWithRand(long *array, unsigned int num_arrays);
-static inline void NumHeapSort(long *array, unsigned long bottom, unsigned long top);
-static inline void NumSift(long *array, unsigned long min, unsigned long max);
+static void NumHeapSort(long *array, unsigned long bottom, unsigned long top);
+static void NumSift(long *array, unsigned long min, unsigned long max);
/**************
** DoNumSort **
@@ -162,7 +162,7 @@ LoadNumArrayWithRand(long *array, unsigned int num_arrays)
** integers. Also pass in minimum and maximum offsets.
** This routine performs a heap sort on that array.
*/
-static inline void
+static void
NumHeapSort(long *array, unsigned long bottom, unsigned long top)
{
unsigned long temp; /* Used to exchange elements */
@@ -195,7 +195,7 @@ NumHeapSort(long *array, unsigned long bottom, unsigned long top)
** Peforms the sift operation on a numeric array,
** constructing a heap in the array.
*/
-static inline void
+static void
NumSift(long *array, unsigned long min, unsigned long max)
{
unsigned long k;
diff --git a/randnum.c b/randnum.c
index 7d2620f..8b5c218 100644
--- a/randnum.c
+++ b/randnum.c
@@ -1,5 +1,4 @@
-#include <stdint.h>
-#include <math.h>
+#include <stdlib.h>
/****************************
** RANDOM NUMBER GENERATOR **
@@ -19,16 +18,16 @@
** val!=0, restart generator.
*/
-int32_t randnum(int32_t val) {
- static int32_t randw[2] = { 13 , 117 };
- int32_t interm;
+int randnum(int val) {
+ static int randw[2] = { 13 , 117 };
+ int interm;
if (val != 0) {
randw[0] = 13;
randw[1] = 117;
}
- interm = (randw[0]* (int32_t)254754 + randw[1]*(int32_t)529562) % (int32_t)999563;
+ interm = (randw[0] * (int)254754 + randw[1] * (int)529562) % (int)999563;
randw[1] = randw[0];
randw[0] = interm;
return(interm);
@@ -39,7 +38,7 @@ int32_t randnum(int32_t val) {
*****************************
** Returns signed 32-bit random modulo num.
*/
-int32_t randwc(int32_t num) {
+int randwc(int num) {
return(randnum(0) % num);
}
@@ -49,7 +48,7 @@ int32_t randwc(int32_t num) {
** Same as randwc(), only this routine returns only
** positive numbers.
*/
-uint32_t abs_randwc(uint32_t num) {
+int abs_randwc(int num) {
return abs(randwc(num));
}
diff --git a/randnum.h b/randnum.h
index cf6b42b..629a5b4 100644
--- a/randnum.h
+++ b/randnum.h
@@ -1,5 +1,3 @@
-#include <stdint.h>
-
-int32_t randwc(int32_t num);
-uint32_t abs_randwc(uint32_t num);
-int32_t randnum(int32_t lngval);
+int randwc(int num);
+int abs_randwc(int num);
+int randnum(int val);
diff --git a/stringsort.c b/stringsort.c
index 28fa155..5f47528 100644
--- a/stringsort.c
+++ b/stringsort.c
@@ -35,11 +35,9 @@ static void stradjust(unsigned long *optrarray,
static void StrHeapSort(unsigned long *optrarray,
unsigned char *strarray,
unsigned long numstrings,
- unsigned long bottom,
unsigned long top);
static int str_is_less(unsigned long *optrarray,
unsigned char *strarray,
- unsigned long numstrings,
unsigned long a,
unsigned long b);
static void strsift(unsigned long *optrarray,
@@ -145,7 +143,7 @@ DoStringSortIteration(unsigned char *array, unsigned int num_arrays)
start = clock();
for(i = 0; i < num_arrays; i++) {
- StrHeapSort(tempobase, tempsbase, nstrings, 0L, nstrings - 1);
+ StrHeapSort(tempobase, tempsbase, nstrings, nstrings - 1);
tempobase += nstrings; /* Advance base pointers */
tempsbase += ARRAY_SIZE + 100;
}
@@ -375,7 +373,6 @@ return;
static void StrHeapSort(unsigned long *optrarray, /* Offset pointers */
unsigned char *strarray, /* Strings array */
unsigned long numstrings, /* # of strings in array */
- unsigned long bottom, /* Region to sort...bottom */
unsigned long top) /* Region to sort...top */
{
unsigned char temp[80]; /* Used to exchange elements */
@@ -426,7 +423,6 @@ for(i=top; i>0; --i)
*/
static int str_is_less(unsigned long *optrarray, /* Offset pointers */
unsigned char *strarray, /* String array */
- unsigned long numstrings, /* # of strings */
unsigned long a, unsigned long b) /* Offsets */
{
int slen; /* String length */
@@ -485,9 +481,9 @@ while((i+i)<=j)
{
k=i+i;
if(k<j)
- if(str_is_less(optrarray,strarray,numstrings,k,k+1L))
+ if(str_is_less(optrarray,strarray,k,k+1L))
++k;
- if(str_is_less(optrarray,strarray,numstrings,i,k))
+ if(str_is_less(optrarray,strarray,i,k))
{
/* temp=string[k] */
tlen=*(strarray+*(optrarray+k));