some LLT fixes

improve portability of byte order test
This commit is contained in:
JeffBezanson 2010-05-14 21:01:00 +00:00
parent 46009027c2
commit 8ea6157c15
6 changed files with 39 additions and 33 deletions

View File

@ -9,7 +9,10 @@ LIBTARGET = lib$(NAME)
LLTDIR = ../llt
LLT = $(LLTDIR)/libllt.a
FLAGS = -falign-functions -Wall -Wno-strict-aliasing -I$(LLTDIR) $(CFLAGS) -DUSE_COMPUTED_GOTO
# OS flags: LINUX, WIN32, MACOSX
# architecture flags: __CPU__=xxx, BITS64, ARCH_X86, ARCH_X86_64
CONFIG = -DLINUX -DARCH_X86 -D__CPU__=586
FLAGS = -falign-functions -Wall -Wno-strict-aliasing -I$(LLTDIR) $(CFLAGS) -DUSE_COMPUTED_GOTO $(CONFIG)
LIBFILES = $(LLT)
LIBS = $(LIBFILES) -lm

View File

@ -888,7 +888,7 @@ static uint32_t process_keys(value_t kwtable,
return nargs;
}
#if _BYTE_ORDER == __BIG_ENDIAN
#if BYTE_ORDER == BIG_ENDIAN
#define GET_INT32(a) \
((int32_t) \
((((int32_t)a[0])<<0) | \
@ -2029,7 +2029,7 @@ static value_t fl_function(value_t *args, uint32_t nargs)
data[i] -= 48;
}
else {
#if _BYTE_ORDER == __BIG_ENDIAN
#if BYTE_ORDER == BIG_ENDIAN
swap = 1;
#endif
}

View File

@ -44,7 +44,7 @@ u_int32_t *bitvector_resize(u_int32_t *b, u_int64_t n, int initzero)
{
u_int32_t *p;
size_t sz = ((n+31)>>5) * 4;
p = realloc(b, sz);
p = LLT_REALLOC(b, sz);
if (p == NULL) return NULL;
if (initzero) memset(p, 0, sz);
return p;

View File

@ -16,6 +16,35 @@
We assume the LP64 convention for 64-bit platforms.
*/
#ifdef LINUX
#include <features.h>
#include <endian.h>
#define LITTLE_ENDIAN __LITTLE_ENDIAN
#define BIG_ENDIAN __BIG_ENDIAN
#define PDP_ENDIAN __PDP_ENDIAN
#define BYTE_ORDER __BYTE_ORDER
#endif
#ifdef MACOSX
#include <machine/endian.h>
#define __LITTLE_ENDIAN LITTLE_ENDIAN
#define __BIG_ENDIAN BIG_ENDIAN
#define __PDP_ENDIAN PDP_ENDIAN
#define __BYTE_ORDER BYTE_ORDER
#endif
#ifdef WIN32
#define __LITTLE_ENDIAN 1234
#define __BIG_ENDIAN 4321
#define __PDP_ENDIAN 3412
#define __BYTE_ORDER __LITTLE_ENDIAN
#define __FLOAT_WORD_ORDER __LITTLE_ENDIAN
#define LITTLE_ENDIAN __LITTLE_ENDIAN
#define BIG_ENDIAN __BIG_ENDIAN
#define PDP_ENDIAN __PDP_ENDIAN
#define BYTE_ORDER __BYTE_ORDER
#endif
#ifdef BOEHM_GC
// boehm GC allocator
#include <gc.h>

View File

@ -20,28 +20,6 @@
#define _IEEE754_H 1
#ifdef LINUX
#include <features.h>
#include <endian.h>
__BEGIN_DECLS
#else
#define __LITTLE_ENDIAN 1234
#define __BIG_ENDIAN 4321
#define __PDP_ENDIAN 3412
#if defined(WIN32) || defined(ARCH_X86) || defined(ARCH_X86_64)
#define __BYTE_ORDER __LITTLE_ENDIAN
#define __FLOAT_WORD_ORDER __LITTLE_ENDIAN
#else
#define __BYTE_ORDER __BIG_ENDIAN
#define __FLOAT_WORD_ORDER __BIG_ENDIAN
#endif
#endif //ifdef LINUX
union ieee754_float
{
float f;
@ -211,8 +189,4 @@ union ieee854_long_double
#define IEEE854_LONG_DOUBLE_BIAS 0x3fff
#ifdef LINUX
__END_DECLS
#endif
#endif /* ieee754.h */

View File

@ -24,7 +24,7 @@ void *malloc_aligned(size_t size, size_t align_size)
{
char *ptr;
ptr = (char*)malloc(size + align_size-1 + sizeof(long));
ptr = (char*)LLT_ALLOC(size + align_size-1 + sizeof(long));
if (ptr == NULL)
return NULL;
@ -33,7 +33,7 @@ void *malloc_aligned(size_t size, size_t align_size)
void free_aligned(void *ptr)
{
free(ALIGNED_TO_ACTUAL(ptr));
LLT_FREE(ALIGNED_TO_ACTUAL(ptr));
}
void *realloc_aligned(void *ptr, size_t size, size_t align_size)
@ -42,7 +42,7 @@ void *realloc_aligned(void *ptr, size_t size, size_t align_size)
if (ptr != NULL)
ptr = ALIGNED_TO_ACTUAL(ptr);
pnew = realloc(ptr, size + align_size-1 + sizeof(long));
pnew = LLT_REALLOC(ptr, size + align_size-1 + sizeof(long));
if (pnew == NULL)
return NULL;