source: git/omalloc/omDefaultConfig.h @ 9cf75aa

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