home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 1 / RISC_DISC_1.iso / pd_share / code / oslib / h / osheap < prev    next >
Encoding:
Text File  |  1994-09-07  |  6.0 KB  |  213 lines

  1. #ifndef osheap_H
  2. #define osheap_H
  3.  
  4. /* C header file for OSHeap
  5.  * written by DefMod (Sep  7 1994) on Wed Sep  7 21:20:41 1994
  6.  * Copyright © Acorn Computers Ltd, 1994
  7.  */
  8.  
  9. /*************************************************************************
  10.  * This source file was written by Acorn Computers Limited. It is part   *
  11.  * of the OSLib library for writing applications for RISC OS. It may be  *
  12.  * used freely in the creation of programs for RISC OS.                  *
  13.  *************************************************************************/
  14.  
  15. #ifndef types_H
  16.    #include "types.h"
  17. #endif
  18.  
  19. #ifndef os_H
  20.    #include "os.h"
  21. #endif
  22.  
  23. /**********************************
  24.  * SWI names and SWI reason codes *
  25.  **********************************/
  26. #undef  OS_Heap
  27. #define OS_Heap                                 0x1D
  28. #undef  XOS_Heap
  29. #define XOS_Heap                                0x2001D
  30. #undef  OSHeap_Initialise
  31. #define OSHeap_Initialise                       0x0
  32. #undef  OSHeap_Describe
  33. #define OSHeap_Describe                         0x1
  34. #undef  OSHeap_Alloc
  35. #define OSHeap_Alloc                            0x2
  36. #undef  OSHeap_Free
  37. #define OSHeap_Free                             0x3
  38. #undef  OSHeap_Realloc
  39. #define OSHeap_Realloc                          0x4
  40. #undef  OSHeap_Resize
  41. #define OSHeap_Resize                           0x5
  42. #undef  OSHeap_ReadSize
  43. #define OSHeap_ReadSize                         0x6
  44.  
  45. /************************
  46.  * Constant definitions *
  47.  ************************/
  48. #define error_HEAP_BAD_REASON                   0x180u
  49. #define error_HEAP_INIT                         0x181u
  50. #define error_HEAP_BAD_DESC                     0x182u
  51. #define error_HEAP_BAD_LINK                     0x183u
  52. #define error_HEAP_ALLOC                        0x184u
  53. #define error_HEAP_NOT_ABLOCK                   0x185u
  54. #define error_HEAP_BAD_EXTEND                   0x186u
  55. #define error_HEAP_EXCESSIVE_SHRINK             0x187u
  56. #define error_HEAP_HEAP_LOCKED                  0x188u
  57.  
  58. /*************************
  59.  * Function declarations *
  60.  *************************/
  61.  
  62. #ifdef __cplusplus
  63.    extern "C" {
  64. #endif
  65.  
  66. /*************************************************************
  67.  * NOTE: The following functions provide direct access to    *
  68.  *       the SWI's noted in the function description.        *
  69.  *       Please read the relevant PRM section for more       *
  70.  *       information on their input/output parameters.       *
  71.  *************************************************************/
  72.  
  73. /* ------------------------------------------------------------------------
  74.  * Function:      osheap_initialise()
  75.  *
  76.  * Description:   Initialises a heap
  77.  *
  78.  * Input:         heap - value of R1 on entry
  79.  *                size - value of R3 on entry
  80.  *
  81.  * Other notes:   Calls SWI 0x1D with R0 = 0x0.
  82.  */
  83.  
  84. extern os_error *xosheap_initialise (byte *heap,
  85.       int size);
  86. extern void osheap_initialise (byte *heap,
  87.       int size);
  88.  
  89. /* ------------------------------------------------------------------------
  90.  * Function:      osheap_describe()
  91.  *
  92.  * Description:   Describes a heap
  93.  *
  94.  * Input:         heap - value of R1 on entry
  95.  *
  96.  * Output:        max - value of R2 on exit
  97.  *                free - value of R3 on exit (X version only)
  98.  *
  99.  * Returns:       R3 (non-X version only)
  100.  *
  101.  * Other notes:   Calls SWI 0x1D with R0 = 0x1.
  102.  */
  103.  
  104. extern os_error *xosheap_describe (byte *heap,
  105.       int *max,
  106.       int *free);
  107. extern int osheap_describe (byte *heap,
  108.       int *max);
  109.  
  110. /* ------------------------------------------------------------------------
  111.  * Function:      osheap_alloc()
  112.  *
  113.  * Description:   Gets a heap block
  114.  *
  115.  * Input:         heap - value of R1 on entry
  116.  *                size - value of R2 on entry
  117.  *
  118.  * Output:        blk - value of R2 on exit (X version only)
  119.  *
  120.  * Returns:       R2 (non-X version only)
  121.  *
  122.  * Other notes:   Calls SWI 0x1D with R0 = 0x2.
  123.  */
  124.  
  125. extern os_error *xosheap_alloc (byte *heap,
  126.       int size,
  127.       void **blk);
  128. extern void *osheap_alloc (byte *heap,
  129.       int size);
  130.  
  131. /* ------------------------------------------------------------------------
  132.  * Function:      osheap_free()
  133.  *
  134.  * Description:   Frees a heap block
  135.  *
  136.  * Input:         heap - value of R1 on entry
  137.  *                blk - value of R2 on entry
  138.  *
  139.  * Other notes:   Calls SWI 0x1D with R0 = 0x3.
  140.  */
  141.  
  142. extern os_error *xosheap_free (byte *heap,
  143.       void *blk);
  144. extern void osheap_free (byte *heap,
  145.       void *blk);
  146.  
  147. /* ------------------------------------------------------------------------
  148.  * Function:      osheap_realloc()
  149.  *
  150.  * Description:   Extends or shrinks a heap block
  151.  *
  152.  * Input:         heap - value of R1 on entry
  153.  *                blk - value of R2 on entry
  154.  *                size_increase - value of R3 on entry
  155.  *
  156.  * Output:        blk_out - value of R2 on exit (X version only)
  157.  *
  158.  * Returns:       R2 (non-X version only)
  159.  *
  160.  * Other notes:   Calls SWI 0x1D with R0 = 0x4.
  161.  */
  162.  
  163. extern os_error *xosheap_realloc (byte *heap,
  164.       void *blk,
  165.       int size_increase,
  166.       void **blk_out);
  167. extern void *osheap_realloc (byte *heap,
  168.       void *blk,
  169.       int size_increase);
  170.  
  171. /* ------------------------------------------------------------------------
  172.  * Function:      osheap_resize()
  173.  *
  174.  * Description:   Extends or shrinks a heap
  175.  *
  176.  * Input:         heap - value of R1 on entry
  177.  *                size_increase - value of R3 on entry
  178.  *
  179.  * Other notes:   Calls SWI 0x1D with R0 = 0x5.
  180.  */
  181.  
  182. extern os_error *xosheap_resize (byte *heap,
  183.       int size_increase);
  184. extern void osheap_resize (byte *heap,
  185.       int size_increase);
  186.  
  187. /* ------------------------------------------------------------------------
  188.  * Function:      osheap_read_size()
  189.  *
  190.  * Description:   Reads a heap block size
  191.  *
  192.  * Input:         heap - value of R1 on entry
  193.  *                blk - value of R2 on entry
  194.  *
  195.  * Output:        size - value of R3 on exit (X version only)
  196.  *
  197.  * Returns:       R3 (non-X version only)
  198.  *
  199.  * Other notes:   Calls SWI 0x1D with R0 = 0x6.
  200.  */
  201.  
  202. extern os_error *xosheap_read_size (byte *heap,
  203.       void *blk,
  204.       int *size);
  205. extern int osheap_read_size (byte *heap,
  206.       void *blk);
  207.  
  208. #ifdef __cplusplus
  209.    }
  210. #endif
  211.  
  212. #endif
  213.