Skip to content

Commit bd65b8b

Browse files
committed
- NEW RML or NEW OMDev is required for this and make clean!
- unified with MetaModelica/rml revision 260 https://openmodelica.ida.liu.se/svn/MetaModelica/trunk Revision: 260 Author: adrpo Date: den 5 maj 2013 21:46:18 Message: - larger strings on 32 and 64 bit (now we consider the slots [*only for strings*] to be 32-5 bits on 32bit [3 is 101 the string tag + 2 to translate from words to bytes] and 64-6 bits on 64bit [3 is 101 the string tag + 3 to translate from words to bytes]) on 32 bit: 536870907 bytes maximum (~511 Mbytes strings) on 64 bit: who cares? git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@15985 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 4afb2af commit bd65b8b

File tree

1 file changed

+40
-35
lines changed

1 file changed

+40
-35
lines changed

SimulationRuntime/c/meta/meta_modelica.h

Lines changed: 40 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -127,52 +127,57 @@ typedef int mmc_switch_type;
127127

128128
#endif
129129

130-
#define MMC_TAGPTR(p) ((void*)((char*)(p) + 3))
131-
#define MMC_UNTAGPTR(x) ((void*)((char*)(x) - 3))
130+
#define MMC_TAGPTR(p) ((void*)((char*)(p) + 3))
131+
#define MMC_UNTAGPTR(x) ((void*)((char*)(x) - 3))
132132
#define MMC_STRUCTHDR(slots,ctor) (((slots) << 10) + (((ctor) & 255) << 2))
133-
#define MMC_NILHDR MMC_STRUCTHDR(0,0)
134-
#define MMC_CONSHDR MMC_STRUCTHDR(2,1)
135-
#define MMC_NONEHDR MMC_STRUCTHDR(0,1)
136-
#define MMC_OFFSET(p,i) ((void*)((void**)(p) + (i)))
137-
#define MMC_FETCH(p) (*(void**)(p))
138-
#define MMC_CAR(X) MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(X),1))
139-
#define MMC_CDR(X) MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(X),2))
140-
#define MMC_NILTEST(x) (MMC_GETHDR(x) == MMC_NILHDR)
141-
#define MMC_IMMEDIATE(i) ((void*)(i))
142-
#define MMC_IS_IMMEDIATE(x) (!((mmc_uint_t)(x) & 1))
143-
#define MMC_TAGFIXNUM(i) ((i) << 1)
144-
#define MMC_UNTAGFIXNUM(X) (((mmc_sint_t) X) >> 1)
145-
#define MMC_REALHDR (((MMC_SIZE_DBL/MMC_SIZE_INT) << 10) + 9)
146-
#define MMC_HDR_IS_FORWARD(hdr) (((hdr) & 3) == 3)
133+
#define MMC_NILHDR MMC_STRUCTHDR(0,0)
134+
#define MMC_CONSHDR MMC_STRUCTHDR(2,1)
135+
#define MMC_NONEHDR MMC_STRUCTHDR(0,1)
136+
#define MMC_OFFSET(p,i) ((void*)((void**)(p) + (i)))
137+
#define MMC_FETCH(p) (*(void**)(p))
138+
#define MMC_CAR(X) MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(X),1))
139+
#define MMC_CDR(X) MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(X),2))
140+
#define MMC_NILTEST(x) (MMC_GETHDR(x) == MMC_NILHDR)
141+
#define MMC_IMMEDIATE(i) ((void*)(i))
142+
#define MMC_IS_IMMEDIATE(x) (!((mmc_uint_t)(x) & 1))
143+
#define MMC_TAGFIXNUM(i) ((i) << 1)
144+
#define MMC_UNTAGFIXNUM(X) (((mmc_sint_t) X) >> 1)
145+
#define MMC_REALHDR (((MMC_SIZE_DBL/MMC_SIZE_INT) << 10) + 9)
146+
#define MMC_HDR_IS_FORWARD(hdr) (((hdr) & 3) == 3)
147147
/*
148148
#define MMC_REALDATA(x) (*((double*)(((mmc_uint_t*)MMC_UNTAGPTR(x))+1)))
149149
*/
150-
#define MMC_REALDATA(x) (((struct mmc_real*)MMC_UNTAGPTR(x))->data)
151-
#define MMC_STRINGHDR(nbytes) (((nbytes)<<(10-MMC_LOG2_SIZE_INT))+((1<<10)+5))
152-
#define MMC_HDRSLOTS(hdr) ((hdr) >> 10)
153-
#define MMC_GETHDR(x) (*(mmc_uint_t*)MMC_UNTAGPTR(x))
154-
#define MMC_HDRCTOR(hdr) (((hdr) >> 2) & 255)
155-
#define MMC_HDRISSTRING(hdr) (((hdr) & ((1<<(10-MMC_LOG2_SIZE_INT))-1)) == 5)
156-
#define MMC_HDRSTRLEN(hdr) (((hdr) >> (10-MMC_LOG2_SIZE_INT)) - MMC_SIZE_INT)
157-
#define MMC_STRINGDATA(x) (((struct mmc_string*)MMC_UNTAGPTR(x))->data)
158-
#define MMC_HDRISSTRUCT(hdr) (!((hdr) & 3))
159-
#define MMC_STRUCTDATA(x) (((struct mmc_struct*)MMC_UNTAGPTR(x))->data)
160-
#define MMC_ARRAY_TAG 255
161-
#define MMC_STRLEN(x) (MMC_HDRSTRLEN(MMC_GETHDR(x)))
162-
#define MMC_OPTIONNONE(x) (0==MMC_HDRSLOTS(MMC_GETHDR(x)) ? 1 : 0)
150+
#define MMC_REALDATA(x) (((struct mmc_real*)MMC_UNTAGPTR(x))->data)
151+
152+
#define MMC_GETHDR(x) (*(mmc_uint_t*)MMC_UNTAGPTR(x))
153+
154+
#define MMC_STRINGHDR(nbytes) ((((mmc_uint_t)nbytes)<<(3))+((1<<(3+MMC_LOG2_SIZE_INT))+5))
155+
#define MMC_HDRISSTRING(hdr) (((hdr) & (7)) == 5)
156+
#define MMC_HDRSTRLEN(hdr) (((hdr) >> (3)) - MMC_SIZE_INT)
157+
#define MMC_STRINGDATA(x) (((struct mmc_string*)MMC_UNTAGPTR(x))->data)
158+
#define MMC_HDRSTRINGSLOTS(hdr) (hdr >> (3+MMC_LOG2_SIZE_INT))
159+
160+
#define MMC_HDRSLOTS(hdr) ((MMC_HDRISSTRING(hdr)) ? (MMC_HDRSTRINGSLOTS(hdr)) : ((hdr) >> 10))
161+
#define MMC_HDRCTOR(hdr) (((hdr) >> 2) & 255)
162+
#define MMC_HDRISSTRUCT(hdr) (!((hdr) & 3))
163+
#define MMC_STRUCTDATA(x) (((struct mmc_struct*)MMC_UNTAGPTR(x))->data)
164+
165+
#define MMC_ARRAY_TAG 255
166+
#define MMC_STRLEN(x) (MMC_HDRSTRLEN(MMC_GETHDR(x)))
167+
#define MMC_OPTIONNONE(x) (0==MMC_HDRSLOTS(MMC_GETHDR(x)) ? 1 : 0)
163168

164169
/*
165170
* adrpo: if a structure has pointers
166171
* Bit 0 is zero if the node contains pointers, 1 otherwise.
167172
*/
168-
#define MMC_HDRHASPTRS(hdr) (!((hdr) & 1))
173+
#define MMC_HDRHASPTRS(hdr) (!((hdr) & 1))
169174
/*
170175
* adrpo: if this object was marked, used by GC!
171176
* [xxxxxxxx1x] (used during garbage collection) a marked node;
172177
*/
173-
#define MMC_HDRISMARKED(hdr) ((hdr) & 2)
174-
#define MMC_HDR_MARK(hdr) ((hdr) | 2)
175-
#define MMC_HDR_UNMARK(hdr) ((hdr) & ~((mmc_uint_t)2))
178+
#define MMC_HDRISMARKED(hdr) ((hdr) & 2)
179+
#define MMC_HDR_MARK(hdr) ((hdr) | 2)
180+
#define MMC_HDR_UNMARK(hdr) ((hdr) & ~((mmc_uint_t)2))
176181

177182

178183
#define MMC_INT_MAX ((1<<30)-1)
@@ -193,7 +198,7 @@ typedef int mmc_switch_type;
193198
} NAME = { MMC_STRINGHDR(LEN), VAL }
194199
#define MMC_REFSTRINGLIT(NAME) MMC_TAGPTR(&(NAME).header)
195200

196-
/* adrpo: assume RML_DBL_PAD always! */
201+
/* adrpo: assume MMC_DBL_PAD always! */
197202
struct mmc_real_lit { /* there must be no padding between `header' and `data' */
198203
mmc_uint_t filler;
199204
mmc_uint_t header;
@@ -216,7 +221,7 @@ struct mmc_cons_struct {
216221
void *data[2]; /* `slots' elements */
217222
};
218223

219-
/* adrpo: assume RML_DBL_STRICT always! */
224+
/* adrpo: assume MMC_DBL_STRICT always! */
220225
struct mmc_real {
221226
mmc_uint_t header; /* MMC_REALHDR */
222227
mmc_uint_t data[MMC_SIZE_DBL/MMC_SIZE_INT];

0 commit comments

Comments
 (0)