removing some unused stuff

This commit is contained in:
Jeff Bezanson 2012-02-17 19:08:50 -05:00
parent bcd381bf90
commit 689ec946d8
6 changed files with 1 additions and 200 deletions

View File

@ -2,7 +2,7 @@ CC = gcc
SRCS = bitvector.c hashing.c socket.c timefuncs.c dblprint.c ptrhash.c \ 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 \ 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 swapreverse.c lltinit.c arraylist.c
OBJS = $(SRCS:%.c=%.o) OBJS = $(SRCS:%.c=%.o)
DOBJS = $(SRCS:%.c=%.do) DOBJS = $(SRCS:%.c=%.do)

View File

@ -1,91 +0,0 @@
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#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;
}

View File

@ -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);

View File

@ -1,58 +0,0 @@
// by Paul Hsieh
//#include "pstdint.h" /* Replace with <stdint.h> if appropriate */
#include <stdint.h>
#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;
}

View File

@ -68,8 +68,6 @@ void test_dblprint()
{ {
char str[64]; char str[64];
dbl_tolerance(1e-12);
prettycplx(0,0); prettycplx(0,0);
prettycplx(1,0); prettycplx(1,0);
prettycplx(0,1); prettycplx(0,1);

View File

@ -21,10 +21,6 @@ void free_aligned(void *ptr);
void *realloc_aligned(void *ptr, size_t size, size_t align_size); 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); int double_exponent(double d);
double double_mantissa(double d); double double_mantissa(double d);
int float_exponent(float f); int float_exponent(float f);