[a70441f] | 1 | /* -*-c++-*- */ |
---|
[5f9072] | 2 | /******************************************************************* |
---|
| 3 | * Computer Algebra System SINGULAR |
---|
| 4 | * |
---|
| 5 | * mod2.h: Main configuration file for Singular |
---|
| 6 | * DO NOT EDIT! |
---|
| 7 | * |
---|
[aa0dc7] | 8 | * Version: $Id: mod2.h.in,v 1.142 2009-05-25 12:38:39 Singular Exp $ |
---|
[5f9072] | 9 | *******************************************************************/ |
---|
| 10 | #ifndef MOD2_H |
---|
| 11 | #define MOD2_H |
---|
| 12 | |
---|
| 13 | /******************************************************************* |
---|
[a693ce] | 14 | * Defines which are set by configure |
---|
[5f9072] | 15 | ******************************************************************/ |
---|
[f413ec5] | 16 | /* Define to use dynamic linking */ |
---|
| 17 | #undef HAVE_DL |
---|
[833e11] | 18 | /* Define to use readline lib for fancy display: configure result */ |
---|
| 19 | #undef HAVE_LIBREADLINE |
---|
[7e5a38] | 20 | /* Define to use static readline lib for fancy display */ |
---|
[5f9072] | 21 | #undef HAVE_READLINE |
---|
[7e5a38] | 22 | /* define to use dynamic version of readline lib */ |
---|
| 23 | #undef HAVE_DYN_RL |
---|
[5f9072] | 24 | /* Define to have dbm links */ |
---|
| 25 | #undef HAVE_DBM |
---|
| 26 | /* Define to have MP links */ |
---|
| 27 | #undef HAVE_MPSR |
---|
| 28 | /* Define to have factory functionality added */ |
---|
| 29 | #undef HAVE_FACTORY |
---|
| 30 | /* Define to have libfac functionality added */ |
---|
| 31 | #undef HAVE_LIBFAC_P |
---|
| 32 | /* Define if you have stdc headers */ |
---|
| 33 | #undef STDC_HEADERS |
---|
[b60fb4] | 34 | /* Define if you have asm/sigcontext.h */ |
---|
| 35 | #undef HAVE_ASM_SIGCONTEXT_H |
---|
[5f9072] | 36 | /* Define if you have sys/file.h */ |
---|
| 37 | #undef HAVE_SYS_FILE_H |
---|
[64c6d1] | 38 | /* Define if you have sys/stat.h */ |
---|
| 39 | #undef HAVE_SYS_STAT_H |
---|
[1caa72] | 40 | /* Define if you have sys/param.h */ |
---|
| 41 | #undef HAVE_SYS_PARAM_H |
---|
| 42 | /* Define if you have sys/file.h */ |
---|
| 43 | #undef HAVE_SYS_TYPES_H |
---|
[5f9072] | 44 | /* Define if you have sys/ioctl.h */ |
---|
| 45 | #undef HAVE_SYS_IOCTL_H |
---|
| 46 | /* Define if you have sys/time.h */ |
---|
| 47 | #undef HAVE_SYS_TIME_H |
---|
[b85a6c] | 48 | /* Define if you have sys/times.h */ |
---|
| 49 | #undef HAVE_SYS_TIMES_H |
---|
[3037783] | 50 | /* io header: */ |
---|
| 51 | /* Define if you have termcap.h */ |
---|
| 52 | #undef HAVE_TERMCAP_H |
---|
| 53 | /* Define if you have termios.h */ |
---|
| 54 | #undef HAVE_TERMIOS_H |
---|
[bd337e] | 55 | /* Define if you have term.h */ |
---|
| 56 | #undef HAVE_TERM_H |
---|
[7d52ae] | 57 | /* Define if you have readline/history.h */ |
---|
| 58 | #undef HAVE_READLINE_HISTORY_H |
---|
[3a8afb6] | 59 | /* Define if readline/readline.h is ok */ |
---|
| 60 | #undef READLINE_READLINE_H_OK |
---|
[5f9072] | 61 | /* Define if time.h and sys/time.h can be included at the same time */ |
---|
| 62 | #undef TIME_WITH_SYS_TIME |
---|
| 63 | /* Define if you have alloca.h */ |
---|
| 64 | #undef HAVE_ALLOCA_H |
---|
[1caa72] | 65 | /* Define if you have pwd.h */ |
---|
| 66 | #undef HAVE_PWD_H |
---|
[52a5e8] | 67 | /* Define if you have unistd.h */ |
---|
| 68 | #undef HAVE_UNISTD_H |
---|
[138f0c] | 69 | /* define if you have malloc.h */ |
---|
[52a5e8] | 70 | #undef HAVE_MALLOC_H |
---|
[138f0c] | 71 | /* define if you have pwd.h*/ |
---|
| 72 | #undef HAVE_PWD_H |
---|
[5f9072] | 73 | /* Define if you have alloca */ |
---|
| 74 | #undef HAVE_ALLOCA |
---|
| 75 | /* Define if you have getpagesize */ |
---|
| 76 | #undef GETPAGESIZE |
---|
| 77 | /* Define if you have vprintf */ |
---|
| 78 | #undef HAVE_VPRINTF |
---|
| 79 | /* Define if you have gettimeofday */ |
---|
| 80 | #undef HAVE_GETTIMEOFDAY |
---|
| 81 | /* Define if you have atexit */ |
---|
| 82 | #undef HAVE_ATEXIT |
---|
[a693ce] | 83 | /* Define if you have bcopy, bzero and bcmp |
---|
[2c3da6] | 84 | Linux needs that define! */ |
---|
| 85 | #undef HAVE_BCOPY |
---|
[5f9072] | 86 | /* Define if sprintf does not return number of printed chars */ |
---|
| 87 | #undef BSD_SPRINTF |
---|
[c7db8e] | 88 | /* define if you have explicit C++ constructors */ |
---|
| 89 | #undef HAVE_EXPLICIT_CONSTR |
---|
[1caa72] | 90 | /* Define if you have the getcwd function. */ |
---|
| 91 | #undef HAVE_GETCWD |
---|
| 92 | /* Define if you have the getwd function. */ |
---|
| 93 | #undef HAVE_GETWD |
---|
[a79a128] | 94 | /* Define if you have snprintf */ |
---|
| 95 | #undef HAVE_VSNPRINTF |
---|
[a8bce04] | 96 | /* Define if you have readlink */ |
---|
| 97 | #undef HAVE_READLINK |
---|
[45f7bf] | 98 | /* Define if you have usleep */ |
---|
| 99 | #undef HAVE_USLEEP |
---|
[3bb3e6a] | 100 | /* Define if you have sleep */ |
---|
| 101 | #undef HAVE_SLEEP |
---|
[9c35ef] | 102 | /* Define if you have setenv */ |
---|
| 103 | #undef HAVE_SETENV |
---|
[138f0c] | 104 | /* Define if you have petpwnam */ |
---|
| 105 | #undef HAVE_GETPWNAM |
---|
[9d72fe] | 106 | /* Define if you have popen */ |
---|
| 107 | #undef HAVE_POPEN |
---|
[4094088] | 108 | /* Define if you have sysconf */ |
---|
| 109 | #undef HAVE_SYSCONF |
---|
[206aed] | 110 | /* Define if you have siginterrupt (BSD4.3) */ |
---|
| 111 | #undef HAVE_SIGINTERRUPT |
---|
[1cddd8] | 112 | /* define for boost includes and lib */ |
---|
| 113 | #undef HAVE_BOOST_DYNAMIC_BITSET_HPP |
---|
[ea6657f] | 114 | /* define for std:vector includes */ |
---|
| 115 | #undef USE_STDVECBOOL |
---|
[51c163] | 116 | /* Define sizeof(char) */ |
---|
| 117 | #define SIZEOF_CHAR 1 |
---|
| 118 | /* Define sizeof(short) */ |
---|
| 119 | #define SIZEOF_SHORT 2 |
---|
| 120 | /* Define sizeof(int) */ |
---|
| 121 | #define SIZEOF_INT 4 |
---|
| 122 | /* Define sizeof(long) */ |
---|
| 123 | #define SIZEOF_LONG 4 |
---|
[5f9072] | 124 | /* Define sizeof(void*) */ |
---|
| 125 | #define SIZEOF_VOIDP 4 |
---|
[fff984] | 126 | /* Define sizeof(double) */ |
---|
| 127 | #define SIZEOF_DOUBLE 8 |
---|
[51c163] | 128 | /* Define if your integer format is big endian */ |
---|
| 129 | #undef WORDS_BIGENDIAN |
---|
[64c6d1] | 130 | /* Define major version of Singular -- should be set in ../configure.in!!!*/ |
---|
[cb0e67b] | 131 | #define SINGULAR_MAJOR_VERSION 0 |
---|
[64c6d1] | 132 | /* Define minor version of Singular -- should be set in ../configure.in!!! */ |
---|
[cb0e67b] | 133 | #define SINGULAR_MINOR_VERSION 0 |
---|
[64c6d1] | 134 | /* Define sub version of Singular -- should be set in ../configure.in!!! */ |
---|
[cb0e67b] | 135 | #define SINGULAR_SUB_VERSION 0 |
---|
[5f9072] | 136 | /* Define version as a string */ |
---|
| 137 | #define S_VERSION1 "" |
---|
| 138 | /* Define version date as a string */ |
---|
| 139 | #define S_VERSION2 "" |
---|
[72f950] | 140 | /* Define uname identifier as a string */ |
---|
| 141 | #define S_UNAME "" |
---|
[9c35ef] | 142 | /* Absolute pathname of root directory of Singular source */ |
---|
| 143 | #define S_ROOT_DIR "" |
---|
[814c11] | 144 | /* Define to use new namespaces techniks */ |
---|
| 145 | #undef HAVE_NAMESPACES |
---|
[e5ee39f] | 146 | #undef HAVE_NS |
---|
[814c11] | 147 | /* Define to enable dynamic module code */ |
---|
| 148 | #undef HAVE_DYNAMIC_LOADING |
---|
| 149 | /* Define to enable plural */ |
---|
| 150 | #undef HAVE_PLURAL |
---|
[9e9dbc] | 151 | /* Define to enable ratGB/ ratGRING */ |
---|
| 152 | #undef HAVE_RATGRING |
---|
[037df4] | 153 | /* Define to enable shiftbba */ |
---|
| 154 | #undef HAVE_SHIFTBBA |
---|
[696db9] | 155 | /* Define to enable libsvd */ |
---|
| 156 | #undef HAVE_SVD |
---|
[7afec5] | 157 | /* CPU type: i[3456]86: */ |
---|
| 158 | #undef SI_CPU_I386 |
---|
| 159 | /* CPU type: sparc: */ |
---|
| 160 | #undef SI_CPU_SPARC |
---|
| 161 | /* CPU type: ppc: */ |
---|
| 162 | #undef SI_CPU_PPC |
---|
| 163 | /* CPU type: IA64: */ |
---|
| 164 | #undef SI_CPU_IA64 |
---|
| 165 | /* CPU type: x86_64: */ |
---|
| 166 | #undef SI_CPU_X86_64 |
---|
[5f9072] | 167 | |
---|
| 168 | /******************************************************************* |
---|
| 169 | * Defines which are not set by configure |
---|
| 170 | ******************************************************************/ |
---|
[f413ec5] | 171 | |
---|
[5f9072] | 172 | /* Default value for timer resolution in ticks per second */ |
---|
| 173 | /* set to 10 for resolution of tenth of a second, etc */ |
---|
| 174 | #define TIMER_RESOLUTION 1 |
---|
[f413ec5] | 175 | |
---|
[5f9072] | 176 | /* Undefine to disable the quote/eval of expressions */ |
---|
| 177 | #define SIQ 1 |
---|
[f413ec5] | 178 | |
---|
[5f9072] | 179 | /* Define to enable TCL interface */ |
---|
[49c4ae] | 180 | #undef HAVE_TCL |
---|
[f413ec5] | 181 | |
---|
[dc87554] | 182 | /* Undefine to disable Gerhard's and Wilfried's fast and dirty std computations */ |
---|
[5f9072] | 183 | #define FAST_AND_DIRTY |
---|
| 184 | |
---|
[c3f0f3] | 185 | /* eigenvalues */ |
---|
[670d92] | 186 | #ifndef HAVE_DYNAMIC_LOADING |
---|
[c3f0f3] | 187 | #define HAVE_EIGENVAL 1 |
---|
| 188 | |
---|
[bb0153] | 189 | /* Gauss-Manin system */ |
---|
| 190 | #define HAVE_GMS 1 |
---|
[670d92] | 191 | #endif |
---|
[bb0153] | 192 | |
---|
[057751] | 193 | /* linear algebra extensions from pcv.h/pcv.cc */ |
---|
| 194 | #define HAVE_PCV 1 |
---|
| 195 | |
---|
[b546c0] | 196 | /* procedures to compute groebner bases with the f5 implementation */ |
---|
| 197 | /* still testing */ |
---|
| 198 | #undef HAVE_F5 |
---|
[797ff9] | 199 | |
---|
[b4e3253] | 200 | /* letterplace gb:*/ |
---|
[4b00ef] | 201 | #define HAVE_SHIFTBBA 1 |
---|
[b546c0] | 202 | |
---|
| 203 | /* rings as coefficients */ |
---|
| 204 | #define HAVE_RINGS |
---|
| 205 | |
---|
| 206 | /* procedures to compute with units */ |
---|
[4abea21] | 207 | #define HAVE_UNITS |
---|
[7e67559] | 208 | |
---|
[77ff8e] | 209 | /* Define to use old mechanismen for saving currRing with procedures |
---|
[a693ce] | 210 | * Does not work with HAVE_NAMESPACES enabled |
---|
[77ff8e] | 211 | */ |
---|
| 212 | #undef USE_IILOCALRING |
---|
| 213 | |
---|
[6a51ef] | 214 | |
---|
| 215 | /* Define to use scanner when loading libraries */ |
---|
| 216 | #define HAVE_LIBPARSER |
---|
| 217 | |
---|
[2b3f23] | 218 | /*#define PROFILING*/ |
---|
[670667] | 219 | #ifdef PROFILING |
---|
[2b3f23] | 220 | #define PROFILER ,0,0 |
---|
[670667] | 221 | #else |
---|
[a693ce] | 222 | #define PROFILER |
---|
[670667] | 223 | #endif |
---|
| 224 | |
---|
[64c6d1] | 225 | /* Define to use gmp for rational arithmetic */ |
---|
| 226 | #define HAVE_GMP |
---|
| 227 | |
---|
[5f9072] | 228 | /******************************************************************* |
---|
| 229 | * Evaluate the set defines |
---|
| 230 | ******************************************************************/ |
---|
| 231 | /* FGLM needs factory */ |
---|
| 232 | #ifdef HAVE_FACTORY |
---|
| 233 | #define HAVE_FGLM |
---|
| 234 | #endif |
---|
| 235 | |
---|
[223114] | 236 | /* Define if you want fglm for homogeneous case */ |
---|
| 237 | #ifdef HAVE_FGLM |
---|
| 238 | #undef HAVE_FGLM_HOME |
---|
| 239 | #endif |
---|
| 240 | |
---|
[7885020] | 241 | /* Spectrum needs GMP */ |
---|
| 242 | #ifdef HAVE_GMP |
---|
[d3bf098] | 243 | #define HAVE_SPECTRUM 1 |
---|
[7885020] | 244 | #endif |
---|
| 245 | |
---|
[5f9072] | 246 | /* Undefine to disable real time measurments */ |
---|
| 247 | #ifdef HAVE_GETTIMEOFDAY |
---|
| 248 | #define HAVE_RTIMER |
---|
[3ebcbd] | 249 | #endif |
---|
[5f9072] | 250 | |
---|
| 251 | #if SIZEOF_VOIDP == 8 |
---|
[b7b08c] | 252 | /* SIZEOF_LONG == SIZEOF_VOIDP is guaranteed by configure */ |
---|
[5f9072] | 253 | #define ALIGN_8 |
---|
[b7b08c] | 254 | #define LOG_SIZEOF_LONG 3 |
---|
| 255 | #define LOG_SIZEOF_VOIDP 3 |
---|
| 256 | #else |
---|
| 257 | #define LOG_SIZEOF_LONG 2 |
---|
| 258 | #define LOG_SIZEOF_VOIDP 2 |
---|
[5f9072] | 259 | #endif |
---|
| 260 | |
---|
[f62e786] | 261 | #ifndef CHAR_BIT |
---|
| 262 | #define CHAR_BIT 8 |
---|
| 263 | #endif |
---|
| 264 | |
---|
| 265 | #define BIT_SIZEOF_LONG CHAR_BIT*SIZEOF_LONG |
---|
| 266 | |
---|
[aa0dc7] | 267 | #define SINGULAR_PATCHLEVEL 3 |
---|
[ea6657f] | 268 | #define SINGULAR_VERSION ((SINGULAR_MAJOR_VERSION*1000 + SINGULAR_MINOR_VERSION*100 + SINGULAR_SUB_VERSION*10)+SINGULAR_PATCHLEVEL) |
---|
[5f9072] | 269 | |
---|
| 270 | /******************************************************************* |
---|
[a693ce] | 271 | * Miscellanous Defines |
---|
[5f9072] | 272 | ******************************************************************/ |
---|
[dc0898] | 273 | /* Under HPUX 9, system(...) returns -1 if SIGCHLD does not equal |
---|
| 274 | SIG_DFL. However, if it stays at SIG_DFL we get zombie processes |
---|
| 275 | for terminated childs generated by fork. Therefors some special treatment |
---|
| 276 | is necessary */ |
---|
| 277 | #ifdef HPUX_9 |
---|
| 278 | #include <stdlib.h> |
---|
| 279 | #define system hpux9_system |
---|
| 280 | #ifdef __cplusplus |
---|
| 281 | extern "C" { |
---|
| 282 | #endif |
---|
| 283 | int hpux9_system(const char* system); |
---|
| 284 | #ifdef __cplusplus |
---|
| 285 | } |
---|
| 286 | #endif |
---|
| 287 | #endif |
---|
[faaef1] | 288 | |
---|
[6a51ef] | 289 | #ifndef HAVE_LIBPARSER |
---|
| 290 | # undef YYLPDEBUG |
---|
| 291 | #else |
---|
[799ce1] | 292 | # define YYLPDEBUG 1 |
---|
[6a51ef] | 293 | #endif |
---|
| 294 | |
---|
[5f9072] | 295 | #ifndef FALSE |
---|
| 296 | #define FALSE 0 |
---|
| 297 | #endif |
---|
| 298 | |
---|
| 299 | #ifndef TRUE |
---|
| 300 | #define TRUE 1 |
---|
| 301 | #endif |
---|
| 302 | |
---|
| 303 | #ifndef NULL |
---|
| 304 | #define NULL (0) |
---|
| 305 | #endif |
---|
| 306 | |
---|
| 307 | #ifndef SEEK_END |
---|
| 308 | #define SEEK_END 2 |
---|
| 309 | #endif |
---|
| 310 | |
---|
| 311 | #ifndef SEEK_SET |
---|
| 312 | #define SEEK_SET 0 |
---|
| 313 | #endif |
---|
| 314 | |
---|
| 315 | #define HALT() m2_end(2) |
---|
| 316 | |
---|
| 317 | #define memcpy4 memcpy |
---|
| 318 | |
---|
[faaef1] | 319 | /* define OLD_RES for res/sres/mres(i,j,k) */ |
---|
[1dc07a7] | 320 | #undef OLD_RES |
---|
[faaef1] | 321 | |
---|
[5f9072] | 322 | /* the maximal ascii length of an int number + 1 = 11 for 32 bit int */ |
---|
| 323 | #define MAX_INT_LEN 11 |
---|
[82af190] | 324 | #define MAX_INT_VAL 0x7fffffff |
---|
[5f9072] | 325 | |
---|
[51c163] | 326 | #ifdef DO_PROFILE |
---|
[a693ce] | 327 | /* define to enable explicit profiling of some crucial inline |
---|
[f92fa13] | 328 | * routines and defines */ |
---|
[7a5e7c] | 329 | #undef DO_DEEP_PROFILE |
---|
[51c163] | 330 | #endif |
---|
[f92fa13] | 331 | |
---|
[52a5e8] | 332 | #define buildin_rand 1 |
---|
| 333 | |
---|
| 334 | /* define to enable assume */ |
---|
| 335 | #ifndef HAVE_ASSUME |
---|
| 336 | #undef HAVE_ASSUME |
---|
| 337 | #endif |
---|
| 338 | |
---|
[6b32990] | 339 | /* define LINKAGE to "extern C" if compiling for shared libs */ |
---|
| 340 | #ifndef LINKAGE |
---|
| 341 | #if defined(PIC) |
---|
| 342 | #define LINKAGE extern "C" |
---|
| 343 | #else |
---|
| 344 | #define LINKAGE |
---|
| 345 | #endif |
---|
| 346 | #endif |
---|
| 347 | |
---|
[b7b08c] | 348 | |
---|
[5f9072] | 349 | /******************************************************************* |
---|
| 350 | * DEBUG OPTIONS |
---|
| 351 | * -- only significant for for compiling without -DNDEBUG |
---|
| 352 | * -- you better know what your are doing, if you touch this |
---|
| 353 | ******************************************************************/ |
---|
[a693ce] | 354 | #ifndef NDEBUG |
---|
[5f9072] | 355 | |
---|
[ec7aac] | 356 | /* undefine to enable inline */ |
---|
| 357 | #define NO_INLINE |
---|
| 358 | |
---|
[52a5e8] | 359 | /* undefine to disable assume -- should normally be defined for NDEBUG */ |
---|
| 360 | #define HAVE_ASSUME |
---|
| 361 | |
---|
[d14712] | 362 | /* undef PDEBUG to disable checks of polys |
---|
[cb66fa] | 363 | |
---|
| 364 | define PDEBUG to |
---|
| 365 | 0 for enabling pTest |
---|
[512a2b] | 366 | 1 plus tests in Level 1 poly routines (operations on monomials) |
---|
| 367 | 2 plus tests in Level 2 poly routines (operations on single exponents) |
---|
[cb66fa] | 368 | -- see also polys.h for more info |
---|
| 369 | |
---|
| 370 | NOTE: you can set the value of PDEBUG on a per-file basis, before |
---|
[512a2b] | 371 | including mod2.h, provided ! PDEBUG is defined in mod2.h E.g.: |
---|
[cb66fa] | 372 | |
---|
| 373 | #define PDEBUG 2 |
---|
| 374 | #include "mod2.h" |
---|
| 375 | ... |
---|
| 376 | |
---|
| 377 | makes sure that all poly operations in your file are done with |
---|
| 378 | PDEBUG == 2 |
---|
[512a2b] | 379 | To break after an error occured, set a debugger breakpoint on |
---|
| 380 | dErrorBreak. |
---|
[cb66fa] | 381 | */ |
---|
[a6a239] | 382 | #ifndef PDEBUG |
---|
[d14712] | 383 | #define PDEBUG 0 |
---|
[a6a239] | 384 | #endif |
---|
[d14712] | 385 | |
---|
[c232af] | 386 | /* define MDEBUG to enable memory checks */ |
---|
| 387 | #define MDEBUG 0 |
---|
| 388 | |
---|
| 389 | #ifdef MDEBUG |
---|
| 390 | /* If ! defined(OM_NDEBUG) and (defined(OM_TRACK) or defined(OM_CHECK) |
---|
| 391 | then omDebug routines are used for memory allocation/free: |
---|
| 392 | |
---|
[512a2b] | 393 | The omDebug routines are controlled by the values of OM_TRACK, OM_CHECK |
---|
| 394 | and OM_KEEP. There meaning is roughly as follows: |
---|
[c232af] | 395 | OM_TRACK: strored with address : extra space |
---|
| 396 | 0 : no additional info is stored : 0 |
---|
| 397 | 1 : file:line of location where address was allocated : 1 word |
---|
| 398 | 2 : plus backtrace of stack where adress was allocated: 6 words |
---|
| 399 | 3 : plus size/bin info and front-, and back padding : 9 words |
---|
| 400 | 4 : plus file:line of location where adress was freed : 10 words |
---|
| 401 | 5 : plus backtrace of stack where adress was allocated: 15 words |
---|
| 402 | OM_CHECK: checks done |
---|
| 403 | 0 : no checks |
---|
| 404 | 1 : constant-time checks: i.e. addr checks only |
---|
| 405 | 2 : plus linear-time checks and constant related bin check |
---|
| 406 | 3 : plus quadratic-time checks and linear-time related bin checks and |
---|
| 407 | constant time all memory checks |
---|
| 408 | 4 : and so on |
---|
| 409 | ==> for OM_CHECK >= 3 it gets rather slow |
---|
[512a2b] | 410 | OM_KEEP: determines whether addresses are really freed ( |
---|
| 411 | 0 : addresses are really freed |
---|
| 412 | 1 : addresses are only marked as free and not really freed. |
---|
[c232af] | 413 | |
---|
[512a2b] | 414 | OM_CHECK, OM_TRACK, and OM_KEEP can be set on a per-file basis |
---|
| 415 | (as can OM_NDEBUG), e.g.: |
---|
[c232af] | 416 | #define OM_CHECK 3 |
---|
| 417 | #define OM_TRACK 5 |
---|
[512a2b] | 418 | #define OM_KEEP 1 |
---|
| 419 | #include "mod2.h" |
---|
| 420 | #include "omalloc.h" |
---|
[c232af] | 421 | ensures that all memory allocs/free in this file are done with |
---|
[512a2b] | 422 | OM_CHECK==3 and OM_TRACK==5, and that all addresses allocated/freed |
---|
| 423 | in this file are only marked as free and never really freed. |
---|
[c232af] | 424 | |
---|
[512a2b] | 425 | To set OM_CHECK, OM_TRACK and OM_KEEP under dynamic scope, set |
---|
| 426 | om_Opts.MinCheck, om_Opts.MinTrack to the respectiv values and |
---|
| 427 | om_Opts.Keep to the number of addresses which are kept before they are |
---|
| 428 | actually freed. E.g.: |
---|
| 429 | int check=om_Opts.MinCheck, track=om_Opts.MinTrack, keep= m_OPts.Keep; |
---|
| 430 | om_Opts.MinCheck = 3; om_Opts.MinTrack = 5; omOpts.Keep = LONG_MAX; |
---|
[c232af] | 431 | ExternalRoutine(); |
---|
[512a2b] | 432 | om_Opts.MinCheck = check; omOpts.MinTrack = track; omOpts.Keep = keep; |
---|
[c232af] | 433 | ensures that all calls omDebug routines occuring during the computation of |
---|
[512a2b] | 434 | ExternalRoutine() are done with OM_CHECK==3 and OM_TRACK==5, and |
---|
| 435 | calls to omFree only mark addresses as free and not really free them. |
---|
[c232af] | 436 | |
---|
| 437 | Furthermore, the value of OM_SING_KEEP (resp. om_Opts.Keep) specifies |
---|
[512a2b] | 438 | how many addresses are kept before they are actually freed, independently |
---|
| 439 | of the value of OM_KEEP. |
---|
| 440 | |
---|
| 441 | Some tips on possible values of OM_TRACK, OM_CHECK, OM_KEEP: |
---|
| 442 | + To find out about an address that has been freed twice, first locate the |
---|
| 443 | file(s) where the error occured, and then at the beginning of these files: |
---|
| 444 | #define OM_CHECK 3 |
---|
| 445 | #define OM_TRACK 5 |
---|
| 446 | #define OM_KEEP 1 |
---|
| 447 | #include "mod2.h" |
---|
| 448 | #include "omalloc.h" |
---|
| 449 | Under dynamic scope, do (e.g., from within the debugger): |
---|
| 450 | om_Opts.MinCheck = 3; om_Opts.MinTrack = 5; omOpts.Keep = LONG_MAX; |
---|
[c232af] | 451 | + to find out where "memory corruption" occured, increase value of |
---|
| 452 | OM_CHECK - the higher this value is, the more consistency checks are |
---|
| 453 | done (However a value > 3 checks the entire memory each time an omalloc |
---|
[cb66fa] | 454 | routine is used!) |
---|
[c232af] | 455 | |
---|
| 456 | Some more tips on the usage of omalloc: |
---|
| 457 | + omAlloc*, omRealloc*, omFree*, omCheck* omDebug* omTest* rotuines |
---|
| 458 | assume that sizes are > 0 and pointers are != NULL |
---|
| 459 | + omalloc*, omrealloc*, omfree* omcheck*, omdebug* omtest* routines allow |
---|
| 460 | NULL pointers and sizes == 0 |
---|
| 461 | + You can safely use any free/realloc routine in combination with any alloc |
---|
| 462 | routine (including the debug versions): E.g., an address allocated with |
---|
| 463 | omAllocBin can be freed with omfree, or an adress allocated with |
---|
| 464 | om(Debug)Alloc can be freed with omfree, or omFree, or omFreeSize, etc. |
---|
[cb66fa] | 465 | However, keep in mind that the efficiency decreases from |
---|
[c232af] | 466 | Bin over Size to General routines (i.e., omFreeBin is more efficient than |
---|
[512a2b] | 467 | omFreeSize which is more efficient than omFree, likewise with the alloc |
---|
[c232af] | 468 | routines). |
---|
[512a2b] | 469 | + if OM_CHECK is undefined or 0, then all omCheck routines do nothing |
---|
| 470 | + if OM_CHECK and OM_TRACK are both undefined (or 0), or if OM_NDEBUG is |
---|
| 471 | defined, then the "real" alloc/realloc/free macros are used, and all |
---|
| 472 | omTest, omDebug and omCheck routines are undefined |
---|
| 473 | + to break after an omError occured within a debugger, |
---|
| 474 | set a breakpoint on dErrorBreak |
---|
| 475 | + to do checks from within the debugger, or to do checks with explicit |
---|
[ec7aac] | 476 | check level, use omTest routines. |
---|
[c232af] | 477 | */ |
---|
| 478 | |
---|
[512a2b] | 479 | /* by default, store alloc info and file/line where addr was freed */ |
---|
| 480 | #ifndef OM_TRACK |
---|
| 481 | #define OM_TRACK 4 |
---|
| 482 | #endif |
---|
| 483 | /* only do constant-time memory checks */ |
---|
| 484 | #ifndef OM_CHECK |
---|
[c232af] | 485 | #define OM_CHECK 1 |
---|
[512a2b] | 486 | #endif |
---|
| 487 | /* Do actually free memory: |
---|
| 488 | (be careful: if this is set, memory is never really freed, |
---|
| 489 | but only marked as free) */ |
---|
| 490 | #ifndef OM_KEEP |
---|
| 491 | #define OM_KEEP 0 |
---|
| 492 | #endif |
---|
| 493 | /* but only after you have freed 1000 more addresses |
---|
| 494 | (this is actually independent of the value of OM_KEEP and used |
---|
| 495 | to initialize om_Opts.Keep) */ |
---|
| 496 | #ifndef OM_SING_KEEP |
---|
[c232af] | 497 | #define OM_SING_KEEP 1000 |
---|
[512a2b] | 498 | #endif |
---|
| 499 | |
---|
[c232af] | 500 | #endif /* MDEBUG */ |
---|
| 501 | |
---|
| 502 | |
---|
| 503 | /* undef KDEBUG for check of data during std computations |
---|
[d14712] | 504 | * |
---|
| 505 | * define KDEBUG to |
---|
| 506 | * 0 for basic tests |
---|
| 507 | * 1 for tests in kSpoly |
---|
| 508 | * NOTE: You can locally enable tests in kspoly by setting the |
---|
| 509 | * define at the beginning of kspoly.cc |
---|
| 510 | */ |
---|
| 511 | #define KDEBUG 0 |
---|
[52a5e8] | 512 | |
---|
[5f9072] | 513 | /* define LDEBUG checking numbers, undefine otherwise */ |
---|
[a693ce] | 514 | #define LDEBUG |
---|
[5f9072] | 515 | /* define RDEBUG checking rings (together with TRACE=9) */ |
---|
[a693ce] | 516 | #define RDEBUG |
---|
[5f9072] | 517 | /* define TEST for non time critical tests, undefine otherwise */ |
---|
| 518 | #define TEST |
---|
[fff984] | 519 | |
---|
[5f9072] | 520 | /* #define PAGE_TEST */ |
---|
| 521 | |
---|
[6b6b2f9] | 522 | /* define YYDEBUG 1 for debugging bison texts, 0 otherwise */ |
---|
[a693ce] | 523 | #define YYDEBUG 1 |
---|
| 524 | |
---|
[5f9072] | 525 | /* Undefine to disable debugging of MP stuff */ |
---|
| 526 | #ifdef HAVE_MPSR |
---|
[a693ce] | 527 | #define MPSR_DEBUG |
---|
[5f9072] | 528 | #endif |
---|
| 529 | |
---|
| 530 | |
---|
| 531 | #ifdef TEST |
---|
| 532 | #ifndef buildin_rand |
---|
| 533 | #define buildin_rand 1 |
---|
| 534 | #endif |
---|
| 535 | #endif |
---|
| 536 | |
---|
[7885020] | 537 | /* define SPECTRUM_DEBUG and SPECTRUM_PRINT for debugging the spectrum code */ |
---|
| 538 | /* define SPECTRUM_IOSTREAM to use C++ iostream for error messages */ |
---|
| 539 | |
---|
| 540 | /* #define SPECTRUM_DEBUG */ |
---|
| 541 | /* #define SPECTRUM_PRINT */ |
---|
| 542 | #undef SPECTRUM_IOSTREAM |
---|
| 543 | |
---|
| 544 | #ifdef SPECTRUM_DEBUG |
---|
| 545 | #define MULTICNT_DEBUG |
---|
| 546 | #define GMPRAT_DEBUG |
---|
| 547 | #define KMATRIX_DEBUG |
---|
| 548 | #define SPLIST_DEBUG |
---|
| 549 | #define NPOLYGON_DEBUG |
---|
| 550 | #define SEMIC_DEBUG |
---|
| 551 | #endif |
---|
| 552 | |
---|
| 553 | #ifdef SPECTRUM_PRINT |
---|
| 554 | #define MULTICNT_PRINT |
---|
| 555 | #define GMPRAT_PRINT |
---|
| 556 | #define KMATRIX_PRINT |
---|
| 557 | #define SPLIST_PRINT |
---|
| 558 | #define NPOLYGON_PRINT |
---|
| 559 | #define SEMIC_PRINT |
---|
| 560 | #endif |
---|
| 561 | |
---|
| 562 | #ifdef SPECTRUM_IOSTREAM |
---|
| 563 | #define MULTICNT_IOSTREAM |
---|
| 564 | #define GMPRAT_IOSTREAM |
---|
| 565 | #define KMATRIX_IOSTREAM |
---|
| 566 | #define SPLIST_IOSTREAM |
---|
| 567 | #define NPOLYGON_IOSTREAM |
---|
| 568 | #define SEMIC_IOSTREAM |
---|
| 569 | #endif |
---|
| 570 | |
---|
| 571 | |
---|
| 572 | #else /* not NDEBUG **************************************************** */ |
---|
[6b6b2f9] | 573 | |
---|
[996e19] | 574 | #define NO_PDEBUG |
---|
[a6a239] | 575 | |
---|
[6b6b2f9] | 576 | /* define YYDEBUG 1 for debugging bison texts, 0 otherwise */ |
---|
| 577 | #define YYDEBUG 0 |
---|
| 578 | |
---|
[5f9072] | 579 | #endif /* not NDEBUG */ |
---|
| 580 | |
---|
[77ff8e] | 581 | #ifdef HAVE_NAMESPACES |
---|
| 582 | # undef USE_IILOCALRING |
---|
| 583 | #endif |
---|
[52a5e8] | 584 | |
---|
| 585 | /******************************************************************* |
---|
| 586 | * |
---|
[7885020] | 587 | * assume(x) -- a handy macro for assumptions |
---|
[52a5e8] | 588 | * |
---|
| 589 | ******************************************************************/ |
---|
| 590 | |
---|
| 591 | #ifdef __cplusplus |
---|
| 592 | extern "C" { |
---|
| 593 | #endif |
---|
[cb66fa] | 594 | // routine which is used to report the error |
---|
[bd4fa1] | 595 | // returns 0 |
---|
| 596 | extern int dReportError(const char* fmt, ...); |
---|
[cb66fa] | 597 | // within a debugger, set a breakpoint on dErrorBreak |
---|
| 598 | // which is called after the error has been reported |
---|
| 599 | extern void dErrorBreak(); |
---|
[52a5e8] | 600 | #ifdef __cplusplus |
---|
| 601 | } |
---|
| 602 | #endif |
---|
| 603 | |
---|
[512a2b] | 604 | #ifndef HAVE_ASSUME |
---|
| 605 | #define assume(x) ((void) 0) |
---|
| 606 | #define r_assume(x) ((void) 0) |
---|
| 607 | #else /* ! HAVE_ASSUME */ |
---|
| 608 | |
---|
| 609 | #define assume_violation(s,f,l) \ |
---|
| 610 | dReportError("assume violation at %s:%d condition: %s", f,l,s) |
---|
| 611 | |
---|
[52a5e8] | 612 | #define assume(x) _assume(x, __FILE__, __LINE__) |
---|
| 613 | #define r_assume(x) _r_assume(x, __FILE__, __LINE__) |
---|
| 614 | |
---|
| 615 | #define _assume(x, f, l) \ |
---|
| 616 | do \ |
---|
| 617 | { \ |
---|
| 618 | if (! (x)) \ |
---|
| 619 | { \ |
---|
[ec7aac] | 620 | assume_violation(#x, f, l); \ |
---|
[52a5e8] | 621 | } \ |
---|
| 622 | } \ |
---|
| 623 | while (0) |
---|
| 624 | |
---|
| 625 | #define _r_assume(x, f, l) \ |
---|
| 626 | do \ |
---|
| 627 | { \ |
---|
| 628 | if (! (x)) \ |
---|
| 629 | { \ |
---|
[ec7aac] | 630 | assume_violation(#x, f, l); \ |
---|
[52a5e8] | 631 | return 0; \ |
---|
| 632 | } \ |
---|
| 633 | } \ |
---|
| 634 | while (0) |
---|
| 635 | #endif /* HAVE_ASSUME */ |
---|
| 636 | |
---|
[532abf] | 637 | /* do have RDEBUG, unless we are doing the very real thing */ |
---|
| 638 | #ifdef HAVE_ASSUME |
---|
[ec7aac] | 639 | #ifndef RDEBUG |
---|
| 640 | #define RDEBUG |
---|
| 641 | #endif |
---|
| 642 | #endif |
---|
| 643 | |
---|
[6f0eb7] | 644 | #if SIZEOF_VOIDP == 8 |
---|
| 645 | #ifndef OM_CHECK |
---|
| 646 | #define OM_CHECK 0 |
---|
| 647 | #endif |
---|
| 648 | #endif |
---|
| 649 | |
---|
[fb0d9a] | 650 | /* If we're not using GNU C, elide __attribute__ */ |
---|
| 651 | #ifndef __GNUC__ |
---|
| 652 | # define __attribute__(x) /*NOTHING*/ |
---|
| 653 | #endif |
---|
[6f0eb7] | 654 | |
---|
[5f9072] | 655 | #endif /* MOD2_H */ |
---|