2000-05-28 13:40:48 +00:00
|
|
|
/*
|
2014-06-30 09:10:35 +00:00
|
|
|
** _heap.h
|
|
|
|
**
|
|
|
|
** Ullrich von Bassewitz, 1998-06-03, 2004-12-19
|
|
|
|
**
|
|
|
|
*/
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __HEAP_H
|
|
|
|
#define __HEAP_H
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-06-30 09:10:35 +00:00
|
|
|
/* Structure that preceeds a user block in most cases.
|
|
|
|
** The aligned_malloc function may generate blocks where the start pointer
|
|
|
|
** and size are splitted to handle a memory hole that is needed for
|
|
|
|
** alignment.
|
|
|
|
*/
|
2004-12-19 23:09:38 +00:00
|
|
|
struct usedblock {
|
|
|
|
unsigned size;
|
|
|
|
struct usedblock* start;
|
|
|
|
};
|
|
|
|
|
2000-05-28 13:40:48 +00:00
|
|
|
/* Space needed for administering used blocks */
|
2004-12-19 23:09:38 +00:00
|
|
|
#define HEAP_ADMIN_SPACE sizeof (struct usedblock)
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2003-02-01 12:22:09 +00:00
|
|
|
/* The data type used to implement the free list.
|
2014-06-30 09:10:35 +00:00
|
|
|
** Beware: Field order is significant!
|
|
|
|
*/
|
2000-05-28 13:40:48 +00:00
|
|
|
struct freeblock {
|
2013-05-09 11:56:54 +00:00
|
|
|
unsigned size;
|
|
|
|
struct freeblock* next;
|
|
|
|
struct freeblock* prev;
|
2000-05-28 13:40:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Variables that describe the heap */
|
2022-08-29 17:55:48 +00:00
|
|
|
extern unsigned* __heaporg; /* Bottom of heap */
|
|
|
|
extern unsigned* __heapptr; /* Current top */
|
|
|
|
extern unsigned* __heapend; /* Upper limit */
|
|
|
|
extern struct freeblock* __heapfirst; /* First free block in list */
|
|
|
|
extern struct freeblock* __heaplast; /* Last free block in list */
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2022-08-29 18:10:21 +00:00
|
|
|
#if __CC65_STD__ == __CC65_STD_CC65__
|
|
|
|
/* define old name with one underscore for backwards compatibility */
|
|
|
|
#define _heaporg __heaporg
|
|
|
|
#define _heapptr __heapptr
|
|
|
|
#define _heapend __heapend
|
|
|
|
#define _heapfirst __heapfirst
|
|
|
|
#define _heaplast __heaplast
|
|
|
|
#endif
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
/* End of _heap.h */
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|