Skip to content

Commit

Permalink
- mmc_mk_rcon and mmc_unbox_real now do not use a padded struct for a…
Browse files Browse the repository at this point in the history
…llocation/access of data

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@8213 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Mar 14, 2011
1 parent 0991a60 commit 1920e45
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions c_runtime/meta_modelica.c
Expand Up @@ -36,10 +36,11 @@ jmp_buf *mmc_jumper;

void* mmc_mk_rcon(double d)
{
struct mmc_real *p = mmc_alloc_words(sizeof(struct mmc_real)/MMC_SIZE_INT);
p->header = MMC_REALHDR;
p->data = d;
return MMC_TAGPTR(p);
void *p = mmc_alloc_words(MMC_SIZE_DBL/MMC_SIZE_INT+1);
((mmc_uint_t*)p)[0] = MMC_REALHDR;
*((double*)((mmc_uint_t*)p+1)) = d;
p = MMC_TAGPTR(p);
return p;
}

void *mmc_mk_box_arr(int slots, unsigned ctor, const void** args)
Expand Down
2 changes: 1 addition & 1 deletion c_runtime/meta_modelica.h
Expand Up @@ -82,7 +82,7 @@ typedef int mmc_sint_t;
#define MMC_TAGFIXNUM(i) ((i) << 1)
#define MMC_UNTAGFIXNUM(X) (((mmc_sint_t) X) >> 1)
#define MMC_REALHDR (((MMC_SIZE_DBL/MMC_SIZE_INT) << 10) + 9)
#define MMC_REALDATA(x) (((struct mmc_real*)MMC_UNTAGPTR(x))->data)
#define MMC_REALDATA(x) (*((double*)(((mmc_uint_t*)MMC_UNTAGPTR(x))+1)))
#define MMC_STRINGHDR(nbytes) (((nbytes)<<(10-MMC_LOG2_SIZE_INT))+((1<<10)+5))
#define MMC_HDRSLOTS(hdr) ((hdr) >> 10)
#define MMC_GETHDR(x) (*(mmc_uint_t*)MMC_UNTAGPTR(x))
Expand Down

0 comments on commit 1920e45

Please sign in to comment.