// { dg-do run { target { { i?86-*-* x86_64-*-* } && ilp32 } } }
|
// { dg-do run { target { { i?86-*-* x86_64-*-* } && ilp32 } } }
|
// { dg-options "-O2" }
|
// { dg-options "-O2" }
|
|
|
typedef unsigned long long uint64;
|
typedef unsigned long long uint64;
|
typedef __SIZE_TYPE__ size_t;
|
typedef __SIZE_TYPE__ size_t;
|
|
|
extern "C" {
|
extern "C" {
|
extern void *memcpy (void *__restrict __dest,
|
extern void *memcpy (void *__restrict __dest,
|
__const void *__restrict __src, size_t __n) /*throw ()*/;
|
__const void *__restrict __src, size_t __n) /*throw ()*/;
|
extern void abort (void);
|
extern void abort (void);
|
}
|
}
|
|
|
extern void foo (void* p);
|
extern void foo (void* p);
|
|
|
inline uint64
|
inline uint64
|
ghtonll(uint64 x)
|
ghtonll(uint64 x)
|
{
|
{
|
// __r is allocated the same stack slot as dest below
|
// __r is allocated the same stack slot as dest below
|
union { unsigned long long int __ll;
|
union { unsigned long long int __ll;
|
unsigned long int __l[2]; } __w, __r;
|
unsigned long int __l[2]; } __w, __r;
|
__w.__ll = x;
|
__w.__ll = x;
|
__r.__l[0] = (
|
__r.__l[0] = (
|
{
|
{
|
register unsigned int __v;
|
register unsigned int __v;
|
__asm__ __volatile__ ("bswap %0" : "=r" (__v) :
|
__asm__ __volatile__ ("bswap %0" : "=r" (__v) :
|
"0" ((unsigned int) (__w.__l[1])));
|
"0" ((unsigned int) (__w.__l[1])));
|
__v; });
|
__v; });
|
|
|
__r.__l[1] = (
|
__r.__l[1] = (
|
{
|
{
|
register unsigned int __v;
|
register unsigned int __v;
|
__asm__ __volatile__ ("bswap %0" : "=r" (__v) :
|
__asm__ __volatile__ ("bswap %0" : "=r" (__v) :
|
"0" ((unsigned int) (__w.__l[0])));
|
"0" ((unsigned int) (__w.__l[0])));
|
__v; });
|
__v; });
|
|
|
return __r.__ll;
|
return __r.__ll;
|
}
|
}
|
|
|
inline uint64
|
inline uint64
|
double_2_uint64 (const double *source)
|
double_2_uint64 (const double *source)
|
{
|
{
|
uint64 dest; // allocated the same stack slot as __r above
|
uint64 dest; // allocated the same stack slot as __r above
|
memcpy(&dest, source, sizeof(dest));
|
memcpy(&dest, source, sizeof(dest));
|
return dest;
|
return dest;
|
}
|
}
|
|
|
inline void
|
inline void
|
KeyFromUint64(uint64 fp) {
|
KeyFromUint64(uint64 fp) {
|
uint64 norder;
|
uint64 norder;
|
norder = ghtonll (fp);
|
norder = ghtonll (fp);
|
foo((char*)(&norder));
|
foo((char*)(&norder));
|
}
|
}
|
|
|
void
|
void
|
KeyFromDouble(double x) {
|
KeyFromDouble(double x) {
|
uint64 n = double_2_uint64 (&x);
|
uint64 n = double_2_uint64 (&x);
|
if (n >= 42) {
|
if (n >= 42) {
|
n += 1;
|
n += 1;
|
}
|
}
|
|
|
KeyFromUint64(n);
|
KeyFromUint64(n);
|
}
|
}
|
|
|
#define NUM 0x0123456789abcdefll
|
#define NUM 0x0123456789abcdefll
|
#define EXPECTED 0xe0bc9a7856347243ll
|
#define EXPECTED 0xe0bc9a7856347243ll
|
|
|
void foo (void *x)
|
void foo (void *x)
|
{
|
{
|
if (*((uint64 *)x) != (uint64) EXPECTED)
|
if (*((uint64 *)x) != (uint64) EXPECTED)
|
abort ();
|
abort ();
|
}
|
}
|
|
|
int main ()
|
int main ()
|
{
|
{
|
if (sizeof (double) != sizeof (uint64))
|
if (sizeof (double) != sizeof (uint64))
|
return 0;
|
return 0;
|
|
|
if (sizeof (uint64) == sizeof (unsigned long int))
|
if (sizeof (uint64) == sizeof (unsigned long int))
|
return 0;
|
return 0;
|
|
|
KeyFromDouble ((double)NUM);
|
KeyFromDouble ((double)NUM);
|
|
|
return 0;
|
return 0;
|
}
|
}
|
|
|