URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Only display areas with differences |
Details |
Blame |
View Log
Rev 297 |
Rev 338 |
__extension__ union { double d; int i[2]; } u = { d: -0.25 };
|
__extension__ union { double d; int i[2]; } u = { d: -0.25 };
|
|
|
/* This assumes the endianness of words in a long long is the same as
|
/* This assumes the endianness of words in a long long is the same as
|
that for doubles, which doesn't hold for a few platforms, but we
|
that for doubles, which doesn't hold for a few platforms, but we
|
can probably special case them here, as appropriate. */
|
can probably special case them here, as appropriate. */
|
long long endianness_test = 1;
|
long long endianness_test = 1;
|
#define MSW (*(int*)&endianness_test)
|
#define MSW (*(int*)&endianness_test)
|
|
|
int
|
int
|
signbit(double x)
|
signbit(double x)
|
{
|
{
|
__extension__ union { double d; int i[2]; } u = { d: x };
|
__extension__ union { double d; int i[2]; } u = { d: x };
|
return u.i[MSW] < 0;
|
return u.i[MSW] < 0;
|
}
|
}
|
|
|
int main(void)
|
int main(void)
|
{
|
{
|
if (2*sizeof(int) != sizeof(double) || u.i[MSW] >= 0)
|
if (2*sizeof(int) != sizeof(double) || u.i[MSW] >= 0)
|
exit(0);
|
exit(0);
|
|
|
if (!signbit(-0.25))
|
if (!signbit(-0.25))
|
abort();
|
abort();
|
|
|
exit(0);
|
exit(0);
|
}
|
}
|
|
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.