mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-07-20 22:32:01 +00:00
[client] glsl: fix failure to build on clang
Clang with -ffast-math doesnt have `isfinite`, instead implement it locally.
This commit is contained in:
@@ -33,6 +33,7 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <float.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@@ -601,6 +602,20 @@ static bool expressionValue(const GLSLContext * context, const char * token,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool expressionValueFinite(double value)
|
||||||
|
{
|
||||||
|
_Static_assert(sizeof(double) == sizeof(uint64_t) &&
|
||||||
|
DBL_MANT_DIG == 53 && DBL_MAX_EXP == 1024,
|
||||||
|
"GLSL expressions require IEEE-754 binary64 doubles");
|
||||||
|
|
||||||
|
/* isfinite() is not valid with -ffinite-math-only under Clang. Inspect the
|
||||||
|
* binary64 exponent directly so expression overflow can still be rejected. */
|
||||||
|
uint64_t bits;
|
||||||
|
memcpy(&bits, &value, sizeof(bits));
|
||||||
|
return (bits & UINT64_C(0x7ff0000000000000)) !=
|
||||||
|
UINT64_C(0x7ff0000000000000);
|
||||||
|
}
|
||||||
|
|
||||||
static bool evaluateExpression(const GLSLContext * context,
|
static bool evaluateExpression(const GLSLContext * context,
|
||||||
const char * expression, double fallback, double * result)
|
const char * expression, double fallback, double * result)
|
||||||
{
|
{
|
||||||
@@ -653,7 +668,7 @@ static bool evaluateExpression(const GLSLContext * context,
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count != 1 || !isfinite(stack[0]))
|
if (count != 1 || !expressionValueFinite(stack[0]))
|
||||||
goto fail;
|
goto fail;
|
||||||
*result = stack[0];
|
*result = stack[0];
|
||||||
free(copy);
|
free(copy);
|
||||||
|
|||||||
Reference in New Issue
Block a user