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 <tapani.palli@intel.com>
parent a56b7193
...@@ -467,6 +467,26 @@ piglit_alloc_aligned(size_t alignment, size_t size); ...@@ -467,6 +467,26 @@ piglit_alloc_aligned(size_t alignment, size_t size);
void void
piglit_free_aligned(void *p); 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 #ifdef __cplusplus
} /* end extern "C" */ } /* 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