Skip to content

Commit

Permalink
- add function rand to System
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@11817 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Jens Frenkel committed Apr 27, 2012
1 parent 4c54d93 commit 0ce3c23
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Compiler/Util/System.mo
Expand Up @@ -915,4 +915,13 @@ function snprintff "sprintf format string that takes one double as argument"
external "C" str=System_snprintff(format,maxlen,val) annotation(Library = {"omcruntime"});
end snprintff;

public function rand
"function: rand
author: Frenkel TUD 2012-04
"
output Real r;

external "C" r = System_rand();
end rand;

end System;
5 changes: 5 additions & 0 deletions Compiler/runtime/System_omc.cpp
Expand Up @@ -691,4 +691,9 @@ extern const char* System_snprintff(const char *fmt, int len, double d)
return buf;
}

int System_rand()
{
return rand();
}

}
8 changes: 8 additions & 0 deletions Compiler/runtime/System_rml.c
Expand Up @@ -2056,3 +2056,11 @@ RML_BEGIN_LABEL(System__snprintff)
RML_TAILCALLK(rmlSC);
}
RML_END_LABEL


RML_BEGIN_LABEL(System__rand)
{
rmlA0 = mk_icon(rand());
RML_TAILCALLK(rmlSC);
}
RML_END_LABEL

0 comments on commit 0ce3c23

Please sign in to comment.