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) */
78 #if defined(macosx) || defined(MACOS) || defined(NV_MACINTOSH) || \
79 defined(NV_MACINTOSH_64)
80 typedef char* NVREGSTR;
82 typedef NvU8* NVREGSTR;
85 /* mainly for 64-bit linux, where long is 64 bits
86 * and win9x, where int is 16 bit.
88 #if (defined(NV_UNIX) || defined(vxworks) || defined(NV_WINDOWS_CE) || \
89 defined(__arm) || defined(__IAR_SYSTEMS_ICC__) || defined(NV_QNX) || \
90 defined(NV_INTEGRITY) || defined(NV_MODS) || defined(__GNUC__) || \
91 defined(NV_MACINTOSH_64)) && \
92 (!defined(NV_MACINTOSH) || defined(NV_MACINTOSH_64))
93 typedef unsigned int NvV32; /* "void": enumerated or multiple fields */
94 typedef unsigned int NvU32; /* 0 to 4294967295 */
96 typedef unsigned long NvV32; /* "void": enumerated or multiple fields */
97 typedef unsigned long NvU32; /* 0 to 4294967295 */
100 // mac os 32-bit still needs this
101 #if defined(NV_MACINTOSH) && !defined(NV_MACINTOSH_64)
102 typedef signed long NvS32; /* -2147483648 to 2147483647 */
104 typedef signed int NvS32; /* -2147483648 to 2147483647 */
107 /* 64-bit types for compilers that support them, plus some obsolete variants */
108 #if defined(__GNUC__) || defined(__arm) || defined(__IAR_SYSTEMS_ICC__) || defined(__ghs__) || defined(_WIN64) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
109 typedef unsigned long long NvU64; /* 0 to 18446744073709551615 */
110 typedef long long NvS64; /* 2^-63 to 2^63-1 */
112 typedef unsigned __int64 NvU64; /* 0 to 18446744073709551615 */
113 typedef __int64 NvS64; /* 2^-63 to 2^63-1 */
117 enum { NV_FALSE = 0, NV_TRUE = 1 };
120 /* Macros to extract the low and high parts of a 64-bit unsigned integer */
121 /* Also designed to work if someone happens to pass in a 32-bit integer */
122 #define NvU64_HI32(n) ((NvU32)((((NvU64)(n)) >> 32) & 0xffffffff))
123 #define NvU64_LO32(n) ((NvU32)(( (NvU64)(n)) & 0xffffffff))
124 #define NvU40_HI32(n) ((NvU32)((((NvU64)(n)) >> 8) & 0xffffffff))
125 #define NvU40_HI24of32(n) ((NvU32)( (NvU64)(n) & 0xffffff00))
127 /***************************************************************************\
129 |* 64 bit type definitions for use in interface structures. *|
131 \***************************************************************************/
133 #if defined(NV_64_BITS)
135 typedef void* NvP64; /* 64 bit void pointer */
136 typedef NvU64 NvUPtr; /* pointer sized unsigned int */
137 typedef NvS64 NvSPtr; /* pointer sized signed int */
138 typedef NvU64 NvLength; /* length to agree with sizeof */
140 #define NvP64_VALUE(n) (n)
144 typedef NvU64 NvP64; /* 64 bit void pointer */
145 typedef NvU32 NvUPtr; /* pointer sized unsigned int */
146 typedef NvS32 NvSPtr; /* pointer sized signed int */
147 typedef NvU32 NvLength; /* length to agree with sizeof */
149 #define NvP64_VALUE(n) ((void *)(NvUPtr)(n))
153 // XXX Obsolete -- get rid of me...
154 typedef NvP64 NvP64_VALUE_T;
155 typedef NvUPtr NV_UINTPTR_T;
156 #define NvP64_LVALUE(n) (n)
157 #define NvP64_SELECTOR(n) (0)
159 /* Useful macro to hide required double cast */
160 #define NV_PTR_TO_NvP64(n) (NvP64)(NV_UINTPTR_T)(n)
163 /* MODS needs to be able to build without these definitions because they collide
164 with some definitions used in mdiag. */
165 #ifndef DONT_DEFINE_U032
176 #if defined(MACOS) || defined(macintosh) || defined(__APPLE_CC__) || defined(NV_MODS) || defined(MINIRM) || defined(NV_UNIX) || defined (NV_QNX)
177 /* more obsolete stuff */
178 /* need to provide these on macos9 and macosX */
179 #if defined(__APPLE_CC__) /* gross but Apple osX already claims ULONG */
180 #undef ULONG // just in case
181 #define ULONG unsigned long
183 typedef unsigned long ULONG;
185 typedef unsigned char *PUCHAR;
189 /* Supports 32bit libraries on Win64
190 See drivers\opengl\include\nvFirst.h for explanation */
192 #define CAST_NV_PTR(p) p
195 /* Aligns fields in structs so they match up between 32 and 64 bit builds */
196 #if defined(__GNUC__) || defined(NV_QNX)
197 #define NV_ALIGN_BYTES(size) __attribute__ ((aligned (size)))
199 #define NV_ALIGN_BYTES(size) __align(ALIGN)
201 // XXX This is dangerously nonportable! We really shouldn't provide a default
202 // version of this that doesn't do anything.
203 #define NV_ALIGN_BYTES(size)
206 // NV_DECLARE_ALIGNED() can be used on all platforms.
207 // This macro form accounts for the fact that __declspec on Windows is required
208 // before the variable type,
209 // and NV_ALIGN_BYTES is required after the variable name.
210 #if defined(NV_WINDOWS)
211 #define NV_DECLARE_ALIGNED(TYPE_VAR, ALIGN) __declspec(align(ALIGN)) TYPE_VAR
212 #elif defined(__GNUC__) || defined(NV_QNX)
213 #define NV_DECLARE_ALIGNED(TYPE_VAR, ALIGN) TYPE_VAR __attribute__ ((aligned (ALIGN)))
215 #define NV_DECLARE_ALIGNED(TYPE_VAR, ALIGN) __align(ALIGN) TYPE_VAR
219 /***************************************************************************\
220 |* Function Declaration Types *|
221 \***************************************************************************/
223 // stretching the meaning of "nvtypes", but this seems to least offensive
224 // place to re-locate these from nvos.h which cannot be included by a number
225 // of builds that need them
227 #if defined(NV_WINDOWS)
229 #define NV_INLINE __inline
232 #define NV_FORCEINLINE __forceinline
234 #define NV_FORCEINLINE __inline
237 #define NV_APIENTRY __stdcall
238 #define NV_FASTCALL __fastcall
239 #define NV_CDECLCALL __cdecl
240 #define NV_STDCALL __stdcall
242 #define NV_FORCERESULTCHECK
244 #else // defined(NV_WINDOWS)
246 #if defined(__GNUC__) || defined(__INTEL_COMPILER)
247 #define NV_INLINE __inline__
248 #elif defined (macintosh) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
249 #define NV_INLINE inline
251 #define NV_INLINE __inline
256 #if defined(__GNUC__)
257 // GCC 3.1 and beyond support the always_inline function attribute.
258 #if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
259 #define NV_FORCEINLINE __attribute__((always_inline)) __inline__
261 #define NV_FORCEINLINE __inline__
263 #elif defined(__arm) && (__ARMCC_VERSION >= 220000)
264 // RVDS 2.2 also supports forceinline, but ADS 1.2 does not
265 #define NV_FORCEINLINE __forceinline
266 #else /* defined(__GNUC__) */
267 #define NV_FORCEINLINE NV_INLINE
276 * The 'warn_unused_result' function attribute prompts GCC to issue a
277 * warning if the result of a function tagged with this attribute
278 * is ignored by a caller. In combination with '-Werror', it can be
279 * used to enforce result checking in RM code; at this point, this
280 * is only done on UNIX.
282 #if defined(__GNUC__) && defined(NV_UNIX)
283 #if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
284 #define NV_FORCERESULTCHECK __attribute__((warn_unused_result))
286 #define NV_FORCERESULTCHECK
288 #else /* defined(__GNUC__) */
289 #define NV_FORCERESULTCHECK
292 #endif // defined(NV_WINDOWS)
298 #endif /* NVTYPES_INCLUDED */