Fix warnings/errors for strict aliasing & function prototypes
This fixes various issues related to gcc's strict-aliasing warning by using unions. It also handles various cases hit with gcc's missing-declarations warning.
This commit is contained in:
parent
0967748fbc
commit
18b637f9dc
11 changed files with 39 additions and 17 deletions
|
|
@ -43,22 +43,31 @@ namespace {
|
|||
|
||||
using namespace glslang;
|
||||
|
||||
typedef union {
|
||||
double d;
|
||||
int i[2];
|
||||
} DoubleIntUnion;
|
||||
|
||||
// Some helper functions
|
||||
|
||||
bool isNan(double x)
|
||||
{
|
||||
DoubleIntUnion u;
|
||||
// tough to find a platform independent library function, do it directly
|
||||
int bitPatternL = *(int*)&x;
|
||||
int bitPatternH = *((int*)&x + 1);
|
||||
u.d = x;
|
||||
int bitPatternL = u.i[0];
|
||||
int bitPatternH = u.i[1];
|
||||
return (bitPatternH & 0x7ff80000) == 0x7ff80000 &&
|
||||
((bitPatternH & 0xFFFFF) != 0 || bitPatternL != 0);
|
||||
}
|
||||
|
||||
bool isInf(double x)
|
||||
{
|
||||
DoubleIntUnion u;
|
||||
// tough to find a platform independent library function, do it directly
|
||||
int bitPatternL = *(int*)&x;
|
||||
int bitPatternH = *((int*)&x + 1);
|
||||
u.d = x;
|
||||
int bitPatternL = u.i[0];
|
||||
int bitPatternH = u.i[1];
|
||||
return (bitPatternH & 0x7ff00000) == 0x7ff00000 &&
|
||||
(bitPatternH & 0xFFFFF) == 0 && bitPatternL == 0;
|
||||
}
|
||||
|
|
@ -173,7 +182,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TIntermTyped* right
|
|||
case EbtInt:
|
||||
if (rightUnionArray[i] == 0)
|
||||
newConstArray[i].setIConst(0x7FFFFFFF);
|
||||
else if (rightUnionArray[i].getIConst() == -1 && leftUnionArray[i].getIConst() == 0x80000000)
|
||||
else if (rightUnionArray[i].getIConst() == -1 && leftUnionArray[i].getIConst() == (int)0x80000000)
|
||||
newConstArray[i].setIConst(0x80000000);
|
||||
else
|
||||
newConstArray[i].setIConst(leftUnionArray[i].getIConst() / rightUnionArray[i].getIConst());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue