Skip to content

Commit

Permalink
- more mmc_alloc_words_atomic for #if !defined(RML_STYLE_TAGPTR)
Browse files Browse the repository at this point in the history
- works much better in Windows where omc is a 32 bit process

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@19702 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed Mar 24, 2014
1 parent ffe9a0c commit fee49fb
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
4 changes: 4 additions & 0 deletions SimulationRuntime/c/meta/meta_modelica.c
Expand Up @@ -96,7 +96,11 @@ char* mmc_mk_scon_len_ret_ptr(size_t nbytes)
unsigned int nwords = MMC_HDRSLOTS(header) + 1;
struct mmc_string *p;
void *res;
#if defined(RML_STYLE_TAGPTR)
p = (struct mmc_string *) mmc_alloc_words(nwords);
#else
p = (struct mmc_string *) mmc_alloc_words_atomic(nwords);
#endif
p->header = header;
res = MMC_TAGPTR(p);
return MMC_STRINGDATA(res);
Expand Down
5 changes: 5 additions & 0 deletions SimulationRuntime/c/meta/meta_modelica.h
Expand Up @@ -125,6 +125,7 @@ typedef int mmc_switch_type;
#endif

#define RML_STYLE_TAGPTR

#ifdef RML_STYLE_TAGPTR

/* RML-style tagged pointers */
Expand Down Expand Up @@ -350,7 +351,11 @@ static inline void* mmc_mk_scon_len(unsigned int nbytes)
unsigned int nwords = MMC_HDRSLOTS(header) + 1;
struct mmc_string *p;
void *res;
#if defined(RML_STYLE_TAGPTR)
p = (struct mmc_string *) mmc_alloc_words(nwords);
#else
p = (struct mmc_string *) mmc_alloc_words_atomic(nwords);
#endif
p->header = header;
res = MMC_TAGPTR(p);
return res;
Expand Down
20 changes: 20 additions & 0 deletions SimulationRuntime/c/meta/meta_modelica_builtin.c
Expand Up @@ -239,7 +239,11 @@ metamodelica_string boxptr_substring(threadData_t *threadData, metamodelica_stri
}
header = MMC_STRINGHDR(len);
nwords = MMC_HDRSLOTS(header) + 1;
#if defined(RML_STYLE_TAGPTR)
res = (struct mmc_string *) mmc_alloc_words(nwords);
#else
res = (struct mmc_string *) mmc_alloc_words_atomic(nwords);
#endif
res->header = header;
tmp = (char*) res->data;
memcpy(tmp, MMC_STRINGDATA(str) + start, len);
Expand Down Expand Up @@ -291,7 +295,11 @@ metamodelica_string stringAppendList(modelica_metatype lst)

header = MMC_STRINGHDR(nbytes);
nwords = MMC_HDRSLOTS(header) + 1;
#if defined(RML_STYLE_TAGPTR)
res = (struct mmc_string *) mmc_alloc_words(nwords);
#else
res = (struct mmc_string *) mmc_alloc_words_atomic(nwords);
#endif
res->header = header;
tmp = (char*) res->data;
nbytes = 0;
Expand Down Expand Up @@ -343,7 +351,11 @@ metamodelica_string boxptr_stringDelimitList(threadData_t *threadData,modelica_m

header = MMC_STRINGHDR(nbytes);
nwords = MMC_HDRSLOTS(header) + 1;
#if defined(RML_STYLE_TAGPTR)
res = (struct mmc_string *) mmc_alloc_words(nwords);
#else
res = (struct mmc_string *) mmc_alloc_words_atomic(nwords);
#endif
res->header = header;
tmp = (char*) res->data;
nbytes = 0;
Expand Down Expand Up @@ -423,7 +435,11 @@ modelica_metatype boxptr_stringUpdateStringChar(threadData_t *threadData,metamod
length = MMC_STRLEN(str);
if (ix > length)
MMC_THROW_INTERNAL();
#if defined(RML_STYLE_TAGPTR)
p = (struct mmc_string *) mmc_alloc_words(nwords);
#else
p = (struct mmc_string *) mmc_alloc_words_atomic(nwords);
#endif
p->header = header;
memcpy(p->data, MMC_STRINGDATA(str), length);
p->data[ix-1] = MMC_STRINGDATA(c)[0];
Expand All @@ -446,7 +462,11 @@ metamodelica_string_const boxptr_stringAppend(threadData_t *threadData,metamodel
nbytes = len1+len2;
header = MMC_STRINGHDR(nbytes);
nwords = MMC_HDRSLOTS(header) + 1;
#if defined(RML_STYLE_TAGPTR)
p = (struct mmc_string *) mmc_alloc_words(nwords);
#else
p = (struct mmc_string *) mmc_alloc_words_atomic(nwords);
#endif
/* fprintf(stderr, "at address %p\n", MMC_TAGPTR(p)); fflush(NULL); */
p->header = header;

Expand Down

0 comments on commit fee49fb

Please sign in to comment.