source: git/kernel/mod2.h @ e0b002

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