Move more things into compiler-specific headers

This commit has probably broken all compilers except GCC/Clang.
This commit is contained in:
Lassi Kortela 2019-08-27 01:14:59 +03:00
parent 9409096c0a
commit f72c3e9f02
3 changed files with 44 additions and 50 deletions

View File

@ -15,18 +15,6 @@
//
// We assume the LP64 convention for 64-bit platforms.
#undef BITS32
#undef BITS64
typedef uintptr_t value_t;
typedef uintptr_t ufixnum_t;
typedef intptr_t fixnum_t;
#ifdef BITS64
#define T_FIXNUM T_INT64
#else
#define T_FIXNUM T_INT32
#endif
#ifdef __DMC__
#include "scheme_compiler_dmc.h"
#endif
@ -43,19 +31,6 @@ typedef intptr_t fixnum_t;
#include "scheme_compiler_watcomc.h"
#endif
#ifdef __WATCOMC__
typedef float float_t;
typedef double double_t;
#define __ORDER_BIG_ENDIAN__ 4321
#define __ORDER_LITTLE_ENDIAN__ 1234
#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
#define BITS32
#endif
#ifndef __WATCOMC__
#define BITS64
#endif
#define LLT_ALLOC(n) malloc(n)
#define LLT_REALLOC(p, n) realloc((p), (n))
#define LLT_FREE(x) free(x)
@ -72,31 +47,6 @@ typedef int bool_t;
#define LLT_ALIGN(x, sz) (((x) + (sz - 1)) & (-sz))
// branch prediction annotations
#ifdef __GNUC__
#define __unlikely(x) __builtin_expect(!!(x), 0)
#define __likely(x) __builtin_expect(!!(x), 1)
#else
#define __unlikely(x) (x)
#define __likely(x) (x)
#endif
#define DBL_MAXINT 9007199254740992LL
#define FLT_MAXINT 16777216
#define U64_MAX 18446744073709551615ULL
#define S64_MAX 9223372036854775807LL
#define S64_MIN (-S64_MAX - 1LL)
#define BIT63 0x8000000000000000LL
#define BIT31 0x80000000
#define LOG2_10 3.3219280948873626
#define sign_bit(r) ((*(int64_t *)&(r)) & BIT63)
#define LABS(n) (((n) ^ ((n) >> (NBITS - 1))) - ((n) >> (NBITS - 1)))
#define NBABS(n, nb) (((n) ^ ((n) >> ((nb)-1))) - ((n) >> ((nb)-1)))
#define DFINITE(d) \
(((*(int64_t *)&(d)) & 0x7ff0000000000000LL) != 0x7ff0000000000000LL)
#define DNAN(d) ((d) != (d))
extern double D_PNAN;
extern double D_NNAN;
extern double D_PINF;

View File

@ -1,3 +1,13 @@
typedef uintptr_t value_t;
typedef uintptr_t ufixnum_t;
typedef intptr_t fixnum_t;
#ifdef BITS64
#define T_FIXNUM T_INT64
#else
#define T_FIXNUM T_INT32
#endif
void DivideByZeroError(void) __attribute__((__noreturn__));
void lerrorf(value_t e, const char *format, ...)
@ -12,3 +22,28 @@ __attribute__((__noreturn__));
void bounds_error(const char *fname, value_t arr, value_t ind)
__attribute__((__noreturn__));
// branch prediction annotations
#ifdef __GNUC__
#define __unlikely(x) __builtin_expect(!!(x), 0)
#define __likely(x) __builtin_expect(!!(x), 1)
#else
#define __unlikely(x) (x)
#define __likely(x) (x)
#endif
#define DBL_MAXINT 9007199254740992LL
#define FLT_MAXINT 16777216
#define U64_MAX 18446744073709551615ULL
#define S64_MAX 9223372036854775807LL
#define S64_MIN (-S64_MAX - 1LL)
#define BIT63 0x8000000000000000LL
#define BIT31 0x80000000
#define LOG2_10 3.3219280948873626
#define sign_bit(r) ((*(int64_t *)&(r)) & BIT63)
#define LABS(n) (((n) ^ ((n) >> (NBITS - 1))) - ((n) >> (NBITS - 1)))
#define NBABS(n, nb) (((n) ^ ((n) >> ((nb)-1))) - ((n) >> ((nb)-1)))
#define DFINITE(d) \
(((*(int64_t *)&(d)) & 0x7ff0000000000000LL) != 0x7ff0000000000000LL)
#define DNAN(d) ((d) != (d))

View File

@ -1,3 +1,12 @@
#ifdef __WATCOMC__
typedef float float_t;
typedef double double_t;
#define __ORDER_BIG_ENDIAN__ 4321
#define __ORDER_LITTLE_ENDIAN__ 1234
#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
#define BITS32
#endif
#pragma aux DivideByZeroError aborts;
extern void DivideByZeroError(void);