From 689ec946d8650d617f72359e2c997ce2dfa61d3f Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Fri, 17 Feb 2012 19:08:50 -0500 Subject: [PATCH] removing some unused stuff --- llt/Makefile | 2 +- llt/fp.c | 91 -------------------------------------------------- llt/notes | 44 ------------------------ llt/pshash.c | 58 -------------------------------- llt/unittest.c | 2 -- llt/utils.h | 4 --- 6 files changed, 1 insertion(+), 200 deletions(-) delete mode 100644 llt/fp.c delete mode 100644 llt/notes delete mode 100644 llt/pshash.c diff --git a/llt/Makefile b/llt/Makefile index 4ff895a..18a2164 100644 --- a/llt/Makefile +++ b/llt/Makefile @@ -2,7 +2,7 @@ CC = gcc SRCS = bitvector.c hashing.c socket.c timefuncs.c dblprint.c ptrhash.c \ utf8.c ios.c operators.c cplxprint.c dirpath.c htable.c \ - bitvector-ops.c fp.c int2str.c dump.c random.c bswap.c memalign.c \ + bitvector-ops.c int2str.c dump.c random.c bswap.c memalign.c \ swapreverse.c lltinit.c arraylist.c OBJS = $(SRCS:%.c=%.o) DOBJS = $(SRCS:%.c=%.do) diff --git a/llt/fp.c b/llt/fp.c deleted file mode 100644 index a48ecd7..0000000 --- a/llt/fp.c +++ /dev/null @@ -1,91 +0,0 @@ -#include -#include -#include -#include -#include "ieee754.h" -#include "dtypes.h" -#include "hashing.h" - -static uint64_t max_ulps; -static uint32_t flt_max_ulps; - -static uint64_t nexti64pow2(uint64_t i) -{ - if (i==0) return 1; - if ((i&(i-1))==0) return i; - if (i&BIT63) return BIT63; - // repeatedly clear bottom bit - while (i&(i-1)) - i = i&(i-1); - return i<<1; -} - -static uint32_t nexti32pow2(uint32_t i) -{ - if (i==0) return 1; - if ((i&(i-1))==0) return i; - if (i&BIT31) return BIT31; - // repeatedly clear bottom bit - while (i&(i-1)) - i = i&(i-1); - return i<<1; -} - -void dbl_tolerance(double tol) -{ - max_ulps = nexti64pow2((uint64_t)(tol/DBL_EPSILON)); -} - -void flt_tolerance(float tol) -{ - flt_max_ulps = nexti32pow2((uint32_t)(tol/FLT_EPSILON)); -} - -#ifdef __INTEL_COMPILER -static inline int64_t llabs(int64_t j) -{ - return NBABS(j, 64); -} -#else -#endif - -int dbl_equals(double a, double b) -{ - union { double d; int64_t i; } ua; - union { double d; int64_t i; } ub; - int64_t aint, bint; - - if (a == b) - return 1; - ua.d = a; aint = ua.i; - ub.d = b; bint = ub.i; - if (aint < 0) - aint = BIT63 - aint; - if (bint < 0) - bint = BIT63 - bint; - /* you'd think it makes no difference whether the result of llabs is - signed or unsigned, but if it's signed then the case of - 0x8000000000000000 blows up, making 4 == -1 :) */ - if ((uint64_t)llabs(aint-bint) <= max_ulps) - return 1; - return 0; -} - -int flt_equals(float a, float b) -{ - union { float f; int32_t i; } ua; - union { float f; int32_t i; } ub; - int32_t aint, bint; - - if (a == b) - return 1; - ua.f = a; aint = ua.i; - ub.f = b; bint = ub.i; - if (aint < 0) - aint = BIT31 - aint; - if (bint < 0) - bint = BIT31 - bint; - if ((uint32_t)abs(aint-bint) <= flt_max_ulps) - return 1; - return 0; -} diff --git a/llt/notes b/llt/notes deleted file mode 100644 index 73cb47e..0000000 --- a/llt/notes +++ /dev/null @@ -1,44 +0,0 @@ -my c library (jlibc) ------------- - -* bytevector utilities: memswap, memreverse, swap_el, etc. -* hashing, random#s: int32hash, int64hash, int64to32hash, lookup3, ptrhash -* utf8 -* bitvector -- iostream, socket, asynch io -- cross-platform pathnames, cwd, exename, date/time, etc. -* floating point number utils: comparison, print_real, print_cplx -- strtab (with prefix searching) - -(- pool allocator with hooks for gc (sweep function)) -(- list (dequeue)) -(- sort: msort list, qsort numbers) not too important since stdlib has qsort - -- use non-allocating APIs. this means the interface never allocates or - frees memory for you. you have to manage space for objects yourself. - -- separate math library. includes numal, cephes, my complex number routines, - more special functions - - -stream redesign: - -memstream, single-descriptor-backed, pipe (read/write on separate descriptors) - -do our own buffering, so we can implement getline without seek/skip - -all provided functions must be in terms of read,write,poll,flush only -seek/skip will be available, but only works on files and strings -change semantics of bit i/o so it doesn't require skip(-1) - -compare our implementation to somebody else's fread,fwrite,etc. - - -cool trick for faking string streams with stdio: - - char buf[256]; - v = list2(number(6), number(4)); - FILE *f = fopen("/dev/null", "a"); - setbuffer(f, buf, sizeof(buf)); - print(f, v, 0); - printf("got '%s'\n", buf); diff --git a/llt/pshash.c b/llt/pshash.c deleted file mode 100644 index 2dce927..0000000 --- a/llt/pshash.c +++ /dev/null @@ -1,58 +0,0 @@ -// by Paul Hsieh -//#include "pstdint.h" /* Replace with if appropriate */ -#include -#undef get16bits -#if (defined(__GNUC__) && defined(__i386__)) || defined(__WATCOMC__) \ - || defined(_MSC_VER) || defined (__BORLANDC__) || defined (__TURBOC__) -#define get16bits(d) (*((const uint16_t *) (d))) -#endif - -#if !defined (get16bits) -#define get16bits(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8)\ - +(uint32_t)(((const uint8_t *)(d))[0]) ) -#endif - -uint32_t SuperFastHash (const char * data, int len) { -uint32_t hash = len, tmp; -int rem; - - if (len <= 0 || data == NULL) return 0; - - rem = len & 3; - len >>= 2; - - /* Main loop */ - for (;len > 0; len--) { - hash += get16bits (data); - tmp = (get16bits (data+2) << 11) ^ hash; - hash = (hash << 16) ^ tmp; - data += 2*sizeof (uint16_t); - hash += hash >> 11; - } - - /* Handle end cases */ - switch (rem) { - case 3: hash += get16bits (data); - hash ^= hash << 16; - hash ^= data[sizeof (uint16_t)] << 18; - hash += hash >> 11; - break; - case 2: hash += get16bits (data); - hash ^= hash << 11; - hash += hash >> 17; - break; - case 1: hash += *data; - hash ^= hash << 10; - hash += hash >> 1; - } - - /* Force "avalanching" of final 127 bits */ - hash ^= hash << 3; - hash += hash >> 5; - hash ^= hash << 4; - hash += hash >> 17; - hash ^= hash << 25; - hash += hash >> 6; - - return hash; -} diff --git a/llt/unittest.c b/llt/unittest.c index 54d4836..a29bb12 100644 --- a/llt/unittest.c +++ b/llt/unittest.c @@ -68,8 +68,6 @@ void test_dblprint() { char str[64]; - dbl_tolerance(1e-12); - prettycplx(0,0); prettycplx(1,0); prettycplx(0,1); diff --git a/llt/utils.h b/llt/utils.h index bdece65..1fe71b2 100644 --- a/llt/utils.h +++ b/llt/utils.h @@ -21,10 +21,6 @@ void free_aligned(void *ptr); void *realloc_aligned(void *ptr, size_t size, size_t align_size); /* ------------------------------------------------------------- */ -int dbl_equals(double a, double b); -int flt_equals(float a, float b); -void dbl_tolerance(double tol); -void flt_tolerance(float tol); int double_exponent(double d); double double_mantissa(double d); int float_exponent(float f);