adapt for devfs
[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)
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 #if defined(__DragonFly__)
71 #   define NV_BSD
72 #endif // defined(__DragonFly__)
73
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
76 #   define NV_UNIX
77 #endif // defined(__unix__)
78
79 #if (defined(__QNX__) || defined(__QNXNTO__)) && !defined(NV_QNX)
80 #   define NV_QNX
81 #endif
82
83 // ***** Apple variations
84 #if defined(macintosh) || defined(__APPLE__)
85 #   define NV_MACINTOSH
86 #   if defined(__MACH__)
87 #      define NV_MACINTOSH_OSX
88 #   else
89 #      define NV_MACINTOSH_OS9
90 #   endif
91 #   if defined(__LP64__)
92 #      define NV_MACINTOSH_64
93 #   endif
94 #endif  // defined(macintosh)
95
96 // ***** VxWorks
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)
101 #   define NV_VXWORKS
102 #endif
103
104 // ***** Integrity OS
105 #if defined(__INTEGRITY)
106 #  if !defined(NV_INTEGRITY)
107 #    define NV_INTEGRITY
108 #  endif
109 #endif
110
111 // ***** Processor type variations
112 // Note: The prefix NV_CPU_* is taken by \\sw\main\sdk\nvidia\inc\Nvcm.h
113
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
119 #endif
120
121 #if defined(_WIN32) && defined(_M_IA64)
122 #   define NVCPU_IA64_WINDOWS      // any IA64 for Windows opsys
123 #endif
124 #if defined(NV_LINUX) && defined(__ia64__)
125 #   define NVCPU_IA64_LINUX        // any IA64 for Linux opsys
126 #endif
127 #if defined(NVCPU_IA64_WINDOWS) || defined(NVCPU_IA64_LINUX) || defined(IA64)
128 #   define NVCPU_IA64              // any IA64 for any opsys
129 #endif
130
131 #if (defined(NV_MACINTOSH) && !(defined(__i386__) || defined(__x86_64__)))  || defined(__PPC__) || defined(__ppc)
132 #   ifndef NVCPU_PPC
133 #   define NVCPU_PPC               // any PowerPC architecture
134 #   endif
135 #   ifndef NV_BIG_ENDIAN
136 #   define NV_BIG_ENDIAN
137 #   endif
138 #endif
139
140 #if defined(__x86_64) || defined(AMD64) || defined(_M_AMD64)
141 #    define NVCPU_X86_64           // any x86-64 for any opsys
142 #endif
143
144 #if defined(__arm__) || defined(_M_ARM)
145 #   define NVCPU_ARM
146 #   define NVCPU_MIN_PAGE_SHIFT 12
147 #endif
148
149 #if defined(__SH4__)
150 #   ifndef NVCPU_SH4
151 #   define NVCPU_SH4               // Renesas (formerly Hitachi) SH4
152 #   endif
153 #   if   defined NV_WINDOWS_CE
154 #       define NVCPU_MIN_PAGE_SHIFT 12
155 #   endif
156 #endif
157
158 // For Xtensa processors
159 #if defined(__XTENSA__)
160 # define NVCPU_XTENSA
161 # if defined(__XTENSA_EB__)
162 #  define NV_BIG_ENDIAN
163 # endif
164 #endif
165
166
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.
172
173
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)
177 #endif
178
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
181 #else
182     // we assume 32 bits. I don't see a need for NV_16_BITS.
183 #endif
184
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)
190 #define NV_INT64_OK
191 #endif
192
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
196 #endif
197
198
199 /*
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:
202  *
203  *   #if NVCPU_IS_BIG_ENDAIN    // Oops!  Endian is misspelled
204  *
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
208  * conditionals.
209  *
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.
213  *
214  * Finally, these can be used in "if" statements and not just in #if's.  For
215  * example:
216  *
217  *   if (NVCPU_IS_BIG_ENDIAN) x = Swap32(x);
218  *
219  * Maybe some day in the far-off future these can replace the old #define's.
220  */
221 #if defined(NV_WINDOWS)
222 #define NVOS_IS_WINDOWS 1
223 #else
224 #define NVOS_IS_WINDOWS 0
225 #endif
226 #if defined(NV_WINDOWS_CE)
227 #define NVOS_IS_WINDOWS_CE 1
228 #else
229 #define NVOS_IS_WINDOWS_CE 0
230 #endif
231 #if defined(NV_LINUX)
232 #define NVOS_IS_LINUX 1
233 #else
234 #define NVOS_IS_LINUX 0
235 #endif
236 #if defined(NV_UNIX)
237 #define NVOS_IS_UNIX 1
238 #else
239 #define NVOS_IS_UNIX 0
240 #endif
241 #if defined(NV_QNX)
242 #define NVOS_IS_QNX 1
243 #else
244 #define NVOS_IS_QNX 0
245 #endif
246 #if defined(NV_MACINTOSH)
247 #define NVOS_IS_MACINTOSH 1
248 #else
249 #define NVOS_IS_MACINTOSH 0
250 #endif
251 #if defined(NV_VXWORKS)
252 #define NVOS_IS_VXWORKS 1
253 #else
254 #define NVOS_IS_VXWORKS 0
255 #endif
256 #if defined(NV_INTEGRITY)
257 #define NVOS_IS_INTEGRITY 1
258 #else
259 #define NVOS_IS_INTEGRITY 0
260 #endif
261 #if defined(NVCPU_X86)
262 #define NVCPU_IS_X86 1
263 #else
264 #define NVCPU_IS_X86 0
265 #endif
266 #if defined(NVCPU_IA64)
267 #define NVCPU_IS_IA64 1
268 #else
269 #define NVCPU_IS_IA64 0
270 #endif
271 #if defined(NVCPU_X86_64)
272 #define NVCPU_IS_X86_64 1
273 #else
274 #define NVCPU_IS_X86_64 0
275 #endif
276 #if defined(NVCPU_PPC)
277 #define NVCPU_IS_PPC 1
278 #else
279 #define NVCPU_IS_PPC 0
280 #endif
281 #if defined(NVCPU_ARM)
282 #define NVCPU_IS_ARM 1
283 #else
284 #define NVCPU_IS_ARM 0
285 #endif
286 #if defined(NVCPU_SH4)
287 #define NVCPU_IS_SH4 1
288 #else
289 #define NVCPU_IS_SH4 0
290 #endif
291 #if defined(NVCPU_XTENSA)
292 #define NVCPU_IS_XTENSA 1
293 #else
294 #define NVCPU_IS_XTENSA 0
295 #endif
296 #if defined(NV_BIG_ENDIAN)
297 #define NVCPU_IS_BIG_ENDIAN 1
298 #else
299 #define NVCPU_IS_BIG_ENDIAN 0
300 #endif
301 #if defined(NV_64_BITS)
302 #define NVCPU_IS_64_BITS 1
303 #else
304 #define NVCPU_IS_64_BITS 0
305 #endif
306
307 /*****************************************************************************/
308
309 #endif /* __cpuopsys_h_ */