/* Copyright (C) 1989, Digital Equipment Corporation */ /* All rights reserved. */ /* See the file COPYRIGHT for a full description. */ /* File: M3RuntimeDecls.h */ /* Last Modified On Fri Jul 20 11:02:59 1990 by muller */ /* Modified On Wed Jan 17 09:45:46 1990 by kalsow */ /***************************************************************************/ /* Do not put any C code before the include of M3Machine.h. Some machines */ /* require special C code at the very beginning of the file and */ /* it is convenient to put this code in M3Machine.h (which is machine */ /* specific) */ /***************************************************************************/ #define IMPORT extern #define EXPORT #define PRIVATE static /*** machine dependent part ***/ #include "M3Machine.h" /*** ***/ #include /*** predefined types ***/ #define NIL ((char*)0) #define NULLTEXT NIL #define VOID void /* cc doesn't like this as a typedef */ typedef char *ADDRESS; typedef int INTEGER; typedef void (*PROC)(); typedef struct { PROC proc; ADDRESS arg; } CLOSURE; typedef struct IREC { struct IREC* link; int doFirst; PROC initProc; } INITLINK; typedef enum {EXCEPT_HC, FINALLY_HC, RAISES_HC} HANDLER_CLASS; typedef char* EXCEPTION_NAME; #define raises_1 ((EXCEPTION_NAME **) NULL) typedef struct exception { EXCEPTION_NAME *e; ADDRESS a; } EXCEPTION; typedef struct handler { HANDLER_CLASS class; EXCEPTION_NAME** handles; EXCEPTION* exception; jmp_buf pc; struct handler* next; } HANDLER; extern HANDLER *_ThreadSup__handlers; #define PUSH_TRY(handler, excepts, label) {\ handler.class = EXCEPT_HC;\ handler.handles = excepts;\ handler.next = _ThreadSup__handlers;\ handler.exception = 0; \ _ThreadSup__handlers = &handler;\ if (_setjmp (handler.pc)) goto label; } #define PUSH_RAISES(handler, raises, label) {\ handler.class = RAISES_HC;\ handler.handles = raises;\ handler.next = _ThreadSup__handlers;\ handler.exception = 0; \ _ThreadSup__handlers = &handler; } #define PUSH_FINALLY(handler, label) {\ handler.class = FINALLY_HC; \ handler.next = _ThreadSup__handlers;\ handler.exception = FALL_EXCEPTION; \ _ThreadSup__handlers = &handler;\ if (_setjmp(handler.pc)) goto label; } #define CUT_TO_NEXT_HANDLER(handler) {\ _ThreadSup__handlers = handler.next; } #define RAISE_FOR_SURE(e) {\ HANDLER* hh = _ThreadSup__handlers;\ while (hh->class == RAISES_HC) { hh = hh-> next; }\ _ThreadSup__handlers = hh;\ hh->exception = e; \ _longjmp (hh->pc, 1); } #define ALLOC_EXCEPTION(ex,n,arg,size) {\ ex = (EXCEPTION*) malloc (sizeof (EXCEPTION));\ ex->e = n;\ ex->a = (ADDRESS) malloc (size);\ bcopy (arg, ex->a, size); } typedef struct tc { struct tc* next; struct tc* identified_with; int opaque; struct tc* parent; int typecode; PROC mapProc; int datasize; int methodsize; char* defaultMethods; int dimensions; int elemSize; PROC initProc; PROC setupProc; PROC printProc; char* brand; int fprint0, fprint1; } typecell; /* datasize = -1 means that this object is of variable size; the first word of the object is the actual size in bytes, header not included. */ #define VARIABLE_SIZE -1 #define OPEN_ARRAY -2 #define NO_BRAND ((char*)-1) typedef typecell* TYPE; typedef int refHeader; #define TYPECODE_OF(x) ((*((refHeader *) (x))) >> 1) #define SET_TYPECODE(x,y) (*((refHeader *) (x))) = (y << 1) | 1; #define FORWARDING(x) (((*((refHeader *) (x))) & 1) == 0) #define REFANY ((TYPE)0) #define TYPECODE(ref) (((ref)==0) ? 0 : TYPECODE_OF (((refHeader*) ref) - 1)) #define CHKL(e,lo,tmp) (tmp=e, (tmp < lo) ? RANGEFAULT : tmp) #define CHKH(e,hi,tmp) (tmp=e, (hi < tmp) ? RANGEFAULT : tmp) #define CHKR(e,lo,hi,tmp) (tmp=e, ((tmptypecode) || (tc==0) || _M3Runtime__IsSubType(tc,t)) #define ISTYPE(e,t)\ ((e==NIL) || (TYPECODE(e)==t->typecode)) #define NARROW(e,t,tc,tmp)\ (tmp=(char*)e, (ISSUBTYPE(TYPECODE(tmp),tc)?(t)tmp:(NARROWFAULT,(t)0))) #define RAISENOARG(x) _M3Runtime__Raise (x, 0, 0) #define RAISEWARG(x,y,z) _M3Runtime__Raise (x, y, z) #define RAISE(x,y,z) _M3Runtime__Raise (x, y, z) #define ASSERTFAULT _M3Runtime__AssertFault () #define RETURNFAULT _M3Runtime__ReturnFault () #define CASEFAULT _M3Runtime__CaseFault () #define TYPECASEFAULT _M3Runtime__TypecaseFault () #define RANGEFAULT _M3Runtime__RangeFault () #define HANDLERFAULT(e) _M3Runtime__HandlerFault (e) #define NARROWFAULT _M3Runtime__NarrowFault () #define NILFAULT _M3Runtime__NilFault () #define RAISESFAULT(e) _M3Runtime__RaisesFault (e) #define INITIALIZE(chain) _M3Runtime__InitModule (chain) #define CVTIF(x) ((float) x) #define CVTIL(x) ((double) x) #define CVTLF(x) ((float) x) #define CVTFL(x) ((double) x) #define CEILING(r) _M3Runtime__Ceiling (r) #define FLOOR(r) _M3Runtime__Floor (r) #define ROUND(r) _M3Runtime__Round (r) #define TRUNC(r) ((int) r) #define IDIV(n,m) _M3Runtime__Idiv (n,m) #define TNEW(t) _M3Runtime__NewTracedRecord (t) #define UNEW(t) _M3Runtime__NewUntracedRecord (t) #define TNEWOBJ(t) _M3Runtime__NewTracedObj (t) #define UNEWOBJ(t) _M3Runtime__NewUntracedObject (t) #define TNEWA(t,s) _M3Runtime__NewTracedArray (t, s) #define UNEWA(t,s) _M3Runtime__NewUntracedArray (t,s) #define UALLOC(n) _M3Runtime__NewUntraced (n) #define CLONE_METHOD_SUITE(o,t) _M3Runtime__CloneMethodSuite (o,t) #define TVDISPOSE(ref) _M3Runtime__DisposeTracedVar (ref) #define TDISPOSE(ref) _M3Runtime__DisposeTracedValue (ref) #define UVDISPOSE(ref) _M3Runtime__DisposeUntracedVar (ref) #define UDISPOSE(ref) _M3Runtime__DisposeUntracedValue (ref) #define REGISTERTYPE(t) _M3Runtime__RegisterType (t, 0) #define REGISTEROPAQUE(t) _M3Runtime__RegisterType (t, 1) #define IDENTIFYTYPES(t,u) _M3Runtime__IdentifyTypes (t,u) #define CHECKSUBTYPE(t,u) _M3Runtime__CheckSubType (t, u) #define ZERO1B(addr) *(char*) (addr) = 0 #define ZERO1S(addr) *(short*) (addr) = 0 #define ZERO1(addr) *(int*) (addr) = 0 #define ZERO2(a) {int *i =(int*)(a); i[0]=0; i[1]=0; } #define ZERO3(a) {int *i =(int*)(a); i[0]=0; i[1]=0; i[2]=0;} #define ZERO4(a) {int *i =(int*)(a); i[0]=0; i[1]=0; i[2]=0; i[3]=0;} #define ZERO5(a) {int *i =(int*)(a); i[0]=0; i[1]=0; i[2]=0; i[3]=0; \ i[4]=0; } #define ZERO6(a) {int *i =(int*)(a); i[0]=0; i[1]=0; i[2]=0; i[3]=0; \ i[4]=0; i[5] =0; } #define ZERO7(a) {int *i =(int*)(a); i[0]=0; i[1]=0; i[2]=0; i[3]=0; \ i[4]=0; i[5]=0; i[6]=0; } #define ZERO8(a) {int *i =(int*)(a); i[0]=0; i[1]=0; i[2]=0; i[3]=0; \ i[4]=0; i[5]=0; i[6]=0; i[7]=0;} #define ZERO(len,addr) bzero (addr, len) #define COPY(src,dest,len) bcopy (src, dest, len) #define CLOSURE_PROC(p) (((CLOSURE*)p)->proc) #define CLOSURE_FRAME(p) (((CLOSURE*)p)->arg)