Skip to content

Commit

Permalink
Add checks for aarch64 and arm
Browse files Browse the repository at this point in the history
  • Loading branch information
kumarak committed Aug 19, 2021
1 parent c34bda1 commit e594089
Showing 1 changed file with 39 additions and 4 deletions.
43 changes: 39 additions & 4 deletions include/remill/Arch/Runtime/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ struct float80_t final {
static_assert(12 == sizeof(long double) || 16 == sizeof(long double), "Invalid `float128_t` size.");

union union_ld {
uint8_t data[sizeof(float128_t)];
float128_t ld;
uint8_t data[sizeof(long double)];
long double ld;
} __attribute((packed));

union_ld f80 = {.ld = ld};
for (unsigned i = 0; i < sizeof(float80_t); i++) {
this->data[i] = f80.data[i];
Expand All @@ -110,12 +111,46 @@ struct float80_t final {
f80.data[i] = this->data[i];
}

return static_cast<long double>(f80.ld);
return f80.ld;
}

#elif defined(__aarch64__) || defined(__arm__)
inline float80_t(long double ld) {
static_assert(8 == sizeof(long double), "Invalid `long double` size.");

union union_ld {
uint8_t data[sizeof(long double)];
long double ld;
} __attribute((packed));

union_ld f80 = {.ld = ld};
for (unsigned i = 0; i < sizeof(long double); i++) {
this->data[i] = f80.data[i];
}
}

operator long double() {
static_assert(8 == sizeof(long double), "Invalid `long double` size.");

union union_ld {
uint8_t data[sizeof(long double)];
long double ld;
} __attribute((packed));

union_ld f80 = {{0}};
for (unsigned i = 0; i < sizeof(long double); i++) {
f80.data[i] = this->data[i];
}

return f80.ld;
}

#else
#error "float80_t not supported!";
#endif
} __attribute__((packed));

//static_assert(10 == sizeof(float80_t), "Invalid `float80_t` size.");
static_assert(10 == sizeof(float80_t), "Invalid `float80_t` size.");

union nan32_t {
float32_t f;
Expand Down

0 comments on commit e594089

Please sign in to comment.