/* Copyright Per Bothner 1987. Read the file Q-INFO */
#if 0
#define NoValue atoms_NoValue
#define EOF_mark atoms_EOF_mark
#define Fail except_Fail
#define Compare_failed except_Compare_failed
#define Bad_arg_type except_Bad_arg_type
#define End_of_file except_End_of_file
#define Illegal_request except_Illegal_request
#define Undefined except_Undefined
#define V_Error except_V_Error
#define No_memory except_No_memory
#endif

extern struct ExceptionClass Fail[1], Compare_failed[1],
  Bad_arg_type[1], End_of_file[1],
  Illegal_request[1], Undefined[1], V_Error[1], No_memory[1];

#define ByteSize 8
#define ByteSizeLog 3
#define PointerAlignLog 4
#define PointerAlign (1<<PointerAlignLog)
#define DivByteSize(x) ((x)>>ByteSizeLog)
#define DoAlign(x, mult) ((x)+(mult)-1 & ~((mult)-1))

/* NOTES on address space restrictions:
 * All addresses must compare correctly (even if they can be "negative").
 * This includes EOFmagic.
 */

#define BAD_INDEX EOF_mark
#define RAISE_V_Error(error) RAISE(V_Error, FixToObject(error))
#define SetPType(ob,type) ((Object)(((long)(ob) & 0xFFFFFF) + ((type) << 24)))
/*#define IsFixNum(x) ((long)(x) <= 0x20000 && (long)(x) >= (long)0xFFF00000)*/
#define IsFixInt(x) HasHType(x, FixInt)
#define Apply1(f, x) Apply(x, f)
#define APPLY(x, f) (*GetType(x)->prefix)(x, f)
#define HasHType(ob,type) (MemGetType(ob) == (struct Type*)type##T)
#define FixToObject(i) ((Object)AllocFixInt(i))
#if 1
#if 0 /* was: ifndef CPLUS */
extern Object MakeFixInt(long);
#endif
#define LongToAny(i) MAKE_ANY(MakeFixInt(i), NULL)
#else
#define LongToAny(i) MAKE_ANY((void*)i, FixNumT)
#endif

#if 0
#define ObjectToFix(o) (*(long*)(o))
#define FixAddress(x) ((long)x & 0xFFFFFF)
#define MemGetType(x) (((struct Type**)(x))[-1])

#define IsMemObject(x) ((unsigned)(x) < 0x1000000)
#define IsDFloat(x) (MemGetType(x)==FloatT)
#define IsComplex(x) (MemGetType(x)==ComplexT)
#define IsBigNum(x) HasHType(x, TBigNumOb)
#define IsArray(x) HasHType(x, Array)
#define IsString(x) HasHType(x, TStringOb)
#define IsSymbol(x) (MemGetType(x)==SymbolT)
#define IsVariable(x) (MemGetType(x)==VariableT)
#define IsNull(x) ((x) == NULL || (x) == NoValue)

#define InsertProc(type,name,proc) Insert(type.hash,name,proc)
#endif

/* results from a compare operation */
#define CompErr (-2)
#define CompLss (-1)
#define CompEqu 0
#define CompGrt 1
#define CompGeq 2
#define CompNeq 3
#define CompLeq 4
#define CompOrEq(x) (3-(x))
