Loading [MathJax]/extensions/tex2jax.js
  • <xmp id="om0om">
  • <table id="om0om"><noscript id="om0om"></noscript></table>
  • NVIDIA DRIVE OS Linux SDK API Reference

    6.0.9 Release
    All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
    nvcommon.h
    Go to the documentation of this file.
    1 /*
    2  * Copyright (c) 2006-2021 NVIDIA Corporation. All Rights Reserved.
    3  *
    4  * NVIDIA Corporation and its licensors retain all intellectual property
    5  * and proprietary rights in and to this software, related documentation
    6  * and any modifications thereto. Any use, reproduction, disclosure or
    7  * distribution of this software and related documentation without an express
    8  * license agreement from NVIDIA Corporation is strictly prohibited.
    9  */
    10 
    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"
    15 #else
    16 
    37 // Pull in some headers that are mirrored from desktop.
    38 #include "nvtypes.h"
    39 
    42 #include <stddef.h>
    43 #if defined(__hos__) || (defined(__linux__) && !defined(__KERNEL__)) || defined(__arm) || defined(__APPLE__) || defined(__QNX__) || defined(__INTEGRITY) || defined(NV_HYPERVISOR)
    44 #include <stdint.h>
    45 #endif
    46 
    47 // Rest of this file is mobile-only definitions, and appending to them
    48 // is discouraged since it prevents header portability between mobile
    49 // and desktop.
    50 #define NV_FORCE_INLINE NV_FORCEINLINE
    51 #define NV_ALIGN NV_ALIGN_BYTES
    52 
    53 #if (NVCPU_IS_X86 && NVOS_IS_WINDOWS)
    54 # define NVOS_IS_WINDOWS_X86 1
    55 #else
    56 # define NVOS_IS_WINDOWS_X86 0
    57 #endif
    58 
    59 #if defined(__APPLE__)
    60 # define NVOS_IS_DARWIN 1
    61 # define NVOS_IS_UNIX 1
    62 #endif
    63 
    64 #define NVOS_IS_LINUX_KERNEL 0
    65 
    67 #define NV_MIN_F32 (1.1754944e-38f)
    68 #define NV_MAX_F32 (3.4028234e+38f)
    69 
    71 #if defined(__GNUC__)
    72 #define NV_ALIGN_POINTER_NAME(f) f##Align
    73 #define NV_ALIGN_POINTER(t, f) \
    74  union { \
    75  t f; \
    76  NvU64 NV_ALIGN_POINTER_NAME(f); \
    77  }
    78 #else
    79 /* rvds builds don't support anonymous unions but also don't need
    80  * 64-bit alignment.
    81  */
    82 #define NV_ALIGN_POINTER(t, f) t f
    83 #endif
    84 
    87 #if NVOS_IS_WINDOWS
    88 
    89 #define NV_NAKED __declspec(naked)
    90 #define NV_LIKELY(c) (c)
    91 #define NV_UNLIKELY(c) (c)
    92 #define NV_UNUSED
    93 
    94 #elif defined(__ghs__) // GHS COMP
    95 #define NV_NAKED
    96 #define NV_LIKELY(c) (c)
    97 #define NV_UNLIKELY(c) (c)
    98 #define NV_UNUSED __attribute__((unused))
    99 
    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))
    105 
    106 #elif defined(__arm) // ARM RVDS compiler
    107 #define NV_NAKED __asm
    108 #define NV_LIKELY(c) (c)
    109 #define NV_UNLIKELY(c) (c)
    110 #define NV_UNUSED
    111 
    112 #else
    113 #error Unknown compiler
    114 #endif
    115 
    118 #if NVOS_IS_WINDOWS
    119 #define NV_WEAK
    120 #elif defined(__ghs__)
    121 #define NV_WEAK __attribute__((weak))
    122 #elif defined(__GNUC__)
    123 #define NV_WEAK __attribute__((weak))
    124 #elif defined(__arm)
    125 #define NV_WEAK __weak
    126 #else
    127 #error Unknown compiler
    128 #endif
    129 
    130 // NV_DEBUG_CODE conflicts with the definition of the same name
    131 // in OpenGL/nvInc/nvDebug.h.
    132 #if !defined(NV_DEBUG_CODE)
    133 
    137 #if NV_DEBUG
    138 #define NV_DEBUG_CODE(x) x
    139 #else
    140 #define NV_DEBUG_CODE(x)
    141 #endif
    142 #endif
    143 
    145 #define NV_ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
    146 
    148 #ifndef NV_MIN
    149 #define NV_MIN(a,b) (((a) < (b)) ? (a) : (b))
    150 #endif
    151 #ifndef NV_MAX
    152 #define NV_MAX(a,b) (((a) > (b)) ? (a) : (b))
    153 #endif
    154 
    156 #if !defined(NV_OFFSETOF)
    157  #if defined(__GNUC__)
    158  #define NV_OFFSETOF(type, member) __builtin_offsetof(type, member)
    159  #else
    160  #define NV_OFFSETOF(type, member) ((NvUPtr)(&(((type *)0)->member)))
    161  #endif
    162 #endif
    163 
    165 #define NV_SIZEOF(s,e) (sizeof(((s*)0)->e))
    166 
    168 #define NV_LOWEST_BIT_ONLY(v) ((NvU32)(v) & (NvU32)-(NvS32)(v))
    169 
    171 #define NV_IS_POWER_OF_2(v) (NV_LOWEST_BIT_ONLY(v) == (NvU32)(v))
    172 
    179 #define NV_WAIT_INFINITE 0xFFFFFFFF
    180 
    182 #if defined(_PREFAST_)
    183 #define NV_ANALYSIS_ASSUME(x) __analysis_assume(x)
    184 #else
    185 #define NV_ANALYSIS_ASSUME(x)
    186 #endif
    187 
    192 typedef NvU64 NvPhysAddr64;
    193 
    200 typedef NvU32 NvRmPhysAddr;
    201 
    211 static NV_FORCE_INLINE NvU64
    212 NvDiv64Inline(NvU64 dividend, NvU32 divisor)
    213 {
    214  if (divisor == 0U) {
    215  return 0;
    216  }
    217  return dividend / divisor;
    218 }
    219 
    220 #define NvDiv64(dividend, divisor) NvDiv64Inline(dividend, divisor)
    221 
    231 typedef union NvData32Rec
    232 {
    233  NvU32 u;
    234  NvS32 i;
    235  NvF32 f;
    236 } NvData32;
    237 
    241 typedef union NvData64Rec
    242 {
    243  NvU32 u;
    244  NvS32 i;
    245  NvF32 f;
    246  NvU64 u64;
    247  NvS64 i64;
    248  NvF64 d;
    249 } NvData64;
    250 
    256 typedef struct NvPointRec
    257 {
    259  NvS32 x;
    260 
    262  NvS32 y;
    263 } NvPoint;
    264 
    265 typedef struct NvPointF32Rec
    266 {
    268  NvF32 x;
    269 
    271  NvF32 y;
    272 } NvPointF32;
    278 typedef struct NvRectRec
    279 {
    281  NvS32 left;
    282 
    284  NvS32 top;
    285 
    287  NvS32 right;
    288 
    290  NvS32 bottom;
    291 } NvRect;
    292 
    297 typedef struct NvRectF32Rec
    298 {
    299  NvF32 left;
    300  NvF32 top;
    301  NvF32 right;
    302  NvF32 bottom;
    303 } NvRectF32;
    304 
    309 typedef struct NvSizeRec
    310 {
    311  /* width of the surface in pixels */
    312  NvS32 width;
    313 
    314  /* height of the surface in pixels */
    315  NvS32 height;
    316 } NvSize;
    317 
    319 #endif
    320 #endif // INCLUDED_NVCOMMON_H
    NvRectF32Rec::right
    NvF32 right
    Definition: nvcommon.h:301
    NvData32
    union NvData32Rec NvData32
    Union that can be used to view a 32-bit word as your choice of a 32-bit unsigned integer,...
    NvData64Rec::f
    NvF32 f
    Definition: nvcommon.h:245
    NvRectRec::right
    NvS32 right
    right column of a rectangle
    Definition: nvcommon.h:287
    NvSizeRec
    This structure is used to define a 2-dimensional surface where the surface is determined by it's heig...
    Definition: nvcommon.h:309
    NvPointF32Rec::y
    NvF32 y
    vertical location of the point
    Definition: nvcommon.h:271
    NvPointF32
    struct NvPointF32Rec NvPointF32
    NvData64Rec::d
    NvF64 d
    Definition: nvcommon.h:248
    NvPointRec::x
    NvS32 x
    horizontal location of the point
    Definition: nvcommon.h:259
    NvRectF32Rec
    This structure is used to define a 2-dimensional rectangle with floating point coordinates.
    Definition: nvcommon.h:297
    NvRectRec
    This structure is used to define a 2-dimensional rectangle where the rectangle is bottom right exclus...
    Definition: nvcommon.h:278
    NvData64Rec::i64
    NvS64 i64
    Definition: nvcommon.h:247
    NvSizeRec::width
    NvS32 width
    Definition: nvcommon.h:312
    NvData32Rec::i
    NvS32 i
    Definition: nvcommon.h:234
    NvRectF32
    struct NvRectF32Rec NvRectF32
    This structure is used to define a 2-dimensional rectangle with floating point coordinates.
    NvDiv64Inline
    static NV_FORCE_INLINE NvU64 NvDiv64Inline(NvU64 dividend, NvU32 divisor)
    Performs the 64-bit division and returns the quotient.
    Definition: nvcommon.h:212
    NvData64Rec
    Generic data representation for both 32 and 64 bits data.
    Definition: nvcommon.h:241
    NvData32Rec::u
    NvU32 u
    Definition: nvcommon.h:233
    NvPointF32Rec::x
    NvF32 x
    horizontal location of the point
    Definition: nvcommon.h:268
    NvPointRec::y
    NvS32 y
    vertical location of the point
    Definition: nvcommon.h:262
    NvData64Rec::u
    NvU32 u
    Definition: nvcommon.h:243
    NvData64Rec::i
    NvS32 i
    Definition: nvcommon.h:244
    NvRectRec::top
    NvS32 top
    top row of a rectangle
    Definition: nvcommon.h:284
    NvData64
    union NvData64Rec NvData64
    Generic data representation for both 32 and 64 bits data.
    NvRectF32Rec::top
    NvF32 top
    Definition: nvcommon.h:300
    NV_FORCE_INLINE
    #define NV_FORCE_INLINE
    Include headers that provide NULL, size_t, offsetof, and [u]intptr_t.
    Definition: nvcommon.h:50
    NvPoint
    struct NvPointRec NvPoint
    This structure is used to determine a location on a 2-dimensional object, where the coordinate (0,...
    NvRectF32Rec::left
    NvF32 left
    Definition: nvcommon.h:299
    NvData32Rec
    Union that can be used to view a 32-bit word as your choice of a 32-bit unsigned integer,...
    Definition: nvcommon.h:231
    NvData64Rec::u64
    NvU64 u64
    Definition: nvcommon.h:246
    NvPhysAddr64
    NvU64 NvPhysAddr64
    A physical address type sized such that it matches the addressing support of the hardware modules wit...
    Definition: nvcommon.h:192
    NvRmPhysAddr
    NvU32 NvRmPhysAddr
    This is deprecated and shouldn't be used.
    Definition: nvcommon.h:200
    NvData32Rec::f
    NvF32 f
    Definition: nvcommon.h:235
    NvSizeRec::height
    NvS32 height
    Definition: nvcommon.h:315
    NvRect
    struct NvRectRec NvRect
    This structure is used to define a 2-dimensional rectangle where the rectangle is bottom right exclus...
    NvPointRec
    This structure is used to determine a location on a 2-dimensional object, where the coordinate (0,...
    Definition: nvcommon.h:256
    NvSize
    struct NvSizeRec NvSize
    This structure is used to define a 2-dimensional surface where the surface is determined by it's heig...
    NvPointF32Rec
    Definition: nvcommon.h:265
    NvRectRec::bottom
    NvS32 bottom
    bottom row of a rectangle
    Definition: nvcommon.h:290
    NvRectF32Rec::bottom
    NvF32 bottom
    Definition: nvcommon.h:302
    NvRectRec::left
    NvS32 left
    left column of a rectangle
    Definition: nvcommon.h:281
    人人超碰97caoporen国产