mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-11-04 13:07:32 +00:00
The console's libc passes the value in xmm0: _Dsign (va 0x546f0) stores xmm0 with vmovsd and returns the top 16-bit word & 0x8000; _FDsign (va 0x546a0) does the same with vmovss. Take float/double by value, drop the null-pointer checks, and declare both in libc Api.hpp. The test calls the canonical declarations by value and covers +/-0, +/-1, +/-inf and -NaN.
31 lines
1.2 KiB
C++
31 lines
1.2 KiB
C++
#include "prx/libc/include/Api.hpp"
|
|
#include "prx/libc/include/general/VabiMacros.hpp"
|
|
#include <cstdlib>
|
|
#include <limits>
|
|
|
|
static void Require(bool value) { if (!value) std::abort(); }
|
|
|
|
int main() {
|
|
constexpr short Negative = static_cast<short>(0x8000);
|
|
const float floatInf = std::numeric_limits<float>::infinity();
|
|
const float floatNaN = std::numeric_limits<float>::quiet_NaN();
|
|
Require(_FDsign_nid_postfix(1.0f) == 0);
|
|
Require(_FDsign_nid_postfix(0.0f) == 0);
|
|
Require(_FDsign_nid_postfix(floatInf) == 0);
|
|
Require(_FDsign_nid_postfix(-1.0f) == Negative);
|
|
Require(_FDsign_nid_postfix(-0.0f) == Negative);
|
|
Require(_FDsign_nid_postfix(-floatInf) == Negative);
|
|
Require(_FDsign_nid_postfix(-floatNaN) == Negative);
|
|
|
|
const double doubleInf = std::numeric_limits<double>::infinity();
|
|
const double doubleNaN = std::numeric_limits<double>::quiet_NaN();
|
|
Require(_Dsign_nid_postfix(1.0) == 0);
|
|
Require(_Dsign_nid_postfix(0.0) == 0);
|
|
Require(_Dsign_nid_postfix(doubleInf) == 0);
|
|
Require(_Dsign_nid_postfix(-1.0) == Negative);
|
|
Require(_Dsign_nid_postfix(-0.0) == Negative);
|
|
Require(_Dsign_nid_postfix(-doubleInf) == Negative);
|
|
Require(_Dsign_nid_postfix(-doubleNaN) == Negative);
|
|
return 0;
|
|
}
|