Пример #1
0
void *mk_box2(unsigned ctor, void *x0, void *x1) {
  struct rml_struct *p = alloc_words(3);
  p->header = RML_STRUCTHDR(2, ctor);
  p->data[0] = x0;
  p->data[1] = x1;
  return RML_TAGPTR(p);
}
Пример #2
0
void *mk_box1(unsigned ctor, void *x0)
{
    struct rml_struct *p = alloc_words(2);
    p->header = RML_STRUCTHDR(1, ctor);
    p->data[0] = x0;
    return RML_TAGPTR(p);
}
Пример #3
0
void *mk_rcon(double d)
{
    struct rml_real *p = alloc_words(RML_SIZE_DBL/RML_SIZE_INT + 1);
    rml_prim_set_real(p, d);
    p->header = RML_REALHDR;
    return RML_TAGPTR(p);
}
Пример #4
0
void *mk_box3(unsigned ctor, void *x0, void *x1, void *x2) {
  struct rml_struct *p = alloc_words(4);
  p->header = RML_STRUCTHDR(3, ctor);
  p->data[0] = x0;
  p->data[1] = x1;
  p->data[2] = x2;
  return RML_TAGPTR(p);
}
Пример #5
0
void *mk_box4(unsigned ctor, void *x0, void *x1, void *x2, void *x3) {
  struct rml_struct *p = alloc_words(5);
  p->header = RML_STRUCTHDR(4, ctor);
  p->data[0] = x0;
  p->data[1] = x1;
  p->data[2] = x2;
  p->data[3] = x3;
  return RML_TAGPTR(p);
}
Пример #6
0
void *mk_scon(char *s)
{
    unsigned nbytes = strlen(s);
    unsigned header = RML_STRINGHDR(nbytes);
    unsigned nwords = RML_HDRSLOTS(header) + 1;
    struct rml_string *p = alloc_words(nwords);
    p->header = header;
    memcpy(p->data, s, nbytes+1);	/* including terminating '\0' */
    return RML_TAGPTR(p);
}
Пример #7
0
void *mk_box6(unsigned ctor, void *x0, void *x1, void *x2, void *x3, void *x4,
    void *x5) {
  struct rml_struct *p = alloc_words(7);
  p->header = RML_STRUCTHDR(6, ctor);
  p->data[0] = x0;
  p->data[1] = x1;
  p->data[2] = x2;
  p->data[3] = x3;
  p->data[4] = x4;
  p->data[5] = x5;
  return RML_TAGPTR(p);
}
Пример #8
0
void *mk_scon(char *s) {
  rml_uint_t nbytes = strlen(s);
  rml_uint_t header= RML_STRINGHDR(nbytes);
  rml_uint_t nwords= RML_HDRSLOTS(header) + 1;
  if (!rml_string_cache_index) /* no string in the cache */
  {
    struct rml_string *p = alloc_words(nwords);
    p->header = header;
    memcpy(p->data, s, nbytes+1); /* including terminating '\0' */
    if (rml_string_cache_index < RML_STRING_CACHE_MAX &&
        nbytes < RML_SHARED_STRING_MAX) /* add to sharing only if less than RML_SHARED_STRING_MAX */
      rml_string_cache[rml_string_cache_index++] = p;
    return RML_TAGPTR(p);
  }
  /* else, try to find if we already have the same string in the heap */
  {
    unsigned int i;
    struct rml_string *p;
    for (i = 0; i < rml_string_cache_index; i++)
    {
      p = rml_string_cache[i];
      if (strcmp(p->data,s) == 0)
      {
        rml_total_shared_strings++;
        rml_total_shared_strings_words += nwords;
        return RML_TAGPTR(p);
      }
    }
    /* no string found in cache */
    {
      struct rml_string *p = alloc_words(nwords);
      p->header = header;
      memcpy(p->data, s, nbytes+1); /* including terminating '\0' */
      if (rml_string_cache_index < RML_STRING_CACHE_MAX &&
          nbytes < RML_SHARED_STRING_MAX) /* add to sharing only if less than RML_SHARED_STRING_MAX */
        rml_string_cache[rml_string_cache_index++] = p;
      return RML_TAGPTR(p);
    }
  }
}
Пример #9
0
void *mk_box8(unsigned ctor, void *x0, void *x1, void *x2, void *x3, void *x4,
    void *x5, void *x6, void *x7) {
  struct rml_struct *p = alloc_words(9);
  p->header = RML_STRUCTHDR(8, ctor);
  p->data[0] = x0;
  p->data[1] = x1;
  p->data[2] = x2;
  p->data[3] = x3;
  p->data[4] = x4;
  p->data[5] = x5;
  p->data[6] = x6;
  p->data[7] = x7;
  return RML_TAGPTR(p);
}
Пример #10
0
void *mk_box0(unsigned ctor) {
  struct rml_struct *p = alloc_words(1);
  p->header = RML_STRUCTHDR(0, ctor);
  return RML_TAGPTR(p);
}