types.hpp: implement smin, smax, amin, amax

Rewritten the following global utility constants:
`umax` returns max number, restricted to unsigned.
`smax` returns max signed number, restricted to integrals.
`smin` returns min signed number, restricted to signed.
`amin` returns smin or zero, less restricted.
`amax` returns smax or umax, less restricted.

Fix operators == and <=> for synthesized rel-ops.
This commit is contained in:
Nekotekina 2021-05-22 10:35:15 +03:00
parent 613777afde
commit 160b131de3
38 changed files with 219 additions and 111 deletions

View file

@ -41,7 +41,7 @@ namespace utils
class address_range
{
public:
u32 start = UINT32_MAX; // First address in range
u32 start = umax; // First address in range
u32 end = 0; // Last address
private:
@ -174,7 +174,7 @@ namespace utils
address_range get_min_max(const address_range &other) const
{
return {
std::min(valid() ? start : UINT32_MAX, other.valid() ? other.start : UINT32_MAX),
std::min(valid() ? start : umax, other.valid() ? other.start : umax),
std::max(valid() ? end : 0, other.valid() ? other.end : 0)
};
}
@ -234,7 +234,7 @@ namespace utils
void invalidate()
{
start = UINT32_MAX;
start = umax;
end = 0;
}