1 /****
2  * common.h
3  *
4  * Definitions common to all files.
5  *****/
6 
7 #ifndef COMMON_H
8 #define COMMON_H
9 
10 #undef NDEBUG
11 
12 #include <iostream>
13 #include <climits>
14 
15 #ifdef __CYGWIN__
16 #undef LONG_LONG_MAX
17 #define LONG_LONG_MAX __LONG_LONG_MAX__
18 #undef LONG_LONG_MIN
19 #define LONG_LONG_MIN (-LONG_LONG_MAX-1)
20 #endif
21 
22 #ifdef HAVE_CONFIG_H
23 #include "config.h"
24 #endif
25 
26 #if !defined(FOR_SHARED) && defined(HAVE_LIBGLU) && \
27   ((defined(HAVE_LIBGL) && defined(HAVE_LIBGLUT)) || defined(HAVE_LIBOSMESA))
28 #define HAVE_GL
29 #endif
30 
31 #ifdef HAVE_PTHREAD
32 #include <pthread.h>
33 #endif
34 
35 #include "memory.h"
36 
37 #if defined(HAVE_LONG_LONG) && defined(LONG_LONG_MAX) && defined(LONG_LONG_MIN)
38 #define Int_MAX2 LONG_LONG_MAX
39 #define Int_MIN LONG_LONG_MIN
40 typedef long long Int;
41 typedef unsigned long long unsignedInt;
42 #else
43 #undef HAVE_LONG_LONG
44 #ifdef HAVE_LONG
45 #define Int_MAX2 LONG_MAX
46 #define Int_MIN LONG_MIN
47 typedef long Int;
48 typedef unsigned long unsignedInt;
49 #else
50 #define Int_MAX2 INT_MAX
51 #define Int_MIN INT_MIN
52 typedef int Int;
53 typedef unsigned int unsignedInt;
54 #endif
55 #endif
56 
57 #ifndef COMPACT
58 #if Int_MAX2 >= 0x7fffffffffffffffLL
59 #define COMPACT 1
60 #else
61 #define COMPACT 0
62 #endif
63 #endif
64 
65 #if COMPACT
66 // Reserve highest two values for DefaultValue and Undefined states.
67 #define Int_MAX (Int_MAX2-2)
68 #define int_MAX (LONG_MAX-2)
69 #else
70 #define Int_MAX Int_MAX2
71 #define int_MAX LONG_MAX
72 #endif
73 
74 #define int_MIN LONG_MIN
75 
76 #define RANDOM_MAX 0x7FFFFFFF
77 
78 using std::cout;
79 using std::cin;
80 using std::cerr;
81 using std::endl;
82 using std::istream;
83 using std::ostream;
84 
85 using mem::string;
86 using mem::stringstream;
87 using mem::istringstream;
88 using mem::ostringstream;
89 using mem::stringbuf;
90 
91 #endif
92