import NVIDIA-FreeBSD-x86-190.42
[nvidia.git] / src / cpuopsys.h
1
2 /*! \brief
3  * Define compile time symbols for CPU type and operating system type.
4  * This file should only contain preprocessor commands so that
5  * there are no dependencies on other files.
6  *
7  * cpuopsys.h
8  *
9  * Copyright (c) 2001, Nvidia Corporation.  All rights reserved.
10  */
11
12 /*!
13  * Uniform names are defined for compile time options to distinguish
14  * CPU types and Operating systems.
15  * Distinctions between CPU and OpSys should be orthogonal.
16  *
17  * These uniform names have initially been defined by keying off the
18  * makefile/build names defined for builds in the OpenGL group.
19  * Getting the uniform names defined for other builds may require
20  * different qualifications.
21  *
22  * The file is placed here to allow for the possibility of all driver
23  * components using the same naming convention for conditional compilation.
24  */
25
26 #ifndef __cpuopsys_h_
27 #define __cpuopsys_h_
28
29 /*****************************************************************************/
30 // Define all OS/CPU-Chip related symbols
31
32 // ***** DOS variations
33 #if defined(__DJGPP__)
34 #   define NV_DOS
35 #endif
36
37 // ***** WINDOWS variations
38 #if defined(_WIN32) || defined(_WIN16)
39 #   define NV_WINDOWS
40
41 #   if defined(_WIN32_WINNT)
42 #      define NV_WINDOWS_NT
43 #   elif defined(_WIN32_WCE)
44 #      define NV_WINDOWS_CE
45 #   elif !defined(NV_MODS)
46 #      define NV_WINDOWS_9X
47 #   endif
48 #endif  // _WIN32 || defined(_WIN16)
49
50 // ***** Unix variations
51 #if defined(__linux__) && !defined(NV_LINUX) && !defined(NV_VMWARE)
52 #   define NV_LINUX
53 #endif  // defined(__linux__)
54
55 // SunOS + gcc
56 #if defined(__sun__) && defined(__svr4__)
57 #   define NV_SUNOS
58 #endif // defined(__sun__) && defined(__svr4__)
59
60 // SunOS + Sun Compiler (named SunPro, Studio or Forte)
61 #if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
62 #   define NV_SUNPRO_C
63 #   define NV_SUNOS
64 #endif // defined(_SUNPRO_C) || defined(__SUNPRO_CC)
65
66 #if defined(__FreeBSD__)
67 #   define NV_BSD
68 #endif // defined(__FreeBSD__)
69
70 // XXXar don't define NV_UNIX on MacOSX or vxworks or dos or QNX
71 #if (defined(__unix__) || defined(__unix) ) && !defined(macosx) && !defined(vxworks) && !defined(__DJGPP__) && !defined(NV_UNIX) && !defined(__QNX__) && !defined(__QNXNTO__)// XXX until removed from Makefiles
72 #   define NV_UNIX
73 #endif // defined(__unix__)
74
75 #if (defined(__QNX__) || defined(__QNXNTO__)) && !defined(NV_QNX)
76 #   define NV_QNX
77 #endif
78
79 // ***** Apple variations
80 #if defined(macintosh) || defined(__APPLE__)
81 #   define NV_MACINTOSH
82 #   if defined(__MACH__)
83 #      define NV_MACINTOSH_OSX
84 #   else
85 #      define NV_MACINTOSH_OS9
86 #   endif
87 #   if defined(__LP64__)
88 #      define NV_MACINTOSH_64
89 #   endif
90 #endif  // defined(macintosh)
91
92 // ***** VxWorks
93 // Tornado 2.21 is gcc 2.96 and #defines __vxworks.
94 // Tornado 2.02 is gcc 2.7.2 and doesn't define any OS symbol, so we rely on
95 // the build system #defining vxworks.
96 #if defined(__vxworks) || defined(vxworks)
97 #   define NV_VXWORKS
98 #endif
99
100 // ***** Integrity OS
101 #if defined(__INTEGRITY)
102 #  if !defined(NV_INTEGRITY)
103 #    define NV_INTEGRITY
104 #  endif
105 #endif
106
107 // ***** Processor type variations
108 // Note: The prefix NV_CPU_* is taken by \\sw\main\sdk\nvidia\inc\Nvcm.h
109
110 #if ((defined(_M_IX86) || defined(__i386__) || defined(__i386)) && !defined(NVCPU_X86)) // XXX until removed from Makefiles
111     // _M_IX86 for windows, __i386__ for Linux (or any x86 using gcc)
112     // __i386 for Studio compiler on Solaris x86
113 #   define NVCPU_X86               // any IA32 machine (not x86-64)
114 #   define NVCPU_MIN_PAGE_SHIFT 12
115 #endif
116
117 #if defined(_WIN32) && defined(_M_IA64)
118 #   define NVCPU_IA64_WINDOWS      // any IA64 for Windows opsys
119 #endif
120 #if defined(NV_LINUX) && defined(__ia64__)
121 #   define NVCPU_IA64_LINUX        // any IA64 for Linux opsys
122 #endif
123 #if defined(NVCPU_IA64_WINDOWS) || defined(NVCPU_IA64_LINUX) || defined(IA64)
124 #   define NVCPU_IA64              // any IA64 for any opsys
125 #endif
126
127 #if (defined(NV_MACINTOSH) && !(defined(__i386__) || defined(__x86_64__)))  || defined(__PPC__) || defined(__ppc)
128 #   ifndef NVCPU_PPC
129 #   define NVCPU_PPC               // any PowerPC architecture
130 #   endif
131 #   ifndef NV_BIG_ENDIAN
132 #   define NV_BIG_ENDIAN
133 #   endif
134 #endif
135
136 #if defined(__x86_64) || defined(AMD64) || defined(_M_AMD64)
137 #    define NVCPU_X86_64           // any x86-64 for any opsys
138 #endif
139
140 #if defined(__arm__) || defined(_M_ARM)
141 #   define NVCPU_ARM
142 #   define NVCPU_MIN_PAGE_SHIFT 12
143 #endif
144
145 #if defined(__SH4__)
146 #   ifndef NVCPU_SH4
147 #   define NVCPU_SH4               // Renesas (formerly Hitachi) SH4
148 #   endif
149 #   if   defined NV_WINDOWS_CE
150 #       define NVCPU_MIN_PAGE_SHIFT 12
151 #   endif
152 #endif
153
154 // For Xtensa processors
155 #if defined(__XTENSA__)
156 # define NVCPU_XTENSA
157 # if defined(__XTENSA_EB__)
158 #  define NV_BIG_ENDIAN
159 # endif
160 #endif
161
162
163 // Other flavors of CPU type should be determined at run-time.
164 // For example, an x86 architecture with/without SSE.
165 // If it can compile, then there's no need for a compile time option.
166 // For some current GCC limitations, these may be fixed by using the Intel
167 // compiler for certain files in a Linux build.
168
169
170 // The minimum page size can be determined from the minimum page shift
171 #if defined(NVCPU_MIN_PAGE_SHIFT)
172 #define NVCPU_MIN_PAGE_SIZE (1 << NVCPU_MIN_PAGE_SHIFT)
173 #endif
174
175 #if defined(NVCPU_IA64) || defined(NVCPU_X86_64) || defined(NV_MACINTOSH_64)
176 #   define NV_64_BITS          // all architectures where pointers are 64 bits
177 #else
178     // we assume 32 bits. I don't see a need for NV_16_BITS.
179 #endif
180
181 // NOTE: NV_INT64_OK is not needed in the OpenGL driver for any platform
182 // we care about these days. The only consideration is that Linux does not
183 // have a 64-bit divide on the server. To get around this, we convert the
184 // expression to (double) for the division.
185 #if (!(defined(macintosh) || defined(vxworks) || defined(__INTEL_COMPILER)) || defined(NV_LINUX)) && !defined(NV_INT64_OK)
186 #define NV_INT64_OK
187 #endif
188
189 // For verification-only features not intended to be included in normal drivers
190 #if defined(NV_MODS) && defined(DEBUG) && !defined(NV_DOS) && !defined(VISTA_MFG_MODS) && !defined(LINUX_MFG)
191 #define NV_VERIF_FEATURES
192 #endif
193
194
195 /*
196  * New, safer family of #define's -- these ones use 0 vs. 1 rather than
197  * defined/!defined.  This is advantageous because if you make a typo, say:
198  *
199  *   #if NVCPU_IS_BIG_ENDAIN    // Oops!  Endian is misspelled
200  *
201  * ...some compilers can give you a warning telling you that you screwed up.
202  * The compiler can also give you a warning if you forget to #include
203  * "cpuopsys.h" in your code before the point where you try to use these
204  * conditionals.
205  *
206  * Also, the names have been prefixed in more cases with "CPU" or "OS" for
207  * increased clarity.  You can tell the names apart from the old ones because
208  * they all use "_IS_" in the name.
209  *
210  * Finally, these can be used in "if" statements and not just in #if's.  For
211  * example:
212  *
213  *   if (NVCPU_IS_BIG_ENDIAN) x = Swap32(x);
214  *
215  * Maybe some day in the far-off future these can replace the old #define's.
216  */
217 #if defined(NV_WINDOWS)
218 #define NVOS_IS_WINDOWS 1
219 #else
220 #define NVOS_IS_WINDOWS 0
221 #endif
222 #if defined(NV_WINDOWS_CE)
223 #define NVOS_IS_WINDOWS_CE 1
224 #else
225 #define NVOS_IS_WINDOWS_CE 0
226 #endif
227 #if defined(NV_LINUX)
228 #define NVOS_IS_LINUX 1
229 #else
230 #define NVOS_IS_LINUX 0
231 #endif
232 #if defined(NV_UNIX)
233 #define NVOS_IS_UNIX 1
234 #else
235 #define NVOS_IS_UNIX 0
236 #endif
237 #if defined(NV_QNX)
238 #define NVOS_IS_QNX 1
239 #else
240 #define NVOS_IS_QNX 0
241 #endif
242 #if defined(NV_MACINTOSH)
243 #define NVOS_IS_MACINTOSH 1
244 #else
245 #define NVOS_IS_MACINTOSH 0
246 #endif
247 #if defined(NV_VXWORKS)
248 #define NVOS_IS_VXWORKS 1
249 #else
250 #define NVOS_IS_VXWORKS 0
251 #endif
252 #if defined(NV_INTEGRITY)
253 #define NVOS_IS_INTEGRITY 1
254 #else
255 #define NVOS_IS_INTEGRITY 0
256 #endif
257 #if defined(NVCPU_X86)
258 #define NVCPU_IS_X86 1
259 #else
260 #define NVCPU_IS_X86 0
261 #endif
262 #if defined(NVCPU_IA64)
263 #define NVCPU_IS_IA64 1
264 #else
265 #define NVCPU_IS_IA64 0
266 #endif
267 #if defined(NVCPU_X86_64)
268 #define NVCPU_IS_X86_64 1
269 #else
270 #define NVCPU_IS_X86_64 0
271 #endif
272 #if defined(NVCPU_PPC)
273 #define NVCPU_IS_PPC 1
274 #else
275 #define NVCPU_IS_PPC 0
276 #endif
277 #if defined(NVCPU_ARM)
278 #define NVCPU_IS_ARM 1
279 #else
280 #define NVCPU_IS_ARM 0
281 #endif
282 #if defined(NVCPU_SH4)
283 #define NVCPU_IS_SH4 1
284 #else
285 #define NVCPU_IS_SH4 0
286 #endif
287 #if defined(NVCPU_XTENSA)
288 #define NVCPU_IS_XTENSA 1
289 #else
290 #define NVCPU_IS_XTENSA 0
291 #endif
292 #if defined(NV_BIG_ENDIAN)
293 #define NVCPU_IS_BIG_ENDIAN 1
294 #else
295 #define NVCPU_IS_BIG_ENDIAN 0
296 #endif
297 #if defined(NV_64_BITS)
298 #define NVCPU_IS_64_BITS 1
299 #else
300 #define NVCPU_IS_64_BITS 0
301 #endif
302
303 /*****************************************************************************/
304
305 #endif /* __cpuopsys_h_ */