1 /***************************************************************************\
3 |* Copyright 1993-1998 NVIDIA, Corporation. All rights reserved. *|
5 |* NOTICE TO USER: The source code is copyrighted under U.S. and *|
6 |* international laws. Users and possessors of this source code are *|
7 |* hereby granted a nonexclusive, royalty-free copyright license to *|
8 |* use this code in individual and commercial software. *|
10 |* Any use of this source code must include, in the user documenta- *|
11 |* tion and internal comments to the code, notices to the end user *|
14 |* Copyright 1993-1998 NVIDIA, Corporation. All rights reserved. *|
16 |* NVIDIA, CORPORATION MAKES NO REPRESENTATION ABOUT THE SUITABILITY *|
17 |* OF THIS SOURCE CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" *|
18 |* WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND. NVIDIA, CORPOR- *|
19 |* ATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOURCE CODE, *|
20 |* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGE- *|
21 |* MENT, AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL *|
22 |* NVIDIA, CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT, INCI- *|
23 |* DENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RE- *|
24 |* SULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION *|
25 |* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF *|
26 |* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE. *|
28 |* U.S. Government End Users. This source code is a "commercial *|
29 |* item," as that term is defined at 48 C.F.R. 2.101 (OCT 1995), *|
30 |* consisting of "commercial computer software" and "commercial *|
31 |* computer software documentation," as such terms are used in *|
32 |* 48 C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Govern- *|
33 |* ment only as a commercial end item. Consistent with 48 C.F.R. *|
34 |* 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), *|
35 |* all U.S. Government End Users acquire the source code with only *|
36 |* those rights set forth herein. *|
38 \***************************************************************************/
41 /***************************************************************************\
43 |* NV Architecture Interface *|
45 |* <nvtypes.h> defines common widths used to access hardware in of NVIDIA's *|
46 |* Unified Media Architecture (TM). *|
48 \***************************************************************************/
51 #ifndef NVTYPES_INCLUDED
52 #define NVTYPES_INCLUDED
60 #if defined(NV_64_BITS)
64 /***************************************************************************\
66 \***************************************************************************/
68 typedef unsigned char NvV8; /* "void": enumerated or multiple fields */
69 typedef unsigned short NvV16; /* "void": enumerated or multiple fields */
70 typedef unsigned char NvU8; /* 0 to 255 */
71 typedef unsigned short NvU16; /* 0 to 65535 */
72 typedef signed char NvS8; /* -128 to 127 */
73 typedef signed short NvS16; /* -32768 to 32767 */
74 typedef float NvF32; /* IEEE Single Precision (S1E8M23) */
75 typedef double NvF64; /* IEEE Double Precision (S1E11M52) */
77 /* mainly for 64-bit linux, where long is 64 bits
78 * and win9x, where int is 16 bit.
80 #if (defined(NV_UNIX) || defined(vxworks) || defined(NV_WINDOWS_CE) || \
81 defined(__arm) || defined(__IAR_SYSTEMS_ICC__) || defined(NV_QNX) || \
82 defined(NV_INTEGRITY) || defined(NV_MODS) || defined(__GNUC__) || \
83 defined(NV_MACINTOSH_64)) && \
84 (!defined(NV_MACINTOSH) || defined(NV_MACINTOSH_64))
85 typedef unsigned int NvV32; /* "void": enumerated or multiple fields */
86 typedef unsigned int NvU32; /* 0 to 4294967295 */
88 typedef unsigned long NvV32; /* "void": enumerated or multiple fields */
89 typedef unsigned long NvU32; /* 0 to 4294967295 */
92 // mac os 32-bit still needs this
93 #if defined(NV_MACINTOSH) && !defined(NV_MACINTOSH_64)
94 typedef signed long NvS32; /* -2147483648 to 2147483647 */
96 typedef signed int NvS32; /* -2147483648 to 2147483647 */
99 /* 64-bit types for compilers that support them, plus some obsolete variants */
100 #if defined(__GNUC__) || defined(__arm) || defined(__IAR_SYSTEMS_ICC__) || defined(__ghs__) || defined(_WIN64)
101 typedef unsigned long long NvU64; /* 0 to 18446744073709551615 */
102 typedef long long NvS64; /* 2^-63 to 2^63-1 */
104 typedef unsigned __int64 NvU64; /* 0 to 18446744073709551615 */
105 typedef __int64 NvS64; /* 2^-63 to 2^63-1 */
109 enum { NV_FALSE = 0, NV_TRUE = 1 };
112 /* Macros to extract the low and high parts of a 64-bit unsigned integer */
113 /* Also designed to work if someone happens to pass in a 32-bit integer */
114 #define NvU64_HI32(n) ((NvU32)(((NvU64)(n)) >> 32))
115 #define NvU64_LO32(n) ((NvU32)((NvU64)(n)))
116 #define NvU40_HI32(n) ((NvU32)((((NvU64)(n))>>8)&0xffffffff))
117 #define NvU40_HI24of32(n) ((NvU32)((((NvU64)(n)& 0xffffffff))&0xffffff00))
119 /***************************************************************************\
121 |* 64 bit type definitions for use in interface structures. *|
123 \***************************************************************************/
125 #if defined(NV_64_BITS)
127 typedef void* NvP64; /* 64 bit void pointer */
128 typedef NvU64 NvUPtr; /* pointer sized unsigned int */
130 #define NvP64_VALUE(n) (n)
134 typedef NvU64 NvP64; /* 64 bit void pointer */
135 typedef NvU32 NvUPtr; /* pointer sized unsigned int */
137 #define NvP64_VALUE(n) ((void *)(NvUPtr)(n))
141 // XXX Obsolete -- get rid of me...
142 typedef NvP64 NvP64_VALUE_T;
143 typedef NvUPtr NV_UINTPTR_T;
144 #define NvP64_LVALUE(n) (n)
145 #define NvP64_SELECTOR(n) (0)
147 /* Useful macro to hide required double cast */
148 #define NV_PTR_TO_NvP64(n) (NvP64)(NV_UINTPTR_T)(n)
151 /* MODS needs to be able to build without these definitions because they collide
152 with some definitions used in mdiag. */
153 #ifndef DONT_DEFINE_U032
164 #if defined(MACOS) || defined(macintosh) || defined(__APPLE_CC__) || defined(NV_MODS) || defined(MINIRM) || defined(NV_UNIX) || defined (NV_QNX)
165 /* more obsolete stuff */
166 /* need to provide these on macos9 and macosX */
167 #if defined(__APPLE_CC__) /* gross but Apple osX already claims ULONG */
168 #undef ULONG // just in case
169 #define ULONG unsigned long
171 typedef unsigned long ULONG;
173 typedef unsigned char *PUCHAR;
177 /* Supports 32bit libraries on Win64
178 See drivers\opengl\include\nvFirst.h for explanation */
180 #define CAST_NV_PTR(p) p
183 /* Aligns fields in structs so they match up between 32 and 64 bit builds */
184 /* XXX Mac still uses structures without alignment -- needs to be fixed */
185 #if (defined(__GNUC__) || defined(NV_QNX)) && !defined(NV_MACINTOSH)
186 #define NV_ALIGN_BYTES(size) __attribute__ ((aligned (size)))
188 #define NV_ALIGN_BYTES(size) __align(ALIGN)
190 // XXX This is dangerously nonportable! We really shouldn't provide a default
191 // version of this that doesn't do anything.
192 #define NV_ALIGN_BYTES(size)
195 // NV_DECLARE_ALIGNED() can be used on all platforms.
196 // This macro form accounts for the fact that __declspec on Windows is required
197 // before the variable type,
198 // and NV_ALIGN_BYTES is required after the variable name.
199 #if defined(NV_WINDOWS)
200 #define NV_DECLARE_ALIGNED(TYPE_VAR, ALIGN) __declspec(align(ALIGN)) TYPE_VAR
201 #elif defined(__GNUC__) || defined(NV_QNX)
202 #define NV_DECLARE_ALIGNED(TYPE_VAR, ALIGN) TYPE_VAR __attribute__ ((aligned (ALIGN)))
204 #define NV_DECLARE_ALIGNED(TYPE_VAR, ALIGN) __align(ALIGN) TYPE_VAR
208 /***************************************************************************\
209 |* Function Declaration Types *|
210 \***************************************************************************/
212 // stretching the meaning of "nvtypes", but this seems to least offensive
213 // place to re-locate these from nvos.h which cannot be included by a number
214 // of builds that need them
216 #if defined(NV_WINDOWS)
218 #define NV_INLINE __inline
221 #define NV_FORCEINLINE __forceinline
223 #define NV_FORCEINLINE __inline
226 #define NV_APIENTRY __stdcall
227 #define NV_FASTCALL __fastcall
228 #define NV_CDECLCALL __cdecl
229 #define NV_STDCALL __stdcall
231 #define NV_FORCERESULTCHECK
233 #else // defined(NV_WINDOWS)
235 #if defined(__GNUC__) || defined(__INTEL_COMPILER)
236 #define NV_INLINE __inline__
237 #elif defined (macintosh)
238 #define NV_INLINE inline
240 #define NV_INLINE __inline
245 #if defined(__GNUC__)
246 // GCC 3.1 and beyond support the always_inline function attribute.
247 #if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
248 #define NV_FORCEINLINE __attribute__((always_inline)) __inline__
250 #define NV_FORCEINLINE __inline__
252 #elif defined(__arm) && (__ARMCC_VERSION >= 220000)
253 // RVDS 2.2 also supports forceinline, but ADS 1.2 does not
254 #define NV_FORCEINLINE __forceinline
255 #else /* defined(__GNUC__) */
256 #define NV_FORCEINLINE NV_INLINE
265 * The 'warn_unused_result' function attribute prompts GCC to issue a
266 * warning if the result of a function tagged with this attribute
267 * is ignored by a caller. In combination with '-Werror', it can be
268 * used to enforce result checking in RM code; at this point, this
269 * is only done on UNIX.
271 #if defined(__GNUC__) && defined(NV_UNIX)
272 #if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
273 #define NV_FORCERESULTCHECK __attribute__((warn_unused_result))
275 #define NV_FORCERESULTCHECK
277 #else /* defined(__GNUC__) */
278 #define NV_FORCERESULTCHECK
281 #endif // defined(NV_WINDOWS)
287 #endif /* NVTYPES_INCLUDED */