154 lines
4.3 KiB
C
Executable File
154 lines
4.3 KiB
C
Executable File
/*
|
|
* Copyright (c) 2006 - 2007 NVIDIA Corporation. All Rights Reserved.
|
|
*
|
|
* NVIDIA Corporation and its licensors retain all intellectual property
|
|
* and proprietary rights in and to this software, related documentation
|
|
* and any modifications thereto. Any use, reproduction, disclosure or
|
|
* distribution of this software and related documentation without an express
|
|
* license agreement from NVIDIA Corporation is strictly prohibited.
|
|
*/
|
|
|
|
#ifndef NVCOMMON_H
|
|
#define NVCOMMON_H
|
|
|
|
#include "nvtypes.h"
|
|
|
|
// Include headers that provide NULL, size_t, offsetof, and [u]intptr_t. In the
|
|
// event that the toolchain doesn't provide these, provide them ourselves.
|
|
#include <stddef.h>
|
|
#if NVOS_IS_WINDOWS_CE
|
|
typedef int intptr_t;
|
|
typedef unsigned int uintptr_t;
|
|
#elif (NVOS_IS_LINUX && !defined(__KERNEL__)) || defined(__arm)
|
|
#include <stdint.h>
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
extern "C"
|
|
{
|
|
#endif /* __cplusplus */
|
|
|
|
/** nvcommon.h contains standard definitions used by various interfaces
|
|
*/
|
|
|
|
/** A physical address */
|
|
#if NVOS_IS_WINDOWS
|
|
typedef NvU64 NvPhysAddr;
|
|
#else
|
|
typedef NvU32 NvPhysAddr;
|
|
#endif
|
|
|
|
// For historical reasons that are hard to fix, nvtypes.h has an incorrect
|
|
// definition of NV_ALIGN_BYTES for Windows and Macintosh, and for other
|
|
// unsupported compilers like IAR. Provide a correct macro, which we call
|
|
// NV_ALIGN. This can be removed if and when nvtypes.h is fixed.
|
|
// Alternatively, we could use NV_DECLARE_ALIGNED...
|
|
#if NVOS_IS_WINDOWS
|
|
#define NV_ALIGN(size) __declspec(align(size))
|
|
#elif defined(__GNUC__) || NVOS_IS_QNX
|
|
#define NV_ALIGN(size) __attribute__ ((aligned (size)))
|
|
#elif defined(__arm)
|
|
#define NV_ALIGN(size) __align(size)
|
|
#endif
|
|
|
|
/**
|
|
* This macro wraps its argument with the equivalent of "#ifdef DEBUG", but also
|
|
* can be used where #ifdef's can't, like inside a macro.
|
|
*/
|
|
#if defined(DEBUG)
|
|
#define NV_DEBUG_CODE(x) x
|
|
#else
|
|
#define NV_DEBUG_CODE(x)
|
|
#endif
|
|
|
|
/** Macro for determining the size of an array */
|
|
#define NV_ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
|
|
|
/** Macro for taking min or max of a pair of numbers */
|
|
#define NV_MIN(a,b) (((a) < (b)) ? (a) : (b))
|
|
#define NV_MAX(a,b) (((a) > (b)) ? (a) : (b))
|
|
|
|
/**
|
|
* By convention, we use this value to represent an infinite wait interval in
|
|
* APIs that expect a timeout argument. A value of zero should not be
|
|
* interpreted as infinite -- it should be interpreted as "time out immediately
|
|
* and simply check whether the event has already happened."
|
|
*/
|
|
enum { NV_WAIT_INFINITE = 0xFFFFFFFF };
|
|
|
|
/**
|
|
* 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.
|
|
* Here is an example of how you might use it to extract the (integer) bitwise
|
|
* representation of a floating-point number:
|
|
* NvData32 data;
|
|
* data.f = 1.0f;
|
|
* printf("%x", data.u);
|
|
*/
|
|
typedef union NvData32Rec
|
|
{
|
|
NvU32 u;
|
|
NvS32 i;
|
|
NvF32 f;
|
|
} NvData32;
|
|
|
|
/** NvPoint structure is used to determine a location on a 2-dimensional
|
|
object, where the coordinate (0,0) is located at the top-left of the
|
|
object. The values of x and y are in pixels.
|
|
*/
|
|
typedef struct _NvPoint_t
|
|
{
|
|
/** horizontal location of the point */
|
|
NvS32 x;
|
|
|
|
/** vertical location of the point */
|
|
NvS32 y;
|
|
|
|
} NvPoint;
|
|
|
|
|
|
/** NvRect structure is used to define a 2-dimensional rectangle
|
|
where the rectangle is bottom right exclusive (i.e. the right most
|
|
column, and the bottom row of the rectangle is not included)
|
|
*/
|
|
typedef struct _NvRect_t
|
|
{
|
|
/** left column of a rectangle */
|
|
NvS32 left;
|
|
|
|
/** top row of a rectangle*/
|
|
NvS32 top;
|
|
|
|
/** right column of a rectangle */
|
|
NvS32 right;
|
|
|
|
/** bottom row of a rectangle */
|
|
NvS32 bottom;
|
|
|
|
} NvRect;
|
|
|
|
|
|
/** NvSize structure is used to define a 2-dimensional surface
|
|
where the surface is determined by it's height and width in
|
|
pixels
|
|
*/
|
|
typedef struct _NvSize_t
|
|
{
|
|
/* width of the surface in pixels */
|
|
NvS32 width;
|
|
|
|
/* height of the surface in pixels */
|
|
NvS32 height;
|
|
|
|
} NvSize;
|
|
|
|
|
|
/** NvDeviceHandle is an opaque handle to a device
|
|
*/
|
|
typedef struct NvDeviceStruct_t *NvDeviceHandle;
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* NVCOMMON_H */
|