home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / mesch12a.zip / meminfo.h < prev    next >
C/C++ Source or Header  |  1994-01-13  |  4KB  |  156 lines

  1.  
  2. /**************************************************************************
  3. **
  4. ** Copyright (C) 1993 David E. Steward & Zbigniew Leyk, all rights reserved.
  5. **
  6. **                 Meschach Library
  7. ** 
  8. ** This Meschach Library is provided "as is" without any express 
  9. ** or implied warranty of any kind with respect to this software. 
  10. ** In particular the authors shall not be liable for any direct, 
  11. ** indirect, special, incidental or consequential damages arising 
  12. ** in any way from use of the software.
  13. ** 
  14. ** Everyone is granted permission to copy, modify and redistribute this
  15. ** Meschach Library, provided:
  16. **  1.  All copies contain this copyright notice.
  17. **  2.  All modified copies shall carry a notice stating who
  18. **      made the last modification and the date of such modification.
  19. **  3.  No charge is made for this software or works derived from it.  
  20. **      This clause shall not be construed as constraining other software
  21. **      distributed on the same medium as this software, nor is a
  22. **      distribution fee considered a charge.
  23. **
  24. ***************************************************************************/
  25.  
  26.  
  27. /* meminfo.h  26/08/93 */
  28. /* changed  11/12/93 */
  29.  
  30.  
  31. #ifndef MEM_INFOH
  32. #define MEM_INFOH
  33.  
  34.  
  35.  
  36. /* for hash table in mem_stat.c */
  37. /* Note: the hash size should be a prime, or at very least odd */
  38. #define MEM_HASHSIZE         509
  39. #define MEM_HASHSIZE_FILE    "meminfo.h"
  40.  
  41.  
  42. /* default: memory information is off */
  43. /* set it to 1 if you want it all the time */
  44. #define MEM_SWITCH_ON_DEF    0
  45.  
  46.  
  47. /* available standard types */
  48. #define TYPE_NULL              (-1)
  49. #define TYPE_MAT                0
  50. #define TYPE_BAND               1
  51. #define TYPE_PERM        2
  52. #define TYPE_VEC        3
  53. #define TYPE_IVEC        4
  54.  
  55. #ifdef SPARSE
  56. #define TYPE_ITER        5
  57. #define TYPE_SPROW              6
  58. #define TYPE_SPMAT        7
  59. #endif
  60.  
  61. #ifdef COMPLEX
  62. #ifdef SPARSE
  63. #define TYPE_ZVEC        8
  64. #define TYPE_ZMAT        9
  65. #else
  66. #define TYPE_ZVEC        5
  67. #define TYPE_ZMAT        6
  68. #endif
  69. #endif
  70.  
  71. /* structure for memory information */
  72. typedef struct {
  73.    long bytes;       /* # of allocated bytes for each type (summary) */
  74.    int  numvar;      /* # of allocated variables for each type */
  75. } MEM_ARRAY;
  76.  
  77.  
  78.  
  79. #ifdef ANSI_C
  80.  
  81. int  mem_info_is_on(void);
  82. int mem_info_on(int sw);
  83.  
  84. long mem_info_bytes(int type,int list);
  85. int mem_info_numvar(int type,int list);
  86. void mem_info_file(FILE * fp,int list);
  87.  
  88. void mem_bytes_list(int type,int old_size,int new_size,
  89.                int list);
  90. void mem_numvar_list(int type, int num, int list);
  91.  
  92. int mem_stat_reg_list(void **var,int type,int list);
  93. int mem_stat_mark(int mark);
  94. int mem_stat_free_list(int mark,int list);
  95. int mem_stat_show_mark(void);
  96. void mem_stat_dump(FILE *fp,int list);
  97. int mem_attach_list(int list,int ntypes,char *type_names[],
  98.     int (*free_funcs[])(), MEM_ARRAY info_sum[]);
  99. int mem_free_vars(int list);
  100. int mem_is_list_attached(int list);
  101. void mem_dump_list(FILE *fp,int list);
  102. int mem_stat_reg_vars(int list,int type,...);
  103.  
  104. #else
  105. int mem_info_is_on();
  106. int mem_info_on();
  107.  
  108. long mem_info_bytes();
  109. int mem_info_numvar();
  110. void mem_info_file();
  111.  
  112. void mem_bytes_list();
  113. void mem_numvar_list();
  114.  
  115. int mem_stat_reg_list();
  116. int mem_stat_mark();
  117. int mem_stat_free_list();
  118. int mem_stat_show_mark();
  119. void mem_stat_dump();
  120. int mem_attach_list();
  121. int mem_free_vars();
  122. int mem_is_list_attached();
  123. void mem_dump_list();
  124. int mem_stat_reg_vars();
  125.  
  126. #endif 
  127.  
  128. /* macros */
  129.  
  130. #define mem_info()   mem_info_file(stdout,0)
  131.  
  132. #define mem_stat_reg(var,type)  mem_stat_reg_list((void **)var,type,0)
  133. #define MEM_STAT_REG(var,type)  mem_stat_reg_list((void **)&(var),type,0)
  134. #define mem_stat_free(mark)   mem_stat_free_list(mark,0)
  135.  
  136. #define mem_bytes(type,old_size,new_size)  \
  137.   mem_bytes_list(type,old_size,new_size,0)
  138.  
  139. #define mem_numvar(type,num) mem_numvar_list(type,num,0)
  140.  
  141.  
  142. /* internal type */
  143.  
  144. typedef struct {
  145.    char **type_names;        /* array of names of types (strings) */
  146.    int  (**free_funcs)();    /* array of functions for releasing types */
  147.    unsigned ntypes;          /* max number of types */
  148.    MEM_ARRAY *info_sum;      /* local array for keeping track of memory */
  149. } MEM_CONNECT;
  150.  
  151. /* max number of lists of types */
  152. #define MEM_CONNECT_MAX_LISTS    5
  153.  
  154.  
  155. #endif
  156.