From 8c65e4c62d43a3515e8e9d20fb567e7e778a262d Mon Sep 17 00:00:00 2001 From: castano Date: Tue, 27 Sep 2011 18:25:39 +0000 Subject: [PATCH] Do not depend on external int limits. --- src/nvcore/Utils.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/nvcore/Utils.h b/src/nvcore/Utils.h index 68167be..9c9159e 100644 --- a/src/nvcore/Utils.h +++ b/src/nvcore/Utils.h @@ -11,6 +11,18 @@ #undef min #undef max +#define NV_INT8_MIN (-128) +#define NV_INT8_MAX 127 +#define NV_INT16_MIN (-32768) +#define NV_INT16_MAX 32767 +#define NV_UINT16_MAX 0xffff +#define NV_INT32_MIN (-2147483648) +#define NV_INT32_MAX 2147483647 +#define NV_UINT32_MAX 0xffffffff +#define NV_INT64_MAX POSH_I64(9223372036854775807) +#define NV_INT64_MIN (-POSH_I64(9223372036854775808)) +#define NV_UINT64_MAX POSH_U64(0xffffffffffffffff) + namespace nv { // Less error prone than casting. From CB: @@ -26,7 +38,7 @@ namespace nv inline uint64 asUnsigned(int64 x) { return (uint64) x; } template inline uint32 toU32(T x) { - nvDebugCheck(x <= UINT32_MAX); + nvDebugCheck(x <= NV_UINT32_MAX); nvDebugCheck(x >= 0); return (uint32) x; }