mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-29 06:23:34 +08:00
Fixed typedef reuse
This commit is contained in:
@@ -50,10 +50,12 @@ public:
|
|||||||
static typename IntegerSpec<BitLen, SignednessUnsigned, CastModeTruncate>::StorageType
|
static typename IntegerSpec<BitLen, SignednessUnsigned, CastModeTruncate>::StorageType
|
||||||
toIeee(typename NativeFloatSelector<BitLen>::Type value)
|
toIeee(typename NativeFloatSelector<BitLen>::Type value)
|
||||||
{
|
{
|
||||||
typedef typename IntegerSpec<BitLen, SignednessUnsigned, CastModeTruncate>::StorageType IntType;
|
union
|
||||||
typedef typename NativeFloatSelector<BitLen>::Type FloatType;
|
{
|
||||||
StaticAssert<sizeof(FloatType) * 8 == BitLen>::check();
|
typename IntegerSpec<BitLen, SignednessUnsigned, CastModeTruncate>::StorageType i;
|
||||||
union { IntType i; FloatType f; } u;
|
typename NativeFloatSelector<BitLen>::Type f;
|
||||||
|
} u;
|
||||||
|
StaticAssert<sizeof(u.f) * 8 == BitLen>::check();
|
||||||
u.f = value;
|
u.f = value;
|
||||||
return u.i;
|
return u.i;
|
||||||
}
|
}
|
||||||
@@ -62,10 +64,12 @@ public:
|
|||||||
static typename NativeFloatSelector<BitLen>::Type
|
static typename NativeFloatSelector<BitLen>::Type
|
||||||
toNative(typename IntegerSpec<BitLen, SignednessUnsigned, CastModeTruncate>::StorageType value)
|
toNative(typename IntegerSpec<BitLen, SignednessUnsigned, CastModeTruncate>::StorageType value)
|
||||||
{
|
{
|
||||||
typedef typename IntegerSpec<BitLen, SignednessUnsigned, CastModeTruncate>::StorageType IntType;
|
union
|
||||||
typedef typename NativeFloatSelector<BitLen>::Type FloatType;
|
{
|
||||||
StaticAssert<sizeof(FloatType) * 8 == BitLen>::check();
|
typename IntegerSpec<BitLen, SignednessUnsigned, CastModeTruncate>::StorageType i;
|
||||||
union { IntType i; FloatType f; } u;
|
typename NativeFloatSelector<BitLen>::Type f;
|
||||||
|
} u;
|
||||||
|
StaticAssert<sizeof(u.f) * 8 == BitLen>::check();
|
||||||
u.i = value;
|
u.i = value;
|
||||||
return u.f;
|
return u.f;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ GlobalDataTypeRegistry::RegistResult GlobalDataTypeRegistry::regist(DataTypeID i
|
|||||||
return RegistResultFrozen;
|
return RegistResultFrozen;
|
||||||
}
|
}
|
||||||
|
|
||||||
static union EntryUnion
|
static union
|
||||||
{
|
{
|
||||||
uint8_t buffer[sizeof(Entry)];
|
uint8_t buffer[sizeof(Entry)];
|
||||||
long long _aligner_1;
|
long long _aligner_1;
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public:
|
|||||||
|
|
||||||
virtual uavcan::MonotonicTime getMonotonic() const
|
virtual uavcan::MonotonicTime getMonotonic() const
|
||||||
{
|
{
|
||||||
struct timespec ts;
|
timespec ts;
|
||||||
if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0)
|
if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0)
|
||||||
{
|
{
|
||||||
throw Exception("Failed to get monotonic time");
|
throw Exception("Failed to get monotonic time");
|
||||||
|
|||||||
Reference in New Issue
Block a user