static float
bitcast_u2f(unsigned int u)
{
- assert(sizeof(float) == sizeof(unsigned int));
+ static_assert(sizeof(float) == sizeof(unsigned int),
+ "float and unsigned int size mismatch");
float f;
memcpy(&f, &u, sizeof(f));
return f;
static unsigned int
bitcast_f2u(float f)
{
- assert(sizeof(float) == sizeof(unsigned int));
+ static_assert(sizeof(float) == sizeof(unsigned int),
+ "float and unsigned int size mismatch");
unsigned int u;
memcpy(&u, &f, sizeof(f));
return u;
static double
bitcast_u642d(uint64_t u)
{
- assert(sizeof(double) == sizeof(uint64_t));
+ static_assert(sizeof(double) == sizeof(uint64_t),
+ "double and uint64_t size mismatch");
double d;
memcpy(&d, &u, sizeof(d));
return d;
static double
bitcast_i642d(int64_t i)
{
- assert(sizeof(double) == sizeof(int64_t));
+ static_assert(sizeof(double) == sizeof(int64_t),
+ "double and int64_t size mismatch");
double d;
memcpy(&d, &i, sizeof(d));
return d;
static uint64_t
bitcast_d2u64(double d)
{
- assert(sizeof(double) == sizeof(uint64_t));
+ static_assert(sizeof(double) == sizeof(uint64_t),
+ "double and uint64_t size mismatch");
uint64_t u;
memcpy(&u, &d, sizeof(d));
return u;
static int64_t
bitcast_d2i64(double d)
{
- assert(sizeof(double) == sizeof(int64_t));
+ static_assert(sizeof(double) == sizeof(int64_t),
+ "double and int64_t size mismatch");
int64_t i;
memcpy(&i, &d, sizeof(d));
return i;