Commit 4abb292f authored by Eric Anholt's avatar Eric Anholt

util: Introduce fui() and uif() helpers for bit-casting floats/uints.

I wanted to fix up some type-punning warnings and was surprised to see
we didn't have this yet.
Reviewed-by: Tapani Pälli's avatarTapani Pälli <>
parent a56b7193
......@@ -467,6 +467,26 @@ piglit_alloc_aligned(size_t alignment, size_t size);
piglit_free_aligned(void *p);
union uif {
float f;
unsigned int ui;
static inline unsigned int
fui(float f)
union uif bits;
bits.f = f;
return bits.ui;
static inline float
uif(unsigned int ui)
union uif bits;
bits.ui = ui;
return bits.f;
#ifdef __cplusplus
} /* end extern "C" */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment