1 /* $Id: snotypes.h,v 1.32 2020-11-19 02:31:31 phil Exp $ */ 2 3 /* NOTE! int_t and real_t should be the same size!!! */ 4 5 #ifndef INT_T 6 #define INT_T long 7 #endif /* INT_T not defined */ 8 9 typedef INT_T int_t; /* used to hold integers, addrs */ 10 11 #ifndef REAL_T 12 #define REAL_T float 13 #endif /* REAL_T not defined */ 14 15 typedef REAL_T real_t; 16 17 union addr { 18 int_t i; 19 real_t f; 20 void *ptr; /* not (yet) used (except by gdb) */ 21 }; 22 23 /* FFLD/VFLD ensure consistant sizing between descr and spec; */ 24 25 /* flags */ 26 #define FNC 01 27 #define TTL 02 28 #define STTL 04 29 #define MARK 010 30 #define PTR 020 31 #define FRZN 040 /* [PLB34] table frozen */ 32 /* only one bit left! */ 33 34 #ifdef NO_BITFIELDS 35 #ifndef VFLD_T 36 #define VFLD_T unsigned int /* at least 32 bits */ 37 #endif /* VFLD_T not defined */ 38 #ifndef FFLD_T 39 #define FFLD_T char 40 #endif /* FFLD_T not defined */ 41 #ifndef SIZLIM 42 /* 43 * NOTE!! SIZLIM must not appear negative when stored in an int_t. 44 * When int_t is 64-bits, the configure script redefines SIZLIM. 45 */ 46 #define SIZLIM 0x7fffffff /* maximum object size (31 bits) */ 47 #endif /* SIZLIM not defined */ 48 49 #define VFLD(name) VFLD_T name 50 #define FFLD(name) FFLD_T name 51 52 #else /* NO_BITFIELDS not defined */ 53 #define VFLD(name) unsigned name : 24 54 #ifdef BITFIELDS_SAME_TYPE 55 /* MicroSoft C won't pack fields unless they're of the same base type!! */ 56 /* gcc 3.3.1 (SuSE Linux) produces broken executable with this!! */ 57 #define FFLD(name) unsigned name : 8 58 #else /* BITFIELDS_SAME_TYPE not defined */ 59 #define FFLD(name) char name 60 #endif /* BITFIELDS_SAME_TYPE not defined */ 61 #define SIZLIM 0xffffff 62 #endif /* NO_BITFIELDS not defined */ 63 64 /* 65 * maximum object sizes for selected v-field and a-field sizes; 66 * 67 * field sizes 68 * v a DESCR SIZLIM MAXOBJ 69 * 16b 32b 8B 64KB 8KD 70 * 24b 32b 8B 16MB 2MD (default) 71 * 32b 32b 12B** 2GB* 171MD 72 * 32b 64b 16B 4GB 256MD (--lp64, --longlong) 73 * 74 * (*) SIZLIM must not appear negative when stored in an int_t 75 * (**) Alignment allowing 76 * 77 * SIZLIM max object size in bytes determines maximum string length 78 * 79 * MAXOBJ (SIZLIM/DESCR) max object size in DESCRs 80 * determines maximum size for; 81 * arrays (one descr per entry) 82 * initial table size (two descrs / entry) 83 * number of identifiers (two descrs / id) 84 * number of functions (two descrs / function) 85 * pattern size (four descrs / node) 86 */ 87 88 /* addressing unit is "char" */ 89 #define CPA 1 /* chars per addr (for BUFLEN) */ 90 typedef char *ptr_t; 91 typedef ptr_t ret_t; /* return value pointer type */ 92 93 /* chars per descr (for BKSIZE,GETLTH) */ 94 #define CPD DESCR 95 96 /* 97 * descriptor; the basic SIL data type 98 */ 99 100 struct descr { 101 union addr a; /* address (new: v) */ 102 FFLD(f); /* flag (new: f) */ 103 VFLD(v); /* value (new: t) data-type/size */ 104 }; 105 106 #define DESCR ((int)sizeof(struct descr)) 107 108 /* 109 * string specifier (qualifier) 110 * 111 * NOTE!! A specifier is made up of two adjacent decsriptors, 112 * thus the "unused" field, and the use of "union addr" for "l" 113 */ 114 115 struct spec { /* (new: qualifier) */ 116 #ifdef SPEC_FIELD_NAMES 117 union addr l; /* length (overlays addr) */ 118 FFLD(unused); /* MBZ (must overlay flags) */ 119 VFLD(o); /* offset */ 120 union addr a; /* address (new: v) */ 121 FFLD(f); /* flags */ 122 VFLD(v); /* value (new: t) */ 123 #else /* SPEC_FIELD_NAMES not defined */ 124 /* alignment safe version (esp when using long long / double) */ 125 struct descr d[2]; 126 #endif /* SPEC_FIELD_NAMES not defined */ 127 }; 128 #define SPEC ((int)sizeof(struct spec)) 129 130 /* for generated code which deals with function pointers */ 131 typedef int (*func_t)(ret_t); 132 133 #ifndef BPC 134 #define BPC 8 /* 8 bits/char */ 135 #endif /* BPC not defined */ 136 137 #define SMAXINT ((((unsigned INT_T)1)<<(sizeof(INT_T)*BPC-1))-1) 138 139 /* here from load.h, for internal use w/o load.h */ 140 #define LOAD_PROTO struct descr *retval, unsigned nargs, struct descr *args 141