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