diff options
| author | Florian Fischer <florian.fl.fischer@fau.de> | 2020-02-27 12:55:18 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fl.fischer@fau.de> | 2020-02-27 12:55:18 +0100 |
| commit | 45984a6b6d9c32c00e00153b90e9208788981ab3 (patch) | |
| tree | 949d1c662b1d1648c8baf2c50ade85ff930566d9 | |
| parent | 9528aa1ea4a28d5439e205910c3574045564d402 (diff) | |
| download | allocbench-45984a6b6d9c32c00e00153b90e9208788981ab3.tar.gz allocbench-45984a6b6d9c32c00e00153b90e9208788981ab3.zip | |
remove unused code and compiler flags from t-test1
| -rw-r--r-- | src/benchmarks/t_test1/Makefile | 8 | ||||
| -rw-r--r-- | src/benchmarks/t_test1/lran2.h | 51 | ||||
| -rw-r--r-- | src/benchmarks/t_test1/t-test.h | 143 |
3 files changed, 3 insertions, 199 deletions
diff --git a/src/benchmarks/t_test1/Makefile b/src/benchmarks/t_test1/Makefile index 109e9a6..62a62ee 100644 --- a/src/benchmarks/t_test1/Makefile +++ b/src/benchmarks/t_test1/Makefile @@ -1,5 +1,5 @@ # Makefile for t-test1 from ptmalloc, version 2 -# by Florian Fischer 2019 +# by Florian Fischer 2019, 2020 # derived from # Makefile for ptmalloc, version 2 # by Wolfram Gloger 1996-1999, 2001, 2002, 2003, 2004, 2006 @@ -16,17 +16,15 @@ WARN_FLAGS ?= -Wall -Wstrict-prototypes T_FLAGS = -DTEST=1 # Thread flags. -# See the platform-specific targets below. -THR_FLAGS = -DUSE_TSD_DATA_HACK -D_REENTRANT THR_LIBS = -lpthread RM = rm -f -CFLAGS ?= $(SYS_FLAGS) $(OPT_FLAGS) $(WARN_FLAGS) $(THR_FLAGS) +CFLAGS ?= $(SYS_FLAGS) $(OPT_FLAGS) $(WARN_FLAGS) all: $(OBJDIR)/t-test1 -$(OBJDIR)/t-test1: t-test1.c t-test.h | $(OBJDIR) +$(OBJDIR)/t-test1: t-test1.c | $(OBJDIR) @echo compiling $@ $(CC) $(CFLAGS) $(T_FLAGS) t-test1.c $(THR_LIBS) -o $@ diff --git a/src/benchmarks/t_test1/lran2.h b/src/benchmarks/t_test1/lran2.h deleted file mode 100644 index cea9920..0000000 --- a/src/benchmarks/t_test1/lran2.h +++ /dev/null @@ -1,51 +0,0 @@ -/* lran2.h - * by Wolfram Gloger 1996. - * - * A small, portable pseudo-random number generator. - */ - -#ifndef _LRAN2_H -#define _LRAN2_H - -#define LRAN2_MAX 714025l /* constants for portable */ -#define IA 1366l /* random number generator */ -#define IC 150889l /* (see e.g. `Numerical Recipes') */ - -struct lran2_st { - long x, y, v[97]; -}; - -static void -lran2_init(struct lran2_st* d, long seed) -{ - long x; - int j; - - x = (IC - seed) % LRAN2_MAX; - if(x < 0) x = -x; - for(j=0; j<97; j++) { - x = (IA*x + IC) % LRAN2_MAX; - d->v[j] = x; - } - d->x = (IA*x + IC) % LRAN2_MAX; - d->y = d->x; -} - -#ifdef __GNUC__ -__inline__ -#endif -static long -lran2(struct lran2_st* d) -{ - int j = (d->y % 97); - - d->y = d->v[j]; - d->x = (IA*d->x + IC) % LRAN2_MAX; - d->v[j] = d->x; - return d->y; -} - -#undef IA -#undef IC - -#endif diff --git a/src/benchmarks/t_test1/t-test.h b/src/benchmarks/t_test1/t-test.h deleted file mode 100644 index a52829a..0000000 --- a/src/benchmarks/t_test1/t-test.h +++ /dev/null @@ -1,143 +0,0 @@ -/* - * $Id: t-test.h,v 1.1 2004/11/04 14:32:21 wg Exp $ - * by Wolfram Gloger 1996. - * Common data structures and functions for testing malloc performance. - */ - -/* Testing level */ -#ifndef TEST -#define TEST 0 -#endif - -/* For large allocation sizes, the time required by copying in - realloc() can dwarf all other execution times. Avoid this with a - size threshold. */ -#ifndef REALLOC_MAX -#define REALLOC_MAX 2000 -#endif - -struct bin { - unsigned char *ptr; - unsigned long size; -}; - -#if TEST > 0 - -static void -mem_init(unsigned char *ptr, unsigned long size) -{ - unsigned long i, j; - - if(size == 0) return; - for(i=0; i<size; i+=2047) { - j = (unsigned long)ptr ^ i; - ptr[i] = ((j ^ (j>>8)) & 0xFF); - } - j = (unsigned long)ptr ^ (size-1); - ptr[size-1] = ((j ^ (j>>8)) & 0xFF); -} - -static int -mem_check(unsigned char *ptr, unsigned long size) -{ - unsigned long i, j; - - if(size == 0) return 0; - for(i=0; i<size; i+=2047) { - j = (unsigned long)ptr ^ i; - if(ptr[i] != ((j ^ (j>>8)) & 0xFF)) return 1; - } - j = (unsigned long)ptr ^ (size-1); - if(ptr[size-1] != ((j ^ (j>>8)) & 0xFF)) return 2; - return 0; -} - -static int -zero_check(unsigned* ptr, unsigned long size) -{ - unsigned char* ptr2; - - while(size >= sizeof(*ptr)) { - if(*ptr++ != 0) - return -1; - size -= sizeof(*ptr); - } - ptr2 = (unsigned char*)ptr; - while(size > 0) { - if(*ptr2++ != 0) - return -1; - --size; - } - return 0; -} - -#endif /* TEST > 0 */ - -/* Allocate a bin with malloc(), realloc() or memalign(). r must be a - random number >= 1024. */ - -static void -bin_alloc(struct bin *m, unsigned long size, int r) -{ -#if TEST > 0 - if(mem_check(m->ptr, m->size)) { - printf("memory corrupt!\n"); - exit(1); - } -#endif - r %= 1024; - /*printf("%d ", r);*/ - if(r < 4) { /* memalign */ - if(m->size > 0) free(m->ptr); - m->ptr = (unsigned char *)memalign(sizeof(int) << r, size); - } else if(r < 20) { /* calloc */ - if(m->size > 0) free(m->ptr); - m->ptr = (unsigned char *)calloc(size, 1); -#if TEST > 0 - if(zero_check((unsigned*)m->ptr, size)) { - long i; - for(i=0; i<size; i++) - if(m->ptr[i] != 0) - break; - printf("calloc'ed memory non-zero (ptr=%p, i=%ld)!\n", m->ptr, i); - exit(1); - } -#endif - } else if(r < 100 && m->size < REALLOC_MAX) { /* realloc */ - if(m->size == 0) m->ptr = NULL; - m->ptr = realloc(m->ptr, size); - } else { /* plain malloc */ - if(m->size > 0) free(m->ptr); - m->ptr = (unsigned char *)malloc(size); - } - if(!m->ptr) { - printf("out of memory (r=%d, size=%ld)!\n", r, (long)size); - exit(1); - } - m->size = size; -#if TEST > 0 - mem_init(m->ptr, m->size); -#endif -} - -/* Free a bin. */ - -static void -bin_free(struct bin *m) -{ - if(m->size == 0) return; -#if TEST > 0 - if(mem_check(m->ptr, m->size)) { - printf("memory corrupt!\n"); - exit(1); - } -#endif - free(m->ptr); - m->size = 0; -} - -/* - * Local variables: - * tab-width: 4 - * End: - */ |
