source: git/kernel/mod2.h @ 91fdef

fieker-DuValspielwiese
Last change on this file since 91fdef was e77add, checked in by Hans Schoenemann <hannes@…>, 13 months ago
changes for 4.3.2p2
  • Property mode set to 100644
File size: 13.1 KB
Line 
1/* -*-c++-*- */
2/*******************************************************************
3 *  Computer Algebra System SINGULAR
4 *
5 *  mod2.h: Main configuration file for Singular
6 *
7 *******************************************************************/
8#ifndef MOD2_H
9#define MOD2_H
10
11/* please include singularconfig.h exclusively via <kernel/mod2.h> and before any other header */
12# include "singularconfig.h"
13# include "misc/auxiliary.h"
14
15#if defined(HAVE_MPFR_H) && defined(HAVE_LIBMPFR)
16#define HAVE_SVD
17#endif
18
19#define SINGULAR_MAJOR_VERSION 4
20#define SINGULAR_MINOR_VERSION 3
21#define SINGULAR_SUB_VERSION 2
22#define SINGULAR_PATCHLEVEL 2
23#define S_ROOT_DIR ""
24
25/*******************************************************************
26 * Defines which are not set by configure
27 ******************************************************************/
28
29/*defines, which should be set by configure */
30#define HAVE_GETTIMEOFDAY 1
31#define TIME_WITH_SYS_TIME 1
32#define HAVE_SYS_TIME_H 1
33/* Default value for timer resolution in ticks per second */
34/* set to 10 for resolution of tenth of a second, etc */
35#define TIMER_RESOLUTION 1
36
37/* Undefine to disable the quote/eval of expressions */
38#define SIQ 1
39
40/* Undefine to disable Gerhard's and Wilfried's fast and dirty std computations */
41#define FAST_AND_DIRTY
42
43/* eigenvalues */
44#define HAVE_EIGENVAL 1
45
46/* Gauss-Manin system */
47#define HAVE_GMS 1
48
49/* include simpleipc/semaphore code, link against librt/libpthread */
50#define HAVE_SIMPLEIPC 1
51
52
53/* linear algebra extensions from pcv.h/pcv.cc */
54#define HAVE_PCV 1
55
56/* procedures to compute with units */
57#define HAVE_UNITS
58
59/* Define to use scanner when loading libraries */
60#define HAVE_LIBPARSER
61
62/* define for parallel processes with shared memory */
63#ifndef __CCYGWIN__
64#if !defined(__MACH__) || !defined(__APPLE__)
65#define HAVE_VSPACE 1
66#endif
67#endif
68
69/*#define PROFILING*/
70#ifdef PROFILING
71#define PROFILER ,0,0
72#else
73#define PROFILER
74#endif
75
76/*******************************************************************
77 * Evaluate the set defines
78 ******************************************************************/
79/* Spectrum needs GMP */
80#define HAVE_SPECTRUM 1
81
82#if SIZEOF_VOIDP == 8
83/* SIZEOF_LONG == SIZEOF_VOIDP is guaranteed by configure */
84#define ALIGN_8
85#endif
86
87#define SINGULAR_VERSION ((SINGULAR_MAJOR_VERSION*1000 + SINGULAR_MINOR_VERSION*100 + SINGULAR_SUB_VERSION*10)+SINGULAR_PATCHLEVEL)
88
89/*******************************************************************
90 * Miscellaneous Defines
91 ******************************************************************/
92#ifndef HAVE_LIBPARSER
93#  undef YYLPDEBUG
94#else
95#  define YYLPDEBUG 1
96#endif
97
98#ifndef FALSE
99#define FALSE       0
100#endif
101
102#ifndef TRUE
103#define TRUE        1
104#endif
105
106#ifndef NULL
107#define NULL        (0)
108#endif
109
110#ifndef SEEK_END
111#define SEEK_END 2
112#endif
113
114#ifndef SEEK_SET
115#define SEEK_SET 0
116#endif
117
118#ifdef __cplusplus
119extern "C" {
120#endif
121void  m2_end(int i);
122#ifdef __cplusplus
123}
124#endif
125
126static inline void HALT(void) { m2_end(2);}
127
128/* define OLD_RES for res/sres/mres(i,j,k) */
129#undef OLD_RES
130
131/* the maximal ascii length of an int number + 1 = 11 for 32 bit int */
132/* #define MAX_INT_LEN 11 */
133
134
135/* define LINKAGE to "extern C" if compiling for shared libs */
136#ifndef LINKAGE
137#if defined(PIC)
138#define LINKAGE extern "C"
139#else
140#define LINKAGE
141#endif
142#endif
143
144
145/*******************************************************************
146 * DEBUG OPTIONS
147 * -- only significant for for compiling without -DSING_NDEBUG
148 * -- you better know what your are doing, if you touch this
149 ******************************************************************/
150#ifndef SING_NDEBUG
151
152/* undefine to enable inline */
153#define NO_INLINE
154
155/* undef PDEBUG to disable checks of polys
156
157 define PDEBUG to
158  0 for enabling pTest
159  1 plus tests in Level 1 poly routines (operations on monomials)
160  2 plus tests in Level 2 poly routines (operations on single exponents)
161 -- see also polys.h for more info
162
163 NOTE: you can set the value of PDEBUG on a per-file basis, before
164       including mod2.h, provided ! PDEBUG is defined in mod2.h E.g.:
165
166       #define PDEBUG 2
167       #include "mod2.h"
168       ...
169
170       makes sure that all poly operations in your file are done with
171       PDEBUG == 2
172 To break after an error occurred, set a debugger breakpoint on
173 dErrorBreak.
174*/
175#ifndef PDEBUG
176#define PDEBUG 0
177#endif
178
179/* define MDEBUG to enable memory checks */
180#define MDEBUG 0
181
182#ifdef MDEBUG
183/* If ! defined(OM_NDEBUG) and (defined(OM_TRACK) or defined(OM_CHECK)
184   then omDebug routines are used for memory allocation/free:
185
186   The omDebug routines are controlled by the values of OM_TRACK, OM_CHECK
187   and OM_KEEP.  There meaning is roughly as follows:
188   OM_TRACK: stored with address                                 : extra space
189     0     : no additional info is stored                        : 0
190     1     : file:line of location where address was allocated   : 1 word
191     2     : plus backtrace of stack where address was allocated : 6 words
192     3     : plus size/bin info and front-, and back padding     : 9 words
193     4     : plus file:line of location where address was freed  : 10 words
194     5     : plus backtrace of stack where address was allocated : 15 words
195   OM_CHECK: checks done
196     0     : no checks
197     1     : constant-time checks: i.e. addr checks only
198     2     : plus linear-time checks and constant related bin check
199     3     : plus quadratic-time checks and linear-time related bin checks and
200             constant time all memory checks
201     4     : and so on
202     ==> for OM_CHECK >= 3 it gets rather slow
203   OM_KEEP:  determines whether addresses are really freed  (
204     0     : addresses are really freed
205     1     : addresses are only marked as free and not really freed.
206
207   OM_CHECK, OM_TRACK, and OM_KEEP can be set on a per-file basis
208   (as can OM_NDEBUG),  e.g.:
209     #define OM_CHECK 3
210     #define OM_TRACK 5
211     #define OM_KEEP  1
212     #include "mod2.h"
213     #include "omalloc/omalloc.h"
214   ensures that all memory allocs/free in this file are done with
215   OM_CHECK==3 and OM_TRACK==5, and that all addresses allocated/freed
216   in this file are only marked as free and never really freed.
217
218   To set OM_CHECK, OM_TRACK and OM_KEEP under dynamic scope, set
219   om_Opts.MinCheck, om_Opts.MinTrack to the respectiv values and
220   om_Opts.Keep to the number of addresses which are kept before they are
221   actually freed. E.g.:
222     int check=om_Opts.MinCheck, track=om_Opts.MinTrack, keep= m_OPts.Keep;
223     om_Opts.MinCheck = 3; om_Opts.MinTrack = 5; omOpts.Keep = LONG_MAX;
224     ExternalRoutine();
225     om_Opts.MinCheck = check; omOpts.MinTrack = track; omOpts.Keep = keep;
226   ensures that all calls omDebug routines  occurring during the computation of
227   ExternalRoutine() are done with OM_CHECK==3 and OM_TRACK==5, and
228   calls to omFree only mark addresses as free and not really free them.
229
230   Furthermore, the value of OM_SING_KEEP (resp. om_Opts.Keep) specifies
231   how many addresses are kept before they are actually freed, independently
232   of the value of OM_KEEP.
233
234   Some tips on possible values of OM_TRACK, OM_CHECK, OM_KEEP:
235   + To find out about an address that has been freed twice, first locate the
236     file(s) where the error occurred, and then at the beginning of these files:
237       #define OM_CHECK 3
238       #define OM_TRACK 5
239       #define OM_KEEP  1
240       #include "mod2.h"
241       #include "omalloc/omalloc.h"
242     Under dynamic scope, do (e.g., from within the debugger):
243       om_Opts.MinCheck = 3; om_Opts.MinTrack = 5; omOpts.Keep = LONG_MAX;
244   + to find out where "memory corruption" occurred, increase value of
245     OM_CHECK - the higher this value is, the more consistency checks are
246     done (However a value > 3 checks the entire memory each time an omalloc
247     routine is used!)
248
249   Some more tips on the usage of omalloc:
250   + omAlloc*, omRealloc*, omFree*, omCheck* omDebug* omTest* rotuines
251     assume that sizes are > 0 and pointers are != NULL
252   + omalloc*, omrealloc*, omfree* omcheck*, omdebug* omtest* routines allow
253     NULL pointers and sizes == 0
254   + You can safely use any free/realloc routine in combination with any alloc
255     routine (including the debug versions): E.g., an address allocated with
256     omAllocBin can be freed with omfree, or an address allocated with
257     om(Debug)Alloc can be freed with omfree, or omFree, or omFreeSize, etc.
258     However, keep in mind that the efficiency decreases from
259     Bin over Size to General routines (i.e., omFreeBin is more efficient than
260     omFreeSize which is more efficient than omFree, likewise with the alloc
261     routines).
262   + if OM_CHECK is undefined or 0, then all omCheck routines do nothing
263   + if OM_CHECK and OM_TRACK are both undefined (or 0), or if OM_NDEBUG is
264     defined, then the "real" alloc/realloc/free macros are used, and all
265     omTest, omDebug and omCheck routines are undefined
266   + to break after an omError occurred within a debugger,
267     set a breakpoint on dErrorBreak
268   + to do checks from within the debugger, or to do checks with explicit
269     check level, use omTest routines.
270*/
271
272/* by default, store alloc info and file/line where addr was freed */
273#ifndef OM_TRACK
274#define OM_TRACK 4
275#endif
276/* only do constant-time memory checks */
277#ifndef OM_CHECK
278#define OM_CHECK 1
279#endif
280/* Do actually free memory:
281   (be careful: if this is set, memory is never really freed,
282    but only marked as free) */
283#ifndef OM_KEEP
284#define OM_KEEP 0
285#endif
286/* but only after you have freed 1000 more addresses
287   (this is actually independent of the value of OM_KEEP and used
288   to initialize om_Opts.Keep) */
289#ifndef OM_SING_KEEP
290#define OM_SING_KEEP 1000
291#endif
292
293#endif /* MDEBUG */
294
295
296/* undef KDEBUG for check of data during std computations
297 *
298 * define KDEBUG to
299 * 0 for basic tests
300 * 1 for tests in kSpoly
301 * NOTE: You can locally enable tests in kspoly by setting the
302 *       define at the beginning of kspoly.cc
303 */
304#define KDEBUG 0
305
306/* define LDEBUG checking numbers, undefine otherwise */
307#define LDEBUG
308/* define RDEBUG checking rings (together with TRACE=9) */
309#define RDEBUG
310/* define TEST for non time critical tests, undefine otherwise */
311#define TEST
312
313/* #define PAGE_TEST */
314
315/* define YYDEBUG 1 for debugging bison texts, 0 otherwise */
316#define YYDEBUG 1
317
318/* define SPECTRUM_DEBUG and SPECTRUM_PRINT for debugging the spectrum code */
319/* define SPECTRUM_IOSTREAM to use C++ iostream for error messages          */
320
321/* #define SPECTRUM_DEBUG */
322/* #define SPECTRUM_PRINT */
323#undef  SPECTRUM_IOSTREAM
324
325#ifdef  SPECTRUM_DEBUG
326#define MULTICNT_DEBUG
327#define GMPRAT_DEBUG
328#define KMATRIX_DEBUG
329#define SPLIST_DEBUG
330#define NPOLYGON_DEBUG
331#define SEMIC_DEBUG
332#endif
333
334#ifdef  SPECTRUM_PRINT
335#define MULTICNT_PRINT
336#define GMPRAT_PRINT
337#define KMATRIX_PRINT
338#define SPLIST_PRINT
339#define NPOLYGON_PRINT
340#define SEMIC_PRINT
341#endif
342
343#ifdef  SPECTRUM_IOSTREAM
344#define MULTICNT_IOSTREAM
345#define GMPRAT_IOSTREAM
346#define KMATRIX_IOSTREAM
347#define SPLIST_IOSTREAM
348#define NPOLYGON_IOSTREAM
349#define SEMIC_IOSTREAM
350#endif
351
352
353#else /* not SING_NDEBUG **************************************************** */
354
355#define NO_PDEBUG
356
357/* define YYDEBUG 1 for debugging bison texts, 0 otherwise */
358#define YYDEBUG 0
359
360#endif /* not SING_NDEBUG */
361
362/*******************************************************************
363 *
364 * assume(x) -- a handy macro for assumptions
365 *
366 ******************************************************************/
367
368#ifdef __cplusplus
369extern "C" {
370#endif
371/* routine which is used to report the error/
372* returns 0 */
373extern int dReportError(const char* fmt, ...);
374/* within a debugger, set a breakpoint on dErrorBreak
375* which is called after the error has been reported */
376extern void dErrorBreak(void);
377#ifdef __cplusplus
378}
379#endif
380
381#ifdef SING_NDEBUG
382#define assume(x) do {} while (0)
383#define r_assume(x) do {} while (0)
384#else /* SING_NDEBUG */
385
386#define assume_violation(s,f,l) \
387  dReportError("assume violation at %s:%d condition: %s", f,l,s)
388
389#define assume(x)   _assume(x, __FILE__, __LINE__)
390#define r_assume(x) _r_assume(x, __FILE__, __LINE__)
391
392#define _assume(x, f, l)                        \
393do                                              \
394{                                               \
395  if (! (x))                                    \
396  {                                             \
397    assume_violation(#x, f, l);                 \
398  }                                             \
399}                                               \
400while (0)
401
402#define _r_assume(x, f, l)                      \
403do                                              \
404{                                               \
405  if (! (x))                                    \
406  {                                             \
407    assume_violation(#x, f, l);                 \
408    return 0;                                   \
409  }                                             \
410}                                               \
411while (0)
412#endif /* SING_NDEBUG */
413
414/* do have RDEBUG, unless we are doing the very real thing */
415#ifndef SING_NDEBUG
416#ifndef RDEBUG
417#define RDEBUG
418#endif
419#endif
420
421#if SIZEOF_VOIDP == 8
422#ifndef OM_CHECK
423#define OM_CHECK 0
424#endif
425#endif
426
427/* If we're not using GNU C, elide __attribute__ */
428#ifndef __GNUC__
429#  define  __attribute__(x)  /*NOTHING*/
430#endif
431
432#define STRINGIFY(name) #name
433#define EXPANDED_STRINGIFY(name) STRINGIFY(name)
434
435#endif /* MOD2_H  */
Note: See TracBrowser for help on using the repository browser.