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.
9 * Copyright (c) 2001, Nvidia Corporation. All rights reserved.
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.
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.
22 * The file is placed here to allow for the possibility of all driver
23 * components using the same naming convention for conditional compilation.
29 /*****************************************************************************/
30 // Define all OS/CPU-Chip related symbols
32 // ***** DOS variations
33 #if defined(__DJGPP__)
37 // ***** WINDOWS variations
38 #if defined(_WIN32) || defined(_WIN16)
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
48 #endif // _WIN32 || defined(_WIN16)
50 // ***** Unix variations
51 #if defined(__linux__) && !defined(NV_LINUX)
53 #endif // defined(__linux__)
56 #if defined(__sun__) && defined(__svr4__)
58 #endif // defined(__sun__) && defined(__svr4__)
60 // SunOS + Sun Compiler (named SunPro, Studio or Forte)
61 #if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
64 #endif // defined(_SUNPRO_C) || defined(__SUNPRO_CC)
66 #if defined(__FreeBSD__)
68 #endif // defined(__FreeBSD__)
70 #if defined(__DragonFly__)
72 #endif // defined(__DragonFly__)
74 // XXXar don't define NV_UNIX on MacOSX or vxworks or dos or QNX
75 #if (defined(__unix__) || defined(__unix) ) && !defined(macosx) && !defined(vxworks) && !defined(__DJGPP__) && !defined(NV_UNIX) && !defined(__QNX__) && !defined(__QNXNTO__)// XXX until removed from Makefiles
77 #endif // defined(__unix__)
79 #if (defined(__QNX__) || defined(__QNXNTO__)) && !defined(NV_QNX)
83 // ***** Apple variations
84 #if defined(macintosh) || defined(__APPLE__)
86 # if defined(__MACH__)
87 # define NV_MACINTOSH_OSX
89 # define NV_MACINTOSH_OS9
91 # if defined(__LP64__)
92 # define NV_MACINTOSH_64
94 #endif // defined(macintosh)
97 // Tornado 2.21 is gcc 2.96 and #defines __vxworks.
98 // Tornado 2.02 is gcc 2.7.2 and doesn't define any OS symbol, so we rely on
99 // the build system #defining vxworks.
100 #if defined(__vxworks) || defined(vxworks)
104 // ***** Integrity OS
105 #if defined(__INTEGRITY)
106 # if !defined(NV_INTEGRITY)
107 # define NV_INTEGRITY
111 // ***** Processor type variations
112 // Note: The prefix NV_CPU_* is taken by \\sw\main\sdk\nvidia\inc\Nvcm.h
114 #if ((defined(_M_IX86) || defined(__i386__) || defined(__i386)) && !defined(NVCPU_X86)) // XXX until removed from Makefiles
115 // _M_IX86 for windows, __i386__ for Linux (or any x86 using gcc)
116 // __i386 for Studio compiler on Solaris x86
117 # define NVCPU_X86 // any IA32 machine (not x86-64)
118 # define NVCPU_MIN_PAGE_SHIFT 12
121 #if defined(_WIN32) && defined(_M_IA64)
122 # define NVCPU_IA64_WINDOWS // any IA64 for Windows opsys
124 #if defined(NV_LINUX) && defined(__ia64__)
125 # define NVCPU_IA64_LINUX // any IA64 for Linux opsys
127 #if defined(NVCPU_IA64_WINDOWS) || defined(NVCPU_IA64_LINUX) || defined(IA64)
128 # define NVCPU_IA64 // any IA64 for any opsys
131 #if (defined(NV_MACINTOSH) && !(defined(__i386__) || defined(__x86_64__))) || defined(__PPC__) || defined(__ppc)
133 # define NVCPU_PPC // any PowerPC architecture
135 # ifndef NV_BIG_ENDIAN
136 # define NV_BIG_ENDIAN
140 #if defined(__x86_64) || defined(AMD64) || defined(_M_AMD64)
141 # define NVCPU_X86_64 // any x86-64 for any opsys
144 #if defined(__arm__) || defined(_M_ARM)
146 # define NVCPU_MIN_PAGE_SHIFT 12
151 # define NVCPU_SH4 // Renesas (formerly Hitachi) SH4
153 # if defined NV_WINDOWS_CE
154 # define NVCPU_MIN_PAGE_SHIFT 12
158 // For Xtensa processors
159 #if defined(__XTENSA__)
160 # define NVCPU_XTENSA
161 # if defined(__XTENSA_EB__)
162 # define NV_BIG_ENDIAN
167 // Other flavors of CPU type should be determined at run-time.
168 // For example, an x86 architecture with/without SSE.
169 // If it can compile, then there's no need for a compile time option.
170 // For some current GCC limitations, these may be fixed by using the Intel
171 // compiler for certain files in a Linux build.
174 // The minimum page size can be determined from the minimum page shift
175 #if defined(NVCPU_MIN_PAGE_SHIFT)
176 #define NVCPU_MIN_PAGE_SIZE (1 << NVCPU_MIN_PAGE_SHIFT)
179 #if defined(NVCPU_IA64) || defined(NVCPU_X86_64) || defined(NV_MACINTOSH_64)
180 # define NV_64_BITS // all architectures where pointers are 64 bits
182 // we assume 32 bits. I don't see a need for NV_16_BITS.
185 // NOTE: NV_INT64_OK is not needed in the OpenGL driver for any platform
186 // we care about these days. The only consideration is that Linux does not
187 // have a 64-bit divide on the server. To get around this, we convert the
188 // expression to (double) for the division.
189 #if (!(defined(macintosh) || defined(vxworks) || defined(__INTEL_COMPILER)) || defined(NV_LINUX)) && !defined(NV_INT64_OK)
193 // For verification-only features not intended to be included in normal drivers
194 #if defined(NV_MODS) && defined(DEBUG) && !defined(NV_DOS) && !defined(VISTA_MFG_MODS) && !defined(LINUX_MFG)
195 #define NV_VERIF_FEATURES
200 * New, safer family of #define's -- these ones use 0 vs. 1 rather than
201 * defined/!defined. This is advantageous because if you make a typo, say:
203 * #if NVCPU_IS_BIG_ENDAIN // Oops! Endian is misspelled
205 * ...some compilers can give you a warning telling you that you screwed up.
206 * The compiler can also give you a warning if you forget to #include
207 * "cpuopsys.h" in your code before the point where you try to use these
210 * Also, the names have been prefixed in more cases with "CPU" or "OS" for
211 * increased clarity. You can tell the names apart from the old ones because
212 * they all use "_IS_" in the name.
214 * Finally, these can be used in "if" statements and not just in #if's. For
217 * if (NVCPU_IS_BIG_ENDIAN) x = Swap32(x);
219 * Maybe some day in the far-off future these can replace the old #define's.
221 #if defined(NV_WINDOWS)
222 #define NVOS_IS_WINDOWS 1
224 #define NVOS_IS_WINDOWS 0
226 #if defined(NV_WINDOWS_CE)
227 #define NVOS_IS_WINDOWS_CE 1
229 #define NVOS_IS_WINDOWS_CE 0
231 #if defined(NV_LINUX)
232 #define NVOS_IS_LINUX 1
234 #define NVOS_IS_LINUX 0
237 #define NVOS_IS_UNIX 1
239 #define NVOS_IS_UNIX 0
242 #define NVOS_IS_QNX 1
244 #define NVOS_IS_QNX 0
246 #if defined(NV_MACINTOSH)
247 #define NVOS_IS_MACINTOSH 1
249 #define NVOS_IS_MACINTOSH 0
251 #if defined(NV_VXWORKS)
252 #define NVOS_IS_VXWORKS 1
254 #define NVOS_IS_VXWORKS 0
256 #if defined(NV_INTEGRITY)
257 #define NVOS_IS_INTEGRITY 1
259 #define NVOS_IS_INTEGRITY 0
261 #if defined(NVCPU_X86)
262 #define NVCPU_IS_X86 1
264 #define NVCPU_IS_X86 0
266 #if defined(NVCPU_IA64)
267 #define NVCPU_IS_IA64 1
269 #define NVCPU_IS_IA64 0
271 #if defined(NVCPU_X86_64)
272 #define NVCPU_IS_X86_64 1
274 #define NVCPU_IS_X86_64 0
276 #if defined(NVCPU_PPC)
277 #define NVCPU_IS_PPC 1
279 #define NVCPU_IS_PPC 0
281 #if defined(NVCPU_ARM)
282 #define NVCPU_IS_ARM 1
284 #define NVCPU_IS_ARM 0
286 #if defined(NVCPU_SH4)
287 #define NVCPU_IS_SH4 1
289 #define NVCPU_IS_SH4 0
291 #if defined(NVCPU_XTENSA)
292 #define NVCPU_IS_XTENSA 1
294 #define NVCPU_IS_XTENSA 0
296 #if defined(NV_BIG_ENDIAN)
297 #define NVCPU_IS_BIG_ENDIAN 1
299 #define NVCPU_IS_BIG_ENDIAN 0
301 #if defined(NV_64_BITS)
302 #define NVCPU_IS_64_BITS 1
304 #define NVCPU_IS_64_BITS 0
307 /*****************************************************************************/
309 #endif /* __cpuopsys_h_ */