Debian Codegraph @

rpython/translator/c/src/commondefs.h

raw symbols SCIP
1
2 /************************************************************/
3 /*** C header subsection: common types and macros ***/
4
5
6 /* We only support the following two kinds of platform:
7
8 int long long long void*
9 --32-bit-- 32 32 64 32
10 --64-bit-- 32 64 64 64
11
12 In particular, Win64 is not supported because it has sizeof(long) == 4.
13 To fix this, find and review all the places that cast a pointer to a long.
14
15 Update:
16 We are trying to lift this restriction for Win64:
17
18 Win64 int long long long void*
19 --64-bit-- 32 32 64 64
20
21 The migration to this platform is complicated and tedious, because
22 PyPy assumes that a void* fits into a long. Therefore, the created PyPy
23 will (first) have a 64 bit int type. The dependency of sys.maxint must
24 be removed in very many places, and the distinction between Python int
25 and long must be changed in explicit range checks.
26
27 This is work in progress with first successes.
28
29 */
30
31 #if defined(__MINGW32__)
32 # include <windows.h>
33 #endif
34 #include <limits.h>
35
36 #ifndef LLONG_MAX
37 #define LLONG_MAX __LONG_LONG_MAX__
38 #endif
39 #ifndef LLONG_MIN
40 #define LLONG_MIN (-LLONG_MAX - 1LL)
41 #endif
42
43 #if INT_MAX != 2147483647
44 # error "unsupported value for INT_MAX"
45 #endif
46 #if INT_MIN != -2147483647-1
47 # error "unsupported value for INT_MIN"
48 #endif
49
50 #if LLONG_MAX != 9223372036854775807LL
51 # error "unsupported value for LLONG_MAX"
52 #endif
53 #if LLONG_MIN != -9223372036854775807LL-1LL
54 # error "unsupported value for LLONG_MIN"
55 #endif
56
57
58 /******************** 32-bit support ********************/
59 #if PYPY_LONG_BIT == 32
60
61 # if LONG_MAX != 2147483647L
62 # error "error in LONG_MAX (32-bit sources but a 64-bit compiler?)"
63 # endif
64 # if LONG_MIN != -2147483647L-1L
65 # error "unsupported value for LONG_MIN"
66 # endif
67
68 # define SIZEOF_INT 4
69 # define SIZEOF_LONG 4
70 # define SIZEOF_SIGNED 4
71 # define SIZEOF_LONG_LONG 8
72
73 /******************** 64-bit support ********************/
74 #else
75
76 # ifndef _WIN64
77 # if LONG_MAX != 9223372036854775807L
78 # error "error in LONG_MAX (64-bit sources but a 32-bit compiler?)"
79 # endif
80 # if LONG_MIN != -9223372036854775807L-1L
81 # error "unsupported value for LONG_MIN"
82 # endif
83
84 # define SIZEOF_INT 4
85 # define SIZEOF_LONG 8
86 # define SIZEOF_SIGNED 8
87 # define SIZEOF_LONG_LONG 8
88
89 /******************** Win-64 support ********************/
90 # else
91 # if LONG_MAX != 2147483647L
92 # error "error in LONG_MAX (64-bit sources but incompatible compiler?)"
93 # endif
94 # if LONG_MIN != -2147483647L-1L
95 # error "unsupported value for LONG_MIN"
96 # endif
97
98 # define SIZEOF_INT 4
99 # define SIZEOF_LONG 4
100 # define SIZEOF_SIGNED 8
101 # define SIZEOF_LONG_LONG 8
102
103 # endif
104
105 #endif
106
107 /********************************************************/
108
109 #if ((-1) >> 1) > 0
110 # define Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J) \
111 ((I) < 0 ? -1-((-1-(I)) >> (J)) : (I) >> (J))
112 #elif ((-1) >> 1) == -1
113 # define Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J) ((I) >> (J))
114 #else
115 # error "uh? strange result"
116 #endif
117
118 #define HAVE_LONG_LONG 1
119 #define Py_HUGE_VAL HUGE_VAL
120
121 #ifdef _WIN32
122 #ifndef MS_WINDOWS
123 # define MS_WINDOWS /* a synonym */
124 #endif
125 #endif
126
127 /* stringify a constant */
128 #define Py_XSTR(x) #x
129 #define Py_STR(x) Py_XSTR(x)