summaryrefslogtreecommitdiff
path: root/tests/texturing
diff options
context:
space:
mode:
authorNeil Roberts <neil@linux.intel.com>2014-09-17 15:47:46 +0100
committerNeil Roberts <neil@linux.intel.com>2014-09-18 17:34:04 +0100
commit0eed11fd312616617ec865a6f59c0e51f5b187fa (patch)
tree134f74d0f7c362b88db9cd75cda12c68f773f316 /tests/texturing
parent948af4eb07bdb7b9c868fa22659b70e744e8e6e8 (diff)
teximage-color: Fix un_to_float for 32-bit builds
The un_to_float function was trying to get the maximum value given a number of bits by shifting ~0ul by the number of bits. For the GL_UNSIGNED_INT type this function was also being used to get a maximum value for a 32-bit quantity. However on a 32-bit build this would mean that it is shifting a 32-bit integer (unsigned long is 32-bit) by 32 bits. The C spec leaves it undefined what happens if you do a shift that is greater than the number of bits in the type. GCC takes advantage of that to make the shift a no-op so the maximum was ending up as zero and the test fails. This patch makes it shift ~0u in the other direction so that it doesn't matter what size unsigned int is and it won't try to shift by 32. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=83695 Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu> Tested-by: Tapani Pälli <tapani.palli@intel.com>
Diffstat (limited to 'tests/texturing')
-rw-r--r--tests/texturing/teximage-colors.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/tests/texturing/teximage-colors.c b/tests/texturing/teximage-colors.c
index 712e11bbf..2bee02f42 100644
--- a/tests/texturing/teximage-colors.c
+++ b/tests/texturing/teximage-colors.c
@@ -189,7 +189,7 @@ valid_combination(GLenum format, GLenum type)
static float
un_to_float(unsigned char bits, unsigned int color)
{
- unsigned int max = ~(~0ul << bits);
+ unsigned int max = ~0u >> (sizeof(max) * 8 - bits);
return (float)color / (float)max;
}