Frobby  0.9.5
stdinc.h
Go to the documentation of this file.
1 /* Frobby: Software for monomial ideal computations.
2  Copyright (C) 2007 Bjarke Hammersholt Roune (www.broune.com)
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program. If not, see http://www.gnu.org/licenses/.
16 */
24 #ifdef _MSC_VER // For Microsoft Compiler in Visual Studio C++.
25 #define _SCL_SECURE_NO_WARNINGS
26 #pragma warning (push, 1) // Reduce warning level for GMP headers.
27 #endif
28 
29 // Some versions of GMP do not define gmp_fprintf unless cstdio is
30 // included first, so we have to include it here.
31 #include <cstdio>
32 #include <cstddef>
33 
34 #include <gmp.h>
35 #include <gmpxx.h>
36 
37 #ifdef _MSC_VER // For Microsoft Compiler in Visual Studio C++.
38 #pragma warning (pop) // Go back to previous warning level.
39 #pragma warning (disable: 4996) // std::copy is flagged as dangerous.
40 #pragma warning (disable: 4290) // VC++ ignores throw () specification.
41 #pragma warning (disable: 4127) // Warns about using "while (true)".
42 #pragma warning (disable: 4100) // Warns about unused parameters.
43 #pragma warning (disable: 4800) // Warns on int to bool conversion.
44 #pragma warning (disable: 4146) // Warns on unary minus on unsigned (bit trick)
45 
46 // This warning warns about using the this pointer in base member
47 // initializer lists. This is a pretty good warning as that can
48 // obviously easily go wrong, but it is pretty useful to do as well,
49 // so the warning is turned off.
50 #pragma warning (disable: 4355)
51 
52 #ifdef _DEBUG
53 #ifndef DEBUG
54 #define DEBUG
55 #endif
56 #endif
57 
58 #ifdef DEBUG
59 // MSC's map header has an issue where you get a syntax error if you
60 // define a macro for new like we do below. We work around this by including
61 // map before we define the macro.
62 #include <map>
63 #endif
64 #endif
65 
66 #include <cstddef>
67 #include <memory>
68 using namespace std;
69 
70 #ifdef DEBUG
71 #include <iostream> // Useful for debugging.
72 #define PRINT
73 #define IF_DEBUG(X) X
74 #include <cassert>
75 #define ASSERT(X) assert(X);
76 void* operator new(size_t s, const char* file, size_t line)
77  throw (std::bad_alloc);
78 void* operator new[](size_t s, const char* file, size_t line)
79  throw (std::bad_alloc);
80 void operator delete(void* s, const char* file, size_t line);
81 void operator delete[](void* s, const char* file, size_t line);
82 #define NEW_MACRO new (__FILE__, __LINE__)
83 #define new NEW_MACRO
84 #else
85 #define IF_DEBUG(X)
86 #define ASSERT(X)
87 #endif
88 
89 typedef unsigned int Exponent;
90 
93 typedef unsigned long Word;
94 static const size_t BitsPerWord = 8 * sizeof(Word);
95 
99 static const size_t MemoryAlignment = sizeof(long);
static const size_t MemoryAlignment
The alignment that memory allocators must ensure.
Definition: stdinc.h:99
unsigned int Exponent
Definition: stdinc.h:89
static const size_t BitsPerWord
Definition: stdinc.h:94
unsigned long Word
The native unsigned type for the CPU.
Definition: stdinc.h:93