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