1 | /******************************************************************* |
---|
2 | * File: omDefaultConfig.h |
---|
3 | * Purpose: default declaration of of configurable stuff |
---|
4 | * Author: obachman (Olaf Bachmann) |
---|
5 | * Created: 11/99 |
---|
6 | * Version: $Id: omDefaultConfig.h,v 1.8 2001-04-30 09:02:05 Singular Exp $ |
---|
7 | *******************************************************************/ |
---|
8 | |
---|
9 | /******************************************************************** |
---|
10 | If you want to make changes to any of these defines, create a file, |
---|
11 | say, MyOmConfig.h, define your particular stuff there, and run configure with |
---|
12 | --external-config-h=MyOmConfig.h. |
---|
13 | |
---|
14 | If you also need to implement something, then implement it in, say, |
---|
15 | MyOmConfig.c, and run configure with |
---|
16 | --external-config-h=MyOmConfig.h --external-config-c=MyOmConfig.c |
---|
17 | |
---|
18 | For omTest to link, you need to make sure that your implementation can also be |
---|
19 | used when not linked with your application. I.e. you should also provide a |
---|
20 | stand-alone implementation if OM_STANDALONE is defined. |
---|
21 | |
---|
22 | Notice that some of these parameters can also be set at run-time, using |
---|
23 | the global om_Opts struct. |
---|
24 | ********************************************************************/ |
---|
25 | #include <mylimits.h> |
---|
26 | #include "omConfig.h" |
---|
27 | /* if external config was provided, 'make' makes links from it to omExternalConfig.h */ |
---|
28 | #ifdef OM_HAVE_EXTERNAL_CONFIG_H |
---|
29 | #include "omExternalConfig.h" |
---|
30 | #endif |
---|
31 | |
---|
32 | /* If this is larger than the track parameter given to the omDebug routines, |
---|
33 | then this is used as TrackLevel: om_Opts.MinTrack is initalized with this */ |
---|
34 | #ifndef OM_DEFAULT_MIN_TRACK |
---|
35 | #define OM_DEFAULT_MIN_TRACK 0 |
---|
36 | #endif |
---|
37 | |
---|
38 | /* If this is larger than the check parameter given to the omDebug routines, |
---|
39 | then this is used as CheckLevel: om_Opts.MinCheck is initalized with this */ |
---|
40 | #ifndef OM_DEFAULT_MIN_CHECK |
---|
41 | #define OM_DEFAULT_MIN_CHECK 0 |
---|
42 | #endif |
---|
43 | |
---|
44 | /* MAX options. If Max < Min, then Max value is used. */ |
---|
45 | /* If this is smaller than the track parameter given to the omDebug routines, |
---|
46 | then this is used as TrackLevel: om_Opts.MaxTrack is initalized with this */ |
---|
47 | #ifndef OM_DEFAULT_MAX_TRACK |
---|
48 | #define OM_DEFAULT_MAX_TRACK 5 |
---|
49 | #endif |
---|
50 | |
---|
51 | /* If this is smaller than the check parameter given to the omDebug routines, |
---|
52 | then this is used as CheckLevel: om_Opts.MaxCheck is initalized with this */ |
---|
53 | #ifndef OM_DEFAULT_MAX_CHECK |
---|
54 | #define OM_DEFAULT_MAX_CHECK 10 |
---|
55 | #endif |
---|
56 | |
---|
57 | /* If this is greater than 0, then the omDebugFree omDebugRealloc delay freeing memory |
---|
58 | by that many blocks: Initalizes omOpts.Keep |
---|
59 | Setting this to LONG_MAX never frees memory */ |
---|
60 | #ifndef OM_DEFAULT_KEEP |
---|
61 | #define OM_DEFAULT_KEEP 100 |
---|
62 | #endif |
---|
63 | |
---|
64 | /* If this is set to |
---|
65 | 0: errors are not reported, only the global variable om_ErrorStatus is set |
---|
66 | 1: short error description, i.e. omError2String(om_ErrorStatus), is reported to stderr |
---|
67 | 2: backtrace of current stack is printed to stderr |
---|
68 | 3: more detailed error description is printed -- this might not make too much sense if |
---|
69 | you are not familiar with omalloc |
---|
70 | Initializes om_Opts.HowToReprotErrors |
---|
71 | */ |
---|
72 | #ifndef OM_DEFAULT_HOW_TO_REPORT_ERRORS |
---|
73 | #if defined(OM_INTERNAL_DEBUG) |
---|
74 | #define OM_DEFAULT_HOW_TO_REPORT_ERRORS 3 |
---|
75 | #else |
---|
76 | #define OM_DEFAULT_HOW_TO_REPORT_ERRORS 2 |
---|
77 | #endif |
---|
78 | #endif |
---|
79 | |
---|
80 | /* if this is set, then all memory allocated with track >= 1 is marked as |
---|
81 | static, i.e. it is not mention in omPrintUsedAddrs */ |
---|
82 | #ifndef OM_DEFAULT_MARK_AS_STATIC |
---|
83 | #define OM_DEFAULT_MARK_AS_STATIC 0 |
---|
84 | #endif |
---|
85 | |
---|
86 | /* Number of pages per region, i.e., how many pages are allocated at once, after we |
---|
87 | run out of pages: Initalizes om_Opts.PagesPerRegion |
---|
88 | The higher this value is, the fewer calls to valloc (resp. mmap) need to be make, |
---|
89 | but the more unused memory the application might have allocated from the operating system |
---|
90 | */ |
---|
91 | #ifndef OM_DEFAULT_PAGES_PER_REGION |
---|
92 | #define OM_DEFAULT_PAGES_PER_REGION 128 |
---|
93 | #endif |
---|
94 | |
---|
95 | /* This is called if nothing goes any more, i.e., if |
---|
96 | memory request can not be serviced. If set, this function should never return.*/ |
---|
97 | #ifndef OM_DEFAULT_OUT_OF_MEMORY_FUNC |
---|
98 | /* This initalizes om_Opts.OutOfMemoryFunc which is declared as |
---|
99 | void (*OutOfMemoryFunc)(); */ |
---|
100 | #define OM_DEFAULT_OUT_OF_MEMORY_FUNC NULL |
---|
101 | #endif |
---|
102 | #ifndef OM_OUT_OF_MEMORY_HOOK |
---|
103 | #define OM_OUT_OF_MEMORY_HOOK() \ |
---|
104 | do \ |
---|
105 | { \ |
---|
106 | if (om_Opts.OutOfMemoryFunc != NULL) \ |
---|
107 | om_Opts.OutOfMemoryFunc(); \ |
---|
108 | fprintf(stderr, "***Emergency Exit: Out of Memory\n"); \ |
---|
109 | exit(1); \ |
---|
110 | } \ |
---|
111 | while (0) |
---|
112 | #endif |
---|
113 | |
---|
114 | /* This is called whenever no more memory could be obtained from the system. |
---|
115 | It should trigger the release of as much memory by the application as possible */ |
---|
116 | #ifndef OM_DEFAULT_MEMORY_LOW_FUNC |
---|
117 | /* This initalizes om_Opts.MemoryLowFunc which is declared as |
---|
118 | void (*MemoryLowFunc)(); */ |
---|
119 | #define OM_DEFAULT_MEMORY_LOW_FUNC NULL |
---|
120 | #endif |
---|
121 | #ifndef OM_DEFAULT_MEMORY_LOW_HOOK |
---|
122 | #define OM_MEMORY_LOW_HOOK() \ |
---|
123 | do \ |
---|
124 | { \ |
---|
125 | if (om_Opts.MemoryLowFunc != NULL) \ |
---|
126 | om_Opts.MemoryLowFunc(); \ |
---|
127 | } \ |
---|
128 | while(0) |
---|
129 | #endif |
---|
130 | |
---|
131 | /* This is called after an omError was reported. |
---|
132 | It is especially useful to set a debugger breakpoint |
---|
133 | to this func */ |
---|
134 | #ifndef OM_DEFAULT_ERROR_HOOK |
---|
135 | #define OM_DEFAULT_ERROR_HOOK omErrorBreak |
---|
136 | #endif |
---|
137 | |
---|
138 | /******************************************************************** |
---|
139 | * |
---|
140 | * The following can NOT be set at run time |
---|
141 | * |
---|
142 | ********************************************************************/ |
---|
143 | /* The following hooks are called after the respective |
---|
144 | system routine was called, and the Stats struct was updated |
---|
145 | Not settable at run-time (makes no sense for thise to be functions, for they would |
---|
146 | be called each time the underlying malloc/valloc is called !) */ |
---|
147 | #ifndef OM_MALLOC_HOOK |
---|
148 | #define OM_MALLOC_HOOK(size) ((void)0) |
---|
149 | #endif |
---|
150 | #ifndef OM_REALLOC_HOOK |
---|
151 | #define OM_REALLOC_HOOK(oldsize, newsize) ((void)0) |
---|
152 | #endif |
---|
153 | #ifndef OM_VALLOC_HOOK |
---|
154 | #define OM_VALLOC_HOOK(size) ((void)0) |
---|
155 | #endif |
---|
156 | #ifndef OM_FREE_HOOK |
---|
157 | #define OM_FREE_HOOK(size) ((void)0) |
---|
158 | #endif |
---|
159 | #ifndef OM_VFREE_HOOK |
---|
160 | #define OM_VFREE_HOOK(size) ((void)0) |
---|
161 | #endif |
---|
162 | #ifndef OM_ALLOC_BINPAGE_HOOK |
---|
163 | #define OM_ALLOC_BINPAGE_HOOK ((void)0) |
---|
164 | #endif |
---|
165 | #ifndef OM_FREE_BINPAGE_HOOK |
---|
166 | #define OM_FREE_BINPAGE_HOOK ((void)0) |
---|
167 | #endif |
---|
168 | |
---|
169 | /* |
---|
170 | * Some stuff related to tracking of addresses |
---|
171 | */ |
---|
172 | |
---|
173 | /* minimal number of WORDS for padding before addr: needs to > 0: only relevant for track >= 3 */ |
---|
174 | #ifndef OM_MIN_SIZEWOF_FRONT_PATTERN |
---|
175 | #define OM_MIN_SIZEWOF_FRONT_PATTERN 1 |
---|
176 | #endif |
---|
177 | |
---|
178 | /* minimal number of WORDS for padding before addr: needs to > 0: only relevant for track >= 3 */ |
---|
179 | #ifndef OM_MIN_SIZEWOF_BACK_PATTERN |
---|
180 | #define OM_MIN_SIZEWOF_BACK_PATTERN 1 |
---|
181 | #endif |
---|
182 | |
---|
183 | /* maximal number of stack frames kept for stack at the allocation time of addr (track >= 2) |
---|
184 | and free time of addr (track >= 5) */ |
---|
185 | #ifndef OM_MAX_KEPT_FRAMES |
---|
186 | #define OM_MAX_KEPT_FRAMES 5 |
---|
187 | #endif |
---|
188 | |
---|
189 | /* pattern with which memory is initalized, for front and back padding, |
---|
190 | and for free memory: only relevant if track >= 3*/ |
---|
191 | #ifndef OM_INIT_PATTERN |
---|
192 | #define OM_INIT_PATTERN 0xfe |
---|
193 | #endif |
---|
194 | #ifndef OM_FRONT_PATTERN |
---|
195 | #define OM_FRONT_PATTERN 0xfd |
---|
196 | #endif |
---|
197 | #ifndef OM_BACK_PATTERN |
---|
198 | #define OM_BACK_PATTERN 0xfc |
---|
199 | #endif |
---|
200 | #ifndef OM_FREE_PATTERN |
---|
201 | #define OM_FREE_PATTERN 0xfb |
---|
202 | #endif |
---|