11 #ifndef INCLUDED_NVCOMMON_H
12 #define INCLUDED_NVCOMMON_H
13 #if (defined(__QNX__) && defined(NV_IS_SAFETY) && (NV_IS_SAFETY == 1))
14 #include "nvcommon_tegra_safety.h"
43 #if defined(__hos__) || (defined(__linux__) && !defined(__KERNEL__)) || defined(__arm) || defined(__APPLE__) || defined(__QNX__) || defined(__INTEGRITY) || defined(NV_HYPERVISOR)
50 #define NV_FORCE_INLINE NV_FORCEINLINE
51 #define NV_ALIGN NV_ALIGN_BYTES
53 #if (NVCPU_IS_X86 && NVOS_IS_WINDOWS)
54 # define NVOS_IS_WINDOWS_X86 1
56 # define NVOS_IS_WINDOWS_X86 0
59 #if defined(__APPLE__)
60 # define NVOS_IS_DARWIN 1
61 # define NVOS_IS_UNIX 1
64 #define NVOS_IS_LINUX_KERNEL 0
67 #define NV_MIN_F32 (1.1754944e-38f)
68 #define NV_MAX_F32 (3.4028234e+38f)
72 #define NV_ALIGN_POINTER_NAME(f) f##Align
73 #define NV_ALIGN_POINTER(t, f) \
76 NvU64 NV_ALIGN_POINTER_NAME(f); \
82 #define NV_ALIGN_POINTER(t, f) t f
89 #define NV_NAKED __declspec(naked)
90 #define NV_LIKELY(c) (c)
91 #define NV_UNLIKELY(c) (c)
94 #elif defined(__ghs__) // GHS COMP
96 #define NV_LIKELY(c) (c)
97 #define NV_UNLIKELY(c) (c)
98 #define NV_UNUSED __attribute__((unused))
100 #elif defined(__GNUC__)
101 #define NV_NAKED __attribute__((naked))
102 #define NV_LIKELY(c) __builtin_expect((c),1)
103 #define NV_UNLIKELY(c) __builtin_expect((c),0)
104 #define NV_UNUSED __attribute__((unused))
106 #elif defined(__arm) // ARM RVDS compiler
107 #define NV_NAKED __asm
108 #define NV_LIKELY(c) (c)
109 #define NV_UNLIKELY(c) (c)
113 #error Unknown compiler
120 #elif defined(__ghs__)
121 #define NV_WEAK __attribute__((weak))
122 #elif defined(__GNUC__)
123 #define NV_WEAK __attribute__((weak))
125 #define NV_WEAK __weak
127 #error Unknown compiler
132 #if !defined(NV_DEBUG_CODE)
138 #define NV_DEBUG_CODE(x) x
140 #define NV_DEBUG_CODE(x)
145 #define NV_ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
149 #define NV_MIN(a,b) (((a) < (b)) ? (a) : (b))
152 #define NV_MAX(a,b) (((a) > (b)) ? (a) : (b))
156 #if !defined(NV_OFFSETOF)
157 #if defined(__GNUC__)
158 #define NV_OFFSETOF(type, member) __builtin_offsetof(type, member)
160 #define NV_OFFSETOF(type, member) ((NvUPtr)(&(((type *)0)->member)))
165 #define NV_SIZEOF(s,e) (sizeof(((s*)0)->e))
168 #define NV_LOWEST_BIT_ONLY(v) ((NvU32)(v) & (NvU32)-(NvS32)(v))
171 #define NV_IS_POWER_OF_2(v) (NV_LOWEST_BIT_ONLY(v) == (NvU32)(v))
179 #define NV_WAIT_INFINITE 0xFFFFFFFF
182 #if defined(_PREFAST_)
183 #define NV_ANALYSIS_ASSUME(x) __analysis_assume(x)
185 #define NV_ANALYSIS_ASSUME(x)
217 return dividend / divisor;
220 #define NvDiv64(dividend, divisor) NvDiv64Inline(dividend, divisor)
321 #endif // INCLUDED_NVCOMMON_H
NvF32 x
horizontal location of the point
struct NvRectRec NvRect
This structure is used to define a 2-dimensional rectangle where the rectangle is bottom right exclus...
NvS32 x
horizontal location of the point
union NvData64Rec NvData64
Generic data representation for both 32 and 64 bits data.
NvS32 top
top row of a rectangle
NvS32 right
right column of a rectangle
static NV_FORCE_INLINE NvU64 NvDiv64Inline(NvU64 dividend, NvU32 divisor)
Performs the 64-bit division and returns the quotient.
struct NvPointF32Rec NvPointF32
This structure is used to define a 2-dimensional rectangle where the rectangle is bottom right exclus...
Generic data representation for both 32 and 64 bits data.
Union that can be used to view a 32-bit word as your choice of a 32-bit unsigned integer, a 32-bit signed integer, or an IEEE single-precision float.
This structure is used to define a 2-dimensional surface where the surface is determined by it's heig...
NvF32 y
vertical location of the point
NvS32 bottom
bottom row of a rectangle
NvS32 y
vertical location of the point
struct NvPointRec NvPoint
This structure is used to determine a location on a 2-dimensional object, where the coordinate (0...
union NvData32Rec NvData32
Union that can be used to view a 32-bit word as your choice of a 32-bit unsigned integer, a 32-bit signed integer, or an IEEE single-precision float.
NvU64 NvPhysAddr64
A physical address type sized such that it matches the addressing support of the hardware modules wit...
#define NV_FORCE_INLINE
Include headers that provide NULL, size_t, offsetof, and [u]intptr_t.
struct NvRectF32Rec NvRectF32
This structure is used to define a 2-dimensional rectangle relative to some containing rectangle...
NvS32 left
left column of a rectangle
struct NvSizeRec NvSize
This structure is used to define a 2-dimensional surface where the surface is determined by it's heig...
This structure is used to define a 2-dimensional rectangle relative to some containing rectangle...
This structure is used to determine a location on a 2-dimensional object, where the coordinate (0...
NvU32 NvRmPhysAddr
This is deprecated and shouldn't be used.