From: Mark Janes Date: Mon, 1 Feb 2016 22:28:00 +0000 (-0800) Subject: i965: fix unsigned long overflows for i386 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ac0589b213f21f22dc330d2e8fb8dceda3960ddc;p=mesa.git i965: fix unsigned long overflows for i386 bit-shifts on 32 bit unsigned longs overflow in several places. The intention was for 64 bit integers to be used. --- diff --git a/src/vulkan/gen75_pack.h b/src/vulkan/gen75_pack.h index b012032190e..7b098894ee2 100644 --- a/src/vulkan/gen75_pack.h +++ b/src/vulkan/gen75_pack.h @@ -47,7 +47,7 @@ union __gen_value { static inline uint64_t __gen_mbo(uint32_t start, uint32_t end) { - return (~0ul >> (64 - (end - start + 1))) << start; + return (~0ull >> (64 - (end - start + 1))) << start; } static inline uint64_t @@ -56,7 +56,7 @@ __gen_field(uint64_t v, uint32_t start, uint32_t end) __gen_validate_value(v); #if DEBUG if (end - start + 1 < 64) - assert(v < 1ul << (end - start + 1)); + assert(v < 1ull << (end - start + 1)); #endif return v << start; @@ -97,7 +97,7 @@ __gen_offset(uint64_t v, uint32_t start, uint32_t end) { __gen_validate_value(v); #if DEBUG - uint64_t mask = (~0ul >> (64 - (end - start + 1))) << start; + uint64_t mask = (~0ull >> (64 - (end - start + 1))) << start; assert((v & ~mask) == 0); #endif diff --git a/src/vulkan/gen7_pack.h b/src/vulkan/gen7_pack.h index a3ba30a9745..7b104c3ab3c 100644 --- a/src/vulkan/gen7_pack.h +++ b/src/vulkan/gen7_pack.h @@ -47,7 +47,7 @@ union __gen_value { static inline uint64_t __gen_mbo(uint32_t start, uint32_t end) { - return (~0ul >> (64 - (end - start + 1))) << start; + return (~0ull >> (64 - (end - start + 1))) << start; } static inline uint64_t @@ -56,7 +56,7 @@ __gen_field(uint64_t v, uint32_t start, uint32_t end) __gen_validate_value(v); #if DEBUG if (end - start + 1 < 64) - assert(v < 1ul << (end - start + 1)); + assert(v < 1ull << (end - start + 1)); #endif return v << start; @@ -97,7 +97,7 @@ __gen_offset(uint64_t v, uint32_t start, uint32_t end) { __gen_validate_value(v); #if DEBUG - uint64_t mask = (~0ul >> (64 - (end - start + 1))) << start; + uint64_t mask = (~0ull >> (64 - (end - start + 1))) << start; assert((v & ~mask) == 0); #endif diff --git a/src/vulkan/gen8_pack.h b/src/vulkan/gen8_pack.h index 042e0290a74..3c014b96147 100644 --- a/src/vulkan/gen8_pack.h +++ b/src/vulkan/gen8_pack.h @@ -47,7 +47,7 @@ union __gen_value { static inline uint64_t __gen_mbo(uint32_t start, uint32_t end) { - return (~0ul >> (64 - (end - start + 1))) << start; + return (~0ull >> (64 - (end - start + 1))) << start; } static inline uint64_t @@ -56,7 +56,7 @@ __gen_field(uint64_t v, uint32_t start, uint32_t end) __gen_validate_value(v); #if DEBUG if (end - start + 1 < 64) - assert(v < 1ul << (end - start + 1)); + assert(v < 1ull << (end - start + 1)); #endif return v << start; @@ -97,7 +97,7 @@ __gen_offset(uint64_t v, uint32_t start, uint32_t end) { __gen_validate_value(v); #if DEBUG - uint64_t mask = (~0ul >> (64 - (end - start + 1))) << start; + uint64_t mask = (~0ull >> (64 - (end - start + 1))) << start; assert((v & ~mask) == 0); #endif diff --git a/src/vulkan/gen9_pack.h b/src/vulkan/gen9_pack.h index db54e9cf85b..df295f4900a 100644 --- a/src/vulkan/gen9_pack.h +++ b/src/vulkan/gen9_pack.h @@ -47,7 +47,7 @@ union __gen_value { static inline uint64_t __gen_mbo(uint32_t start, uint32_t end) { - return (~0ul >> (64 - (end - start + 1))) << start; + return (~0ull >> (64 - (end - start + 1))) << start; } static inline uint64_t @@ -56,7 +56,7 @@ __gen_field(uint64_t v, uint32_t start, uint32_t end) __gen_validate_value(v); #if DEBUG if (end - start + 1 < 64) - assert(v < 1ul << (end - start + 1)); + assert(v < 1ull << (end - start + 1)); #endif return v << start; @@ -97,7 +97,7 @@ __gen_offset(uint64_t v, uint32_t start, uint32_t end) { __gen_validate_value(v); #if DEBUG - uint64_t mask = (~0ul >> (64 - (end - start + 1))) << start; + uint64_t mask = (~0ull >> (64 - (end - start + 1))) << start; assert((v & ~mask) == 0); #endif