2004-07-16 02:26:21 -04:00
|
|
|
typedef struct {
|
|
|
|
CELL base;
|
|
|
|
CELL here;
|
2004-07-29 17:18:41 -04:00
|
|
|
CELL alarm;
|
2004-07-16 02:26:21 -04:00
|
|
|
CELL limit;
|
|
|
|
} ZONE;
|
|
|
|
|
|
|
|
ZONE* z1;
|
|
|
|
ZONE* z2;
|
|
|
|
ZONE* active; /* either z1 or z2 */
|
|
|
|
ZONE* prior; /* if active==z1, z2; if active==z2, z1 */
|
|
|
|
|
2004-08-12 02:13:43 -04:00
|
|
|
void* alloc_guarded(CELL size);
|
|
|
|
ZONE* zalloc(CELL size);
|
2004-07-16 02:26:21 -04:00
|
|
|
void init_arena(CELL size);
|
|
|
|
void flip_zones();
|
|
|
|
|
2004-08-16 20:42:30 -04:00
|
|
|
void check_memory(void);
|
2004-07-16 02:26:21 -04:00
|
|
|
|
|
|
|
INLINE CELL align8(CELL a)
|
|
|
|
{
|
|
|
|
return ((a & 7) == 0) ? a : ((a + 8) & ~7);
|
|
|
|
}
|
|
|
|
|
2004-08-16 20:42:30 -04:00
|
|
|
INLINE void* allot(CELL a)
|
|
|
|
{
|
|
|
|
CELL h = active->here;
|
|
|
|
active->here += align8(a);
|
|
|
|
check_memory();
|
|
|
|
return (void*)h;
|
|
|
|
}
|
|
|
|
|
2004-07-16 02:26:21 -04:00
|
|
|
INLINE CELL get(CELL where)
|
|
|
|
{
|
|
|
|
return *((CELL*)where);
|
|
|
|
}
|
|
|
|
|
|
|
|
INLINE void put(CELL where, CELL what)
|
|
|
|
{
|
|
|
|
*((CELL*)where) = what;
|
|
|
|
}
|
|
|
|
|
|
|
|
INLINE CHAR cget(CELL where)
|
|
|
|
{
|
|
|
|
return *((CHAR*)where);
|
|
|
|
}
|
|
|
|
|
|
|
|
INLINE void cput(CELL where, CHAR what)
|
|
|
|
{
|
|
|
|
*((CHAR*)where) = what;
|
|
|
|
}
|
|
|
|
|
2004-08-11 16:56:48 -04:00
|
|
|
INLINE char bget(CELL where)
|
2004-07-23 20:35:13 -04:00
|
|
|
{
|
2004-08-11 16:56:48 -04:00
|
|
|
return *((char*)where);
|
2004-07-23 20:35:13 -04:00
|
|
|
}
|
|
|
|
|
2004-08-11 16:56:48 -04:00
|
|
|
INLINE void bput(CELL where, char what)
|
2004-07-23 20:35:13 -04:00
|
|
|
{
|
2004-08-11 16:56:48 -04:00
|
|
|
*((char*)where) = what;
|
2004-07-23 20:35:13 -04:00
|
|
|
}
|
|
|
|
|
2004-07-16 02:26:21 -04:00
|
|
|
bool in_zone(ZONE* z, CELL pointer);
|
2004-07-24 00:54:57 -04:00
|
|
|
|
|
|
|
void primitive_room(void);
|