source: git/misc/auxiliary.h.in @ 044f7b

spielwiese
Last change on this file since 044f7b was 51372b, checked in by Hans Schoenemann <hannes@…>, 14 years ago
default: HAVE_FACTORY
  • Property mode set to 100644
File size: 10.1 KB
Line 
1/*****************************************************************************\
2 * Computer Algebra System SINGULAR   
3\*****************************************************************************/
4/** @file auxiliary.h
5 *
6 * All the auxiliary stuff.
7 *
8 * ABSTRACT: we shall put here everything that does not have its own place.
9 *
10 * @author Oleksandr Motsak
11 *
12 * @internal @version \$Id$
13 *
14 **/
15/*****************************************************************************/
16
17#ifndef MISC_AUXILIARY_H
18#define MISC_AUXILIARY_H
19     
20// ----------------- which parts/extensions of Singular to build
21#define HAVE_RINGS
22#define HAVE_FACTORY
23// ----------------  end of parts/extensions
24// -----------------  configure stuff
25
26/* CPU type: i[3456]86: */
27#undef SI_CPU_I386
28/* CPU type: sparc: */
29#undef SI_CPU_SPARC
30/* CPU type: ppc: */
31#undef SI_CPU_PPC
32/* CPU type: IA64: */
33#undef SI_CPU_IA64
34/* CPU type: x86_64: */
35#undef SI_CPU_X86_64
36
37/* Define sizeof(long) */
38#define SIZEOF_LONG 4
39
40/* Define version as a string */
41#define S_VERSION1 "spielwiese"
42
43/* Absolute pathname of root directory of Singular source */
44#define S_ROOT_DIR ""
45
46
47// ----------------- end of configure stuff
48
49// ---------------- Singular standard types etc.
50// BOOLEAN
51
52#if (SIZEOF_LONG == 8)
53typedef int BOOLEAN;
54/* testet on x86_64, gcc 3.4.6: 2 % */
55/* testet on IA64, gcc 3.4.6: 1 % */
56#else
57/* testet on athlon, gcc 2.95.4: 1 % */
58typedef short BOOLEAN;
59#endif
60
61#ifndef FALSE
62#define FALSE       0
63#endif
64
65#ifndef TRUE
66#define TRUE        1
67#endif
68
69#ifndef NULL
70#define NULL        (0)
71#endif
72
73// #ifdef _TRY
74#ifndef ABS
75#define ABS(x) ((x)<0?(-(x)):(x))
76#endif
77// #endif
78
79static const int MAX_INT_LEN= 11;
80typedef void* ADDRESS;
81
82#define loop for(;;)
83
84static inline int si_max(const int a, const int b)  { return (a>b) ? a : b; }
85
86// ---------------- end of Singular standard types etc.
87// ---------------- defines which depend on the settings above
88
89#if defined(SI_CPU_I386) || defined(SI_CPU_X86_64)
90  // the following settings seems to be better on i386 and x86_64 processors
91  // define if a*b is with mod instead of tables
92#define HAVE_MULT_MOD
93  // #define HAVE_GENERIC_ADD
94  // #ifdef HAVE_MULT_MOD
95  // #define HAVE_DIV_MOD
96  // #endif
97#elif defined(SI_CPU_IA64)
98  // the following settings seems to be better on itanium processors
99  // #define HAVE_MULT_MOD
100#define HAVE_GENERIC_ADD
101  // #ifdef HAVE_MULT_MOD
102  // #define HAVE_DIV_MOD
103  // #endif
104#elif defined(SI_CPU_SPARC)
105  // #define HAVE_GENERIC_ADD
106#define HAVE_MULT_MOD
107#ifdef HAVE_MULT_MOD
108#define HAVE_DIV_MOD
109#endif
110#elif defined(SI_CPU_PPC)
111  // the following settings seems to be better on ppc processors
112  // testet on: ppc_Linux, 740/750 PowerMac G3, 512k L2 cache
113#define HAVE_MULT_MOD
114  // #ifdef HAVE_MULT_MOD
115  // #define HAVE_DIV_MOD
116  // #endif
117#endif
118
119
120/*******************************************************************
121 * DEBUG OPTIONS
122 * -- only significant for for compiling without -DNDEBUG
123 * -- you better know what your are doing, if you touch this
124 ******************************************************************/
125#ifndef NDEBUG
126
127/* undefine to enable inline */
128#define NO_INLINE
129
130/* undefine to disable assume -- should normally be defined for NDEBUG */
131#define HAVE_ASSUME
132
133/* undef PDEBUG to disable checks of polys
134
135 define PDEBUG to
136  0 for enabling pTest
137  1 plus tests in Level 1 poly routines (operations on monomials)
138  2 plus tests in Level 2 poly routines (operations on single exponents)
139 -- see also polys.h for more info
140
141 NOTE: you can set the value of PDEBUG on a per-file basis, before
142       including mod2.h, provided ! PDEBUG is defined in mod2.h E.g.:
143
144       #define PDEBUG 2
145       #include "auxiliary.h"
146       ...
147
148       makes sure that all poly operations in your file are done with
149       PDEBUG == 2
150 To break after an error occured, set a debugger breakpoint on
151 dErrorBreak.
152*/
153#ifndef PDEBUG
154#define PDEBUG 0
155#endif
156
157/* define MDEBUG to enable memory checks */
158#define MDEBUG 0
159
160#ifdef MDEBUG
161/* If ! defined(OM_NDEBUG) and (defined(OM_TRACK) or defined(OM_CHECK)
162   then omDebug routines are used for memory allocation/free:
163
164   The omDebug routines are controlled by the values of OM_TRACK, OM_CHECK
165   and OM_KEEP.  There meaning is roughly as follows:
166   OM_TRACK: strored with address                              : extra space
167     0     : no additional info is stored                      : 0
168     1     : file:line of location where address was allocated : 1 word
169     2     : plus backtrace of stack where adress was allocated: 6 words
170     3     : plus size/bin info and front-, and back padding   : 9 words
171     4     : plus file:line of location where adress was freed : 10 words
172     5     : plus backtrace of stack where adress was allocated: 15 words
173   OM_CHECK: checks done
174     0     : no checks
175     1     : constant-time checks: i.e. addr checks only
176     2     : plus linear-time checks and constant related bin check
177     3     : plus quadratic-time checks and linear-time related bin checks and
178             constant time all memory checks
179     4     : and so on
180     ==> for OM_CHECK >= 3 it gets rather slow
181   OM_KEEP:  determines whether addresses are really freed  (
182     0     : addresses are really freed
183     1     : addresses are only marked as free and not really freed.
184
185   OM_CHECK, OM_TRACK, and OM_KEEP can be set on a per-file basis
186   (as can OM_NDEBUG),  e.g.:
187     #define OM_CHECK 3
188     #define OM_TRACK 5
189     #define OM_KEEP  1
190     #include "mod2.h"
191     #include "omalloc.h"
192   ensures that all memory allocs/free in this file are done with
193   OM_CHECK==3 and OM_TRACK==5, and that all addresses allocated/freed
194   in this file are only marked as free and never really freed.
195 
196   To set OM_CHECK, OM_TRACK and OM_KEEP under dynamic scope, set
197   om_Opts.MinCheck, om_Opts.MinTrack to the respectiv values and
198   om_Opts.Keep to the number of addresses which are kept before they are
199   actually freed. E.g.:
200     int check=om_Opts.MinCheck, track=om_Opts.MinTrack, keep= m_OPts.Keep;
201     om_Opts.MinCheck = 3; om_Opts.MinTrack = 5; omOpts.Keep = LONG_MAX;
202     ExternalRoutine();
203     om_Opts.MinCheck = check; omOpts.MinTrack = track; omOpts.Keep = keep;
204   ensures that all calls omDebug routines  occuring during the computation of
205   ExternalRoutine() are done with OM_CHECK==3 and OM_TRACK==5, and
206   calls to omFree only mark addresses as free and not really free them.
207
208   Furthermore, the value of OM_SING_KEEP (resp. om_Opts.Keep) specifies
209   how many addresses are kept before they are actually freed, independently
210   of the value of OM_KEEP.
211
212   Some tips on possible values of OM_TRACK, OM_CHECK, OM_KEEP:
213   + To find out about an address that has been freed twice, first locate the
214     file(s) where the error occured, and then at the beginning of these files:
215       #define OM_CHECK 3
216       #define OM_TRACK 5
217       #define OM_KEEP  1
218       #include "mod2.h"
219       #include "omalloc.h"
220     Under dynamic scope, do (e.g., from within the debugger):
221       om_Opts.MinCheck = 3; om_Opts.MinTrack = 5; omOpts.Keep = LONG_MAX;
222   + to find out where "memory corruption" occured, increase value of
223     OM_CHECK - the higher this value is, the more consistency checks are
224     done (However a value > 3 checks the entire memory each time an omalloc
225     routine is used!)
226   
227   Some more tips on the usage of omalloc:
228   + omAlloc*, omRealloc*, omFree*, omCheck* omDebug* omTest* rotuines
229     assume that sizes are > 0 and pointers are != NULL
230   + omalloc*, omrealloc*, omfree* omcheck*, omdebug* omtest* routines allow
231     NULL pointers and sizes == 0
232   + You can safely use any free/realloc routine in combination with any alloc
233     routine (including the debug versions): E.g., an address allocated with
234     omAllocBin can be freed with omfree, or an adress allocated with
235     om(Debug)Alloc can be freed with omfree, or omFree, or omFreeSize, etc.
236     However, keep in mind that the efficiency decreases from
237     Bin over Size to General routines (i.e., omFreeBin is more efficient than
238     omFreeSize which is more efficient than omFree, likewise with the alloc
239     routines).
240   + if OM_CHECK is undefined or 0, then all omCheck routines do nothing
241   + if OM_CHECK and OM_TRACK are both undefined (or 0), or if OM_NDEBUG is
242     defined, then the "real" alloc/realloc/free macros are used, and all
243     omTest, omDebug and omCheck routines are undefined
244   + to break after an omError occured within a debugger,
245     set a breakpoint on dErrorBreak
246   + to do checks from within the debugger, or to do checks with explicit
247     check level, use omTest routines.
248*/
249
250/* by default, store alloc info and file/line where addr was freed */
251#ifndef OM_TRACK
252#define OM_TRACK 4
253#endif
254/* only do constant-time memory checks */
255#ifndef OM_CHECK
256#define OM_CHECK 1
257#endif
258/* Do actually free memory:
259   (be careful: if this is set, memory is never really freed,
260    but only marked as free) */
261#ifndef OM_KEEP
262#define OM_KEEP 0
263#endif
264/* but only after you have freed 1000 more addresses
265   (this is actually independent of the value of OM_KEEP and used
266   to initialize om_Opts.Keep) */
267#ifndef OM_SING_KEEP
268#define OM_SING_KEEP 1000
269#endif
270
271#endif /* MDEBUG */
272
273
274/* undef KDEBUG for check of data during std computations
275 *
276 * define KDEBUG to
277 * 0 for basic tests
278 * 1 for tests in kSpoly
279 * NOTE: You can locally enable tests in kspoly by setting the
280 *       define at the beginning of kspoly.cc
281 */
282#define KDEBUG 0
283
284/* define LDEBUG checking numbers, undefine otherwise */
285#define LDEBUG
286/* define RDEBUG checking rings (together with TRACE=9) */
287#define RDEBUG
288/* define TEST for non time critical tests, undefine otherwise */
289#define TEST
290
291/* define YYDEBUG 1 for debugging bison texts, 0 otherwise */
292#define YYDEBUG 1
293
294#endif
295/* end of debugging option (ifndef NDEBUG) */
296
297
298
299#ifdef _DEBUG
300#      define FORCEINLINE inline
301#else
302#ifdef NDEBUG
303#if   defined(_MSC_VER)
304#      define FORCEINLINE __forceinline
305#elif defined(__GNUC__) && __GNUC__ > 3
306#      define FORCEINLINE inline __attribute__ ((always_inline))
307#else
308#      define FORCEINLINE inline
309#endif
310#else
311#      define FORCEINLINE inline
312#endif
313/* NDEBUG */
314#endif
315/* _DEBUG */
316
317
318
319#endif
320/* MISC_AUXILIARY_H */
321
Note: See TracBrowser for help on using the repository browser.