source: git/omalloc/omDefaultConfig.h @ b6e039

spielwiese
Last change on this file since b6e039 was b6e039, checked in by Olaf Bachmann <obachman@…>, 24 years ago
* added stuff git-svn-id: file:///usr/local/Singular/svn/trunk@4519 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 6.7 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 *  Version: $Id: omDefaultConfig.h,v 1.1 2000-08-14 12:18:28 obachman 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 <limits.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/* If this is greater than 0, then the omDebugFree omDebugRealloc delay freeing memory
45   by that many blocks: Initalizes omOpts.Keep
46   Setting this to LONG_MAX never frees memory */
47#ifndef OM_DEFAULT_KEEP
48#define OM_DEFAULT_KEEP 0
49#endif
50
51/* If this is set to
52   0: errors are not reported, only the global variable om_ErrorStatus is set
53   1: short error description, i.e. omError2String(om_ErrorStatus), is reported to stderr
54   2: backtrace of current stack is printed to stderr
55   3: more detailed error description is printed -- this might not make too much sense if
56      you are not familiar with omalloc
57   Initializes om_Opts.HowToReprotErrors
58*/
59#ifndef OM_DEFAULT_HOW_TO_REPORT_ERRORS
60#if defined(OM_INTERNAL_DEBUG)
61#define OM_DEFAULT_HOW_TO_REPORT_ERRORS 3
62#else
63#define OM_DEFAULT_HOW_TO_REPORT_ERRORS 2
64#endif
65#endif
66
67/* if this is set, then all memory allocated with track >= 1 is marked as
68   static, i.e. it is not mention in omPrintUsedAddrs */
69#ifndef OM_DEFAULT_MARK_AS_STATIC
70#define OM_DEFAULT_MARK_AS_STATIC 0
71#endif
72
73/* Number of pages per region, i.e., how many pages are allocated at once, after we
74   run out of pages: Initalizes om_Opts.PagesPerRegion
75   The higher this value is, the fewer calls to valloc (resp. mmap) need to be make,
76   but the more unused memory the application might have allocated from the operating system
77*/
78#ifndef OM_DEFAULT_PAGES_PER_REGION
79#define OM_DEFAULT_PAGES_PER_REGION 128
80#endif
81
82/* This is called if nothing goes any more, i.e., if
83   memory request can not be serviced. If set, this function should never return.*/
84#ifndef OM_DEFAULT_OUT_OF_MEMORY_FUNC
85/* This initalizes om_Opts.OutOfMemoryFunc which is declared as
86   void (*OutOfMemoryFunc)(); */
87#define OM_DEFAULT_OUT_OF_MEMORY_FUNC NULL
88#endif
89#ifndef OM_OUT_OF_MEMORY_HOOK
90#define OM_OUT_OF_MEMORY_HOOK()                             \
91do                                                          \
92{                                                           \
93  if (om_Opts.OutOfMemoryFunc != NULL)                      \
94    om_Opts.OutOfMemoryFunc();                              \
95   fprintf(stderr, "***Emergency Exit: Out of Memory\n");   \
96   exit(1);                                                 \
97}                                                           \
98while (0)
99#endif
100 
101/* This is called whenever no more memory could be obtained from the system.
102   It should trigger the release of as much memory by the application as possible */
103#ifndef OM_DEFAULT_MEMORY_LOW_FUNC
104/* This initalizes om_Opts.MemoryLowFunc which is declared as
105   void (*MemoryLowFunc)(); */
106#define OM_DEFAULT_MEMORY_LOW_FUNC NULL
107#endif
108#ifndef OM_DEFAULT_MEMORY_LOW_HOOK
109#define OM_MEMORY_LOW_HOOK()                    \
110do                                              \
111{                                               \
112  if (om_Opts.MemoryLowFunc != NULL)            \
113    om_Opts.MemoryLowFunc();                    \
114}                                               \
115while(0)
116#endif
117
118
119/********************************************************************
120 *
121 * The following can NOT be set at run time
122 *
123 ********************************************************************/
124/* The following hooks are called after the respective
125   system routine was called, and the Stats struct was updated
126   Not settable at run-time (makes no sense for thise to be functions, for they would
127   be called each time the underlying malloc/valloc is called !) */
128#ifndef OM_MALLOC_HOOK
129#define OM_MALLOC_HOOK(size) ((void)0)
130#endif
131#ifndef OM_REALLOC_HOOK
132#define OM_REALLOC_HOOK(oldsize, newsize) ((void)0)
133#endif
134#ifndef OM_VALLOC_HOOK
135#define OM_VALLOC_HOOK(size) ((void)0)
136#endif
137#ifndef OM_FREE_HOOK
138#define OM_FREE_HOOK(size) ((void)0)
139#endif
140#ifndef OM_VFREE_HOOK
141#define OM_VFREE_HOOK(size) ((void)0)
142#endif
143#ifndef OM_ALLOC_BINPAGE_HOOK
144#define OM_ALLOC_BINPAGE_HOOK ((void)0)
145#endif
146#ifndef OM_FREE_BINPAGE_HOOK
147#define OM_FREE_BINPAGE_HOOK ((void)0)
148#endif
149
150/*
151 * Some stuff related to tracking of addresses
152 */
153
154/* minimal number of WORDS for padding before addr: needs to > 0: only relevant for track >= 3 */
155#ifndef OM_MIN_SIZEWOF_FRONT_PATTERN
156#define OM_MIN_SIZEWOF_FRONT_PATTERN 1
157#endif
158
159/* minimal number of WORDS for padding before addr: needs to > 0: only relevant for track >= 3 */
160#ifndef OM_MIN_SIZEWOF_BACK_PATTERN
161#define OM_MIN_SIZEWOF_BACK_PATTERN 1
162#endif
163
164/* maximal number of stack frames kept for stack at the allocation time of addr (track >= 2)
165   and free time of addr (track >= 5) */
166#ifndef OM_MAX_KEPT_FRAMES
167#define OM_MAX_KEPT_FRAMES 5
168#endif
169
170/* pattern with which memory is initalized, for front and back padding,
171   and for free memory: only relevant if track >= 3*/
172#ifndef OM_INIT_PATTERN
173#define OM_INIT_PATTERN    0xfe
174#endif
175#ifndef OM_FRONT_PATTERN
176#define OM_FRONT_PATTERN   0xfd
177#endif
178#ifndef OM_BACK_PATTERN
179#define OM_BACK_PATTERN    0xfc
180#endif
181#ifndef OM_FREE_PATTERN
182#define OM_FREE_PATTERN    0xfb
183#endif
184
185
186
Note: See TracBrowser for help on using the repository browser.