File: memory_map.c

package info (click to toggle)
scheme48 1.9.2-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 18,332 kB
  • sloc: lisp: 88,907; ansic: 87,519; sh: 3,224; makefile: 771
file content (38 lines) | stat: -rw-r--r-- 1,132 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
 * Part of Scheme 48 1.9.  See file COPYING for notices and license.
 *
 * Authors: David Frese
 */

/* The Boehm collector also has a link to the next entry in ascending
   order. This is used for sweeping etc.. I don't think we need
   such. It would be hard to reconstruct dynamically.  It is easy
   enough to find adjacent blocks, which is all I would think matters
   to us */

#include <stdlib.h>
#include "utils.h"
#include "memory_map.h"
#include "page_constants.h"

Metapage* s48_memory_table[TABLE_SIZE];

void s48_memory_map_setB(s48_address address, Area* value) {
  Metapage** metapagep = find_metapagep(address);
  Metapage* metapage = *metapagep;
  if (metapage == NULL) {

    metapage = (Metapage*)calloc(1, sizeof(Metapage));
    if (metapage == NULL) s48_gc_error("add_metapage: out of memory");

#ifdef NEED_METAPAGE_HASHING
    metapage->start_address = ADDR_REST_MASKED(address);
    assert(IS_CORRECT_METAPAGE(metapage, address));
    metapage->next = NULL;
#endif

    *metapagep = metapage;
  }
  metapage->contents[ADDR_PAGE_INDEX(address)] = value;
  assert(metapage == *(find_metapagep(address)));
}