factor/native/memory.h

73 lines
1.1 KiB
C
Raw Normal View History

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 active;
ZONE prior;
2004-07-16 02:26:21 -04:00
2004-08-29 03:20:19 -04:00
bool allot_profiling;
2004-08-12 02:13:43 -04:00
void* alloc_guarded(CELL size);
void init_zone(ZONE* zone, 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-08-29 03:20:19 -04:00
void allot_profile_step(CELL a);
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);
2004-08-29 03:20:19 -04:00
#ifdef FACTOR_PROFILER
if(allot_profiling)
allot_profile_step(align8(a));
#endif
2004-08-16 20:42:30 -04:00
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;
}
INLINE BYTE bget(CELL where)
{
return *((BYTE*)where);
}
INLINE void bput(CELL where, BYTE what)
{
*((BYTE*)where) = what;
}
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);
2004-08-29 03:20:19 -04:00
void primitive_allot_profiling(void);
void primitive_address_of(void);