|
OpenADFortTk (basic)
|
00001 // ########################################################## 00002 // # This file is part of OpenADFortTk. # 00003 // # The full COPYRIGHT notice can be found in the top # 00004 // # level directory of the OpenADFortTk source tree. # 00005 // # For more information visit # 00006 // # http://www.mcs.anl.gov/openad # 00007 // ########################################################## 00008 00009 #ifndef FortTk_quad_INCLUDED 00010 #define FortTk_quad_INCLUDED 00011 00012 #include <../../common/com/targ_const.h> // QUAD_TYPE 00013 namespace FortTk { 00014 00015 // Used to translate the bits within TCONs. We can safely assume 64 00016 // bit values are available on modern platforms. This is used 00017 // simply to convey bits, so we are not concerned with little/big 00018 // endian issues. 00019 struct uint128_t { 00020 00021 uint128_t() : hi(0), lo(0) { } 00022 ~uint128_t() { } 00023 00024 uint128_t(const uint128_t& v) : hi(v.hi), lo(v.lo) { } 00025 uint128_t(const QUAD_TYPE& v) { *this = v; } 00026 00027 uint64_t hi; 00028 uint64_t lo; 00029 }; 00030 00031 inline uint128_t& 00032 assign(uint128_t& qd1, QUAD_TYPE& qd2) { 00033 qd1.hi = *( ((uint64_t*)&qd2) + 1 ); // high 64 bits 00034 qd1.lo = *( (uint64_t*)&qd2 ); // low 64 bits 00035 return qd1; 00036 } 00037 00038 inline QUAD_TYPE& 00039 assign(QUAD_TYPE& qd1, uint128_t& qd2) { 00040 *( ((uint64_t*)&qd1) + 1 ) = qd2.hi; // high 64 bits 00041 *( (uint64_t*)&qd1 ) = qd2.lo; // low 64 bits 00042 return qd1; 00043 } 00044 00045 }; 00046 00047 #endif