home *** CD-ROM | disk | FTP | other *** search
- #ifndef osheap_H
- #define osheap_H
-
- /* C header file for OSHeap
- * written by DefMod (Sep 7 1994) on Wed Sep 7 21:20:41 1994
- * Copyright © Acorn Computers Ltd, 1994
- */
-
- /*************************************************************************
- * This source file was written by Acorn Computers Limited. It is part *
- * of the OSLib library for writing applications for RISC OS. It may be *
- * used freely in the creation of programs for RISC OS. *
- *************************************************************************/
-
- #ifndef types_H
- #include "types.h"
- #endif
-
- #ifndef os_H
- #include "os.h"
- #endif
-
- /**********************************
- * SWI names and SWI reason codes *
- **********************************/
- #undef OS_Heap
- #define OS_Heap 0x1D
- #undef XOS_Heap
- #define XOS_Heap 0x2001D
- #undef OSHeap_Initialise
- #define OSHeap_Initialise 0x0
- #undef OSHeap_Describe
- #define OSHeap_Describe 0x1
- #undef OSHeap_Alloc
- #define OSHeap_Alloc 0x2
- #undef OSHeap_Free
- #define OSHeap_Free 0x3
- #undef OSHeap_Realloc
- #define OSHeap_Realloc 0x4
- #undef OSHeap_Resize
- #define OSHeap_Resize 0x5
- #undef OSHeap_ReadSize
- #define OSHeap_ReadSize 0x6
-
- /************************
- * Constant definitions *
- ************************/
- #define error_HEAP_BAD_REASON 0x180u
- #define error_HEAP_INIT 0x181u
- #define error_HEAP_BAD_DESC 0x182u
- #define error_HEAP_BAD_LINK 0x183u
- #define error_HEAP_ALLOC 0x184u
- #define error_HEAP_NOT_ABLOCK 0x185u
- #define error_HEAP_BAD_EXTEND 0x186u
- #define error_HEAP_EXCESSIVE_SHRINK 0x187u
- #define error_HEAP_HEAP_LOCKED 0x188u
-
- /*************************
- * Function declarations *
- *************************/
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- /*************************************************************
- * NOTE: The following functions provide direct access to *
- * the SWI's noted in the function description. *
- * Please read the relevant PRM section for more *
- * information on their input/output parameters. *
- *************************************************************/
-
- /* ------------------------------------------------------------------------
- * Function: osheap_initialise()
- *
- * Description: Initialises a heap
- *
- * Input: heap - value of R1 on entry
- * size - value of R3 on entry
- *
- * Other notes: Calls SWI 0x1D with R0 = 0x0.
- */
-
- extern os_error *xosheap_initialise (byte *heap,
- int size);
- extern void osheap_initialise (byte *heap,
- int size);
-
- /* ------------------------------------------------------------------------
- * Function: osheap_describe()
- *
- * Description: Describes a heap
- *
- * Input: heap - value of R1 on entry
- *
- * Output: max - value of R2 on exit
- * free - value of R3 on exit (X version only)
- *
- * Returns: R3 (non-X version only)
- *
- * Other notes: Calls SWI 0x1D with R0 = 0x1.
- */
-
- extern os_error *xosheap_describe (byte *heap,
- int *max,
- int *free);
- extern int osheap_describe (byte *heap,
- int *max);
-
- /* ------------------------------------------------------------------------
- * Function: osheap_alloc()
- *
- * Description: Gets a heap block
- *
- * Input: heap - value of R1 on entry
- * size - value of R2 on entry
- *
- * Output: blk - value of R2 on exit (X version only)
- *
- * Returns: R2 (non-X version only)
- *
- * Other notes: Calls SWI 0x1D with R0 = 0x2.
- */
-
- extern os_error *xosheap_alloc (byte *heap,
- int size,
- void **blk);
- extern void *osheap_alloc (byte *heap,
- int size);
-
- /* ------------------------------------------------------------------------
- * Function: osheap_free()
- *
- * Description: Frees a heap block
- *
- * Input: heap - value of R1 on entry
- * blk - value of R2 on entry
- *
- * Other notes: Calls SWI 0x1D with R0 = 0x3.
- */
-
- extern os_error *xosheap_free (byte *heap,
- void *blk);
- extern void osheap_free (byte *heap,
- void *blk);
-
- /* ------------------------------------------------------------------------
- * Function: osheap_realloc()
- *
- * Description: Extends or shrinks a heap block
- *
- * Input: heap - value of R1 on entry
- * blk - value of R2 on entry
- * size_increase - value of R3 on entry
- *
- * Output: blk_out - value of R2 on exit (X version only)
- *
- * Returns: R2 (non-X version only)
- *
- * Other notes: Calls SWI 0x1D with R0 = 0x4.
- */
-
- extern os_error *xosheap_realloc (byte *heap,
- void *blk,
- int size_increase,
- void **blk_out);
- extern void *osheap_realloc (byte *heap,
- void *blk,
- int size_increase);
-
- /* ------------------------------------------------------------------------
- * Function: osheap_resize()
- *
- * Description: Extends or shrinks a heap
- *
- * Input: heap - value of R1 on entry
- * size_increase - value of R3 on entry
- *
- * Other notes: Calls SWI 0x1D with R0 = 0x5.
- */
-
- extern os_error *xosheap_resize (byte *heap,
- int size_increase);
- extern void osheap_resize (byte *heap,
- int size_increase);
-
- /* ------------------------------------------------------------------------
- * Function: osheap_read_size()
- *
- * Description: Reads a heap block size
- *
- * Input: heap - value of R1 on entry
- * blk - value of R2 on entry
- *
- * Output: size - value of R3 on exit (X version only)
- *
- * Returns: R3 (non-X version only)
- *
- * Other notes: Calls SWI 0x1D with R0 = 0x6.
- */
-
- extern os_error *xosheap_read_size (byte *heap,
- void *blk,
- int *size);
- extern int osheap_read_size (byte *heap,
- void *blk);
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif
-