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) && !defined(NV_VMWARE)
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 // 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
73 #endif // defined(__unix__)
75 #if (defined(__QNX__) || defined(__QNXNTO__)) && !defined(NV_QNX)
79 // ***** Apple variations
80 #if defined(macintosh) || defined(__APPLE__)
82 # if defined(__MACH__)
83 # define NV_MACINTOSH_OSX
85 # define NV_MACINTOSH_OS9
87 # if defined(__LP64__)
88 # define NV_MACINTOSH_64
90 #endif // defined(macintosh)
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)
100 // ***** Integrity OS
101 #if defined(__INTEGRITY)
102 # if !defined(NV_INTEGRITY)
103 # define NV_INTEGRITY
107 // ***** Processor type variations
108 // Note: The prefix NV_CPU_* is taken by \\sw\main\sdk\nvidia\inc\Nvcm.h
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
117 #if defined(_WIN32) && defined(_M_IA64)
118 # define NVCPU_IA64_WINDOWS // any IA64 for Windows opsys
120 #if defined(NV_LINUX) && defined(__ia64__)
121 # define NVCPU_IA64_LINUX // any IA64 for Linux opsys
123 #if defined(NVCPU_IA64_WINDOWS) || defined(NVCPU_IA64_LINUX) || defined(IA64)
124 # define NVCPU_IA64 // any IA64 for any opsys
127 #if (defined(NV_MACINTOSH) && !(defined(__i386__) || defined(__x86_64__))) || defined(__PPC__) || defined(__ppc)
129 # define NVCPU_PPC // any PowerPC architecture
131 # ifndef NV_BIG_ENDIAN
132 # define NV_BIG_ENDIAN
136 #if defined(__x86_64) || defined(AMD64) || defined(_M_AMD64)
137 # define NVCPU_X86_64 // any x86-64 for any opsys
140 #if defined(__arm__) || defined(_M_ARM)
142 # define NVCPU_MIN_PAGE_SHIFT 12
147 # define NVCPU_SH4 // Renesas (formerly Hitachi) SH4
149 # if defined NV_WINDOWS_CE
150 # define NVCPU_MIN_PAGE_SHIFT 12
154 // For Xtensa processors
155 #if defined(__XTENSA__)
156 # define NVCPU_XTENSA
157 # if defined(__XTENSA_EB__)
158 # define NV_BIG_ENDIAN
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.
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)
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
178 // we assume 32 bits. I don't see a need for NV_16_BITS.
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)
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
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:
199 * #if NVCPU_IS_BIG_ENDAIN // Oops! Endian is misspelled
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
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.
210 * Finally, these can be used in "if" statements and not just in #if's. For
213 * if (NVCPU_IS_BIG_ENDIAN) x = Swap32(x);
215 * Maybe some day in the far-off future these can replace the old #define's.
217 #if defined(NV_WINDOWS)
218 #define NVOS_IS_WINDOWS 1
220 #define NVOS_IS_WINDOWS 0
222 #if defined(NV_WINDOWS_CE)
223 #define NVOS_IS_WINDOWS_CE 1
225 #define NVOS_IS_WINDOWS_CE 0
227 #if defined(NV_LINUX)
228 #define NVOS_IS_LINUX 1
230 #define NVOS_IS_LINUX 0
233 #define NVOS_IS_UNIX 1
235 #define NVOS_IS_UNIX 0
238 #define NVOS_IS_QNX 1
240 #define NVOS_IS_QNX 0
242 #if defined(NV_MACINTOSH)
243 #define NVOS_IS_MACINTOSH 1
245 #define NVOS_IS_MACINTOSH 0
247 #if defined(NV_VXWORKS)
248 #define NVOS_IS_VXWORKS 1
250 #define NVOS_IS_VXWORKS 0
252 #if defined(NV_INTEGRITY)
253 #define NVOS_IS_INTEGRITY 1
255 #define NVOS_IS_INTEGRITY 0
257 #if defined(NVCPU_X86)
258 #define NVCPU_IS_X86 1
260 #define NVCPU_IS_X86 0
262 #if defined(NVCPU_IA64)
263 #define NVCPU_IS_IA64 1
265 #define NVCPU_IS_IA64 0
267 #if defined(NVCPU_X86_64)
268 #define NVCPU_IS_X86_64 1
270 #define NVCPU_IS_X86_64 0
272 #if defined(NVCPU_PPC)
273 #define NVCPU_IS_PPC 1
275 #define NVCPU_IS_PPC 0
277 #if defined(NVCPU_ARM)
278 #define NVCPU_IS_ARM 1
280 #define NVCPU_IS_ARM 0
282 #if defined(NVCPU_SH4)
283 #define NVCPU_IS_SH4 1
285 #define NVCPU_IS_SH4 0
287 #if defined(NVCPU_XTENSA)
288 #define NVCPU_IS_XTENSA 1
290 #define NVCPU_IS_XTENSA 0
292 #if defined(NV_BIG_ENDIAN)
293 #define NVCPU_IS_BIG_ENDIAN 1
295 #define NVCPU_IS_BIG_ENDIAN 0
297 #if defined(NV_64_BITS)
298 #define NVCPU_IS_64_BITS 1
300 #define NVCPU_IS_64_BITS 0
303 /*****************************************************************************/
305 #endif /* __cpuopsys_h_ */