Skip to content

Commit

Permalink
SimulationRuntime/c/util/string_util.c
Browse files Browse the repository at this point in the history
- proper type sizes for 32 bit
- fix cycle in reading of csv file for test
  simulation/libraries/msl32_cpp/Modelica.Thermal.FluidHeatFlow.Examples.ParallelPumpDropOut.mos

CodegenC.tpl
- remove useless comment in the generated code.

Makefile.omdev.mingw
- compile GC with --enable-munmap=5 to return the free pages to OS after 5 GC cycles

C sources
- do not use alloc_*ignore_off_page so that we can debug better.



git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@19777 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed Mar 26, 2014
1 parent 11261ef commit 69437bb
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 7 deletions.
1 change: 0 additions & 1 deletion Compiler/Template/CodegenC.tpl
Expand Up @@ -5523,7 +5523,6 @@ case FUNCTION(__) then
<%outVarCopy%>
/* functionBodyRegularFunction: out var assign */
<%outVarAssign%>
/* GC: pop the mark! */
<%if acceptParModelicaGrammar() then
'/* Free GPU/OpenCL CPU memory */<%\n%><%varFrees%>'%>
<%freeConstructedExternalObjects%>
Expand Down
1 change: 1 addition & 0 deletions Compiler/runtime/systemimpl.c
Expand Up @@ -2571,6 +2571,7 @@ void SystemImpl__initGarbageCollector(void)
#ifdef RML_STYLE_TAGPTR
GC_register_displacement(3);
#endif
GC_set_force_unmap_on_gcollect(1);
}

int SystemImpl__fileContentsEqual(const char *file1, const char *file2)
Expand Down
2 changes: 1 addition & 1 deletion Compiler/runtime/systemimplmisc.cpp
Expand Up @@ -36,7 +36,7 @@ extern "C" {
FindAndReplace(str,string(search_str),string(replace_str));

len = strlen(str.c_str());
char* res = (char *)GC_malloc_atomic_ignore_off_page(len + 1);
char* res = (char *)GC_malloc_atomic(len + 1);
strcpy(res, str.c_str());
res[len] = '\0';
return res;
Expand Down
5 changes: 3 additions & 2 deletions SimulationRuntime/c/meta/gc/mmc_gc.h
Expand Up @@ -82,6 +82,7 @@ static inline void mmc_GC_init(void)
#ifdef RML_STYLE_TAGPTR
GC_register_displacement(3);
#endif
GC_set_force_unmap_on_gcollect(1);
}

static inline void mmc_GC_init_default(void)
Expand All @@ -101,12 +102,12 @@ static inline void* mmc_alloc_words(unsigned int nwords) {
}

/* for arrays only */
static inline void* mmc_alloc_words_atomic_ignore_offpage(unsigned int nwords) {
static inline void* mmc_alloc_words_atomic_ignore_off_page(unsigned int nwords) {
return GC_MALLOC_ATOMIC_IGNORE_OFF_PAGE((nwords) * sizeof(void*));
}

/* for arrays only */
static inline void* mmc_alloc_words_ignore_offpage(unsigned int nwords) {
static inline void* mmc_alloc_words_ignore_off_page(unsigned int nwords) {
return GC_MALLOC_IGNORE_OFF_PAGE((nwords) * sizeof(void*));
}

Expand Down
4 changes: 2 additions & 2 deletions SimulationRuntime/c/meta/meta_modelica.c
Expand Up @@ -65,7 +65,7 @@ void* mmc_mk_rcon(double d)
void *mmc_mk_box_arr(int slots, unsigned int ctor, void** args)
{
int i;
struct mmc_struct *p = (struct mmc_struct*)mmc_alloc_words_ignore_offpage(slots + 1);
struct mmc_struct *p = (struct mmc_struct*)mmc_alloc_words(slots + 1);
p->header = MMC_STRUCTHDR(slots, ctor);
for (i=0; i<slots; i++) {
p->data[i] = (void*) args[i];
Expand All @@ -78,7 +78,7 @@ void *mmc_mk_box_arr(int slots, unsigned int ctor, void** args)

void *mmc_mk_box_no_assign(int slots, unsigned int ctor)
{
struct mmc_struct *p = (struct mmc_struct*)mmc_alloc_words_ignore_offpage(slots+1);
struct mmc_struct *p = (struct mmc_struct*)mmc_alloc_words(slots+1);
p->header = MMC_STRUCTHDR(slots, ctor);
#ifdef MMC_MK_DEBUG
fprintf(stderr, "STRUCT NO ASSIGN slots%d ctor %u\n", slots, ctor); fflush(NULL);
Expand Down
2 changes: 1 addition & 1 deletion SimulationRuntime/c/meta/meta_modelica_builtin.c
Expand Up @@ -461,7 +461,7 @@ modelica_metatype listAppend(modelica_metatype lst1,modelica_metatype lst2)
length = listLength(lst1);
if (length == 0) /* We need to check for empty lst1 */
return lst2;
res = (struct mmc_cons_struct*)mmc_alloc_words_ignore_offpage( length * 3 /*(sizeof(struct mmc_cons_struct)/sizeof(void*))*/ ); /* Do one single big alloc. It's cheaper */
res = (struct mmc_cons_struct*)mmc_alloc_words( length * 3 /*(sizeof(struct mmc_cons_struct)/sizeof(void*))*/ ); /* Do one single big alloc. It's cheaper */
for (i=0; i<length-1; i++) { /* Write all except the last element... */
struct mmc_cons_struct *p = res+i;
p->header = MMC_STRUCTHDR(2, MMC_CONS_CTOR);
Expand Down
7 changes: 7 additions & 0 deletions SimulationRuntime/c/util/string_util.c
Expand Up @@ -25,9 +25,16 @@

#define ISDIGIT(x) isdigit(x)
#define ISSPACE(x) isspace(x)

#ifdef _LP64 /* 64 bit */
#define SIZEOF_LONG 8
typedef uint64_t ULong;
typedef int64_t Long;
#else /* 32 bit */
#define SIZEOF_LONG 4
typedef uint32_t ULong;
typedef int32_t Long;
#endif

unsigned long
om_scan_oct(const char *start, size_t len, size_t *retlen)
Expand Down

0 comments on commit 69437bb

Please sign in to comment.