Replace TARGET_ARM_MODE pragma with ARM_MODE function attributes
This commit is contained in:
parent
eb4412847e
commit
589676854c
@ -5,8 +5,6 @@
|
||||
|
||||
#include "mtl/target.hpp"
|
||||
|
||||
TARGET_ARM_MODE
|
||||
|
||||
namespace mtl {
|
||||
/**
|
||||
* \brief 32-bit Fixed point number
|
||||
@ -44,9 +42,11 @@ private:
|
||||
* DO NOT use to set the fixed number to an integer value, use
|
||||
* the public constructor instead.
|
||||
*/
|
||||
ARM_MODE
|
||||
constexpr fixed(int32_t _x, bool) noexcept : x(_x) {}
|
||||
|
||||
public:
|
||||
ARM_MODE
|
||||
constexpr fixed() noexcept : x(0) {}
|
||||
/**
|
||||
* \brief Integer constructor
|
||||
@ -56,6 +56,7 @@ public:
|
||||
* the class description for more detail.
|
||||
*/
|
||||
template <typename T, std::enable_if_t<std::is_integral_v<T>, bool> = true>
|
||||
ARM_MODE
|
||||
constexpr fixed(T _i) noexcept : x(_i * 64) {}
|
||||
/**
|
||||
* \brief Floating point constructor
|
||||
@ -69,6 +70,7 @@ public:
|
||||
* float.
|
||||
*/
|
||||
template <typename T, std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
|
||||
ARM_MODE
|
||||
constexpr fixed(T _f) noexcept
|
||||
// 0.5 offset accounts for truncating to integer, round instead
|
||||
: x((_f * 64) + 0.5f) {}
|
||||
@ -82,6 +84,7 @@ public:
|
||||
*
|
||||
* Should not be used unless absolutely needed.
|
||||
*/
|
||||
ARM_MODE
|
||||
static constexpr fixed from_raw(int32_t x) noexcept {
|
||||
return fixed(x, true);
|
||||
}
|
||||
@ -92,6 +95,7 @@ public:
|
||||
* Gets the raw value of the fixed point number. i.e. The fixed point
|
||||
* number multiplied by 64.
|
||||
*/
|
||||
ARM_MODE
|
||||
constexpr int32_t raw() const noexcept {
|
||||
return x;
|
||||
}
|
||||
@ -102,9 +106,11 @@ public:
|
||||
* Addition with fixed point numbers is the same as with a 32-bit
|
||||
* integer, so should be extremely quick.
|
||||
*/
|
||||
ARM_MODE
|
||||
constexpr fixed operator+(fixed rhs) const noexcept {
|
||||
return from_raw(x + rhs.x);
|
||||
}
|
||||
ARM_MODE
|
||||
constexpr fixed& operator+=(fixed rhs) noexcept {
|
||||
x += rhs.x;
|
||||
return *this;
|
||||
@ -112,13 +118,16 @@ public:
|
||||
/**
|
||||
* \brief Fixed point subtraction
|
||||
*/
|
||||
ARM_MODE
|
||||
constexpr fixed operator-(fixed rhs) const noexcept {
|
||||
return from_raw(x - rhs.x);
|
||||
}
|
||||
ARM_MODE
|
||||
constexpr fixed& operator-=(fixed rhs) noexcept {
|
||||
x -= rhs.x;
|
||||
return *this;
|
||||
}
|
||||
ARM_MODE
|
||||
constexpr fixed operator-() const noexcept {
|
||||
return from_raw(-x);
|
||||
}
|
||||
@ -126,9 +135,11 @@ public:
|
||||
/**
|
||||
* \brief Fixed point multiplication
|
||||
*/
|
||||
ARM_MODE
|
||||
constexpr fixed operator*(fixed rhs) const noexcept {
|
||||
return from_raw(((int64_t)x * rhs.x) >> 6);
|
||||
}
|
||||
ARM_MODE
|
||||
constexpr fixed& operator*=(fixed rhs) noexcept {
|
||||
*this = *this * rhs;
|
||||
return *this;
|
||||
@ -149,7 +160,9 @@ public:
|
||||
*
|
||||
* Placed in IWRAM
|
||||
*/
|
||||
GBA_IWRAM fixed operator/(fixed rhs) const noexcept;
|
||||
ARM_MODE GBA_IWRAM
|
||||
fixed operator/(fixed rhs) const noexcept;
|
||||
ARM_MODE
|
||||
fixed& operator/=(fixed rhs) noexcept {
|
||||
*this = *this / rhs;
|
||||
return *this;
|
||||
@ -158,5 +171,3 @@ public:
|
||||
|
||||
} // namespace mtl
|
||||
|
||||
TARGET_END_MODE
|
||||
|
||||
|
||||
@ -2,8 +2,6 @@
|
||||
|
||||
#include "mtl/fixed.hpp"
|
||||
|
||||
TARGET_ARM_MODE
|
||||
|
||||
namespace mtl {
|
||||
|
||||
fixed fixed::operator/(fixed rhs) const noexcept {
|
||||
@ -56,5 +54,3 @@ fixed fixed::operator/(fixed rhs) const noexcept {
|
||||
|
||||
} // namespace mtl
|
||||
|
||||
TARGET_END_MODE
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user