mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-23 11:16:57 -04:00
os: refactor/rewrite entire namespace.
This commit is contained in:
parent
6193283f03
commit
065485b971
181 changed files with 5353 additions and 1929 deletions
|
@ -28,8 +28,14 @@ namespace ams::svc {
|
|||
using Handle = u32;
|
||||
#endif
|
||||
|
||||
enum {
|
||||
HandleWaitMask = (1u << 30),
|
||||
};
|
||||
|
||||
constexpr inline size_t MaxWaitSynchronizationHandleCount = 0x40;
|
||||
|
||||
constexpr inline s64 WaitInfinite = -1;
|
||||
|
||||
enum PseudoHandle : Handle {
|
||||
CurrentThread = 0xFFFF8000,
|
||||
CurrentProcess = 0xFFFF8001,
|
||||
|
|
|
@ -279,8 +279,14 @@ namespace ams::svc {
|
|||
ThreadActivity_Paused = 1,
|
||||
};
|
||||
|
||||
constexpr s32 LowestThreadPriority = 63;
|
||||
constexpr s32 HighestThreadPriority = 0;
|
||||
constexpr inline s32 IdealCoreDontCare = -1;
|
||||
constexpr inline s32 IdealCoreUseProcessValue = -2;
|
||||
constexpr inline s32 IdealCoreNoUpdate = -3;
|
||||
|
||||
constexpr inline s32 LowestThreadPriority = 63;
|
||||
constexpr inline s32 HighestThreadPriority = 0;
|
||||
|
||||
constexpr inline s32 SystemThreadPriorityHighest = 16;
|
||||
|
||||
/* Process types. */
|
||||
enum ProcessInfoType : u32 {
|
||||
|
|
|
@ -21,25 +21,18 @@
|
|||
|
||||
namespace ams {
|
||||
|
||||
class TimeSpan {
|
||||
private:
|
||||
struct TimeSpanType {
|
||||
public:
|
||||
s64 ns;
|
||||
private:
|
||||
constexpr explicit ALWAYS_INLINE TimeSpan(s64 v) : ns(v) { /* ... */ }
|
||||
public:
|
||||
constexpr explicit ALWAYS_INLINE TimeSpan() : TimeSpan(0) { /* ... */ }
|
||||
static constexpr ALWAYS_INLINE TimeSpanType FromNanoSeconds(s64 ns) { return {ns}; }
|
||||
static constexpr ALWAYS_INLINE TimeSpanType FromMicroSeconds(s64 ms) { return FromNanoSeconds(ms * INT64_C(1000)); }
|
||||
static constexpr ALWAYS_INLINE TimeSpanType FromMilliSeconds(s64 ms) { return FromMicroSeconds(ms * INT64_C(1000)); }
|
||||
static constexpr ALWAYS_INLINE TimeSpanType FromSeconds(s64 s) { return FromMilliSeconds(s * INT64_C(1000)); }
|
||||
static constexpr ALWAYS_INLINE TimeSpanType FromMinutes(s64 m) { return FromSeconds(m * INT64_C(60)); }
|
||||
static constexpr ALWAYS_INLINE TimeSpanType FromHours(s64 h) { return FromMinutes(h * INT64_C(60)); }
|
||||
static constexpr ALWAYS_INLINE TimeSpanType FromDays(s64 d) { return FromMinutes(d * INT64_C(24)); }
|
||||
|
||||
static constexpr ALWAYS_INLINE TimeSpan FromNanoSeconds(s64 ns) { return TimeSpan(ns); }
|
||||
static constexpr ALWAYS_INLINE TimeSpan FromMicroSeconds(s64 ms) { return FromNanoSeconds(ms * INT64_C(1000)); }
|
||||
static constexpr ALWAYS_INLINE TimeSpan FromMilliSeconds(s64 ms) { return FromMicroSeconds(ms * INT64_C(1000)); }
|
||||
static constexpr ALWAYS_INLINE TimeSpan FromSeconds(s64 s) { return FromMilliSeconds(s * INT64_C(1000)); }
|
||||
static constexpr ALWAYS_INLINE TimeSpan FromMinutes(s64 m) { return FromSeconds(m * INT64_C(60)); }
|
||||
static constexpr ALWAYS_INLINE TimeSpan FromHours(s64 h) { return FromMinutes(h * INT64_C(60)); }
|
||||
static constexpr ALWAYS_INLINE TimeSpan FromDays(s64 d) { return FromMinutes(d * INT64_C(24)); }
|
||||
|
||||
template<typename R, typename P>
|
||||
constexpr explicit ALWAYS_INLINE TimeSpan(const std::chrono::duration<R, P>& c) : TimeSpan(static_cast<std::chrono::nanoseconds>(c).count()) { /* ... */ }
|
||||
public:
|
||||
constexpr ALWAYS_INLINE s64 GetNanoSeconds() const { return this->ns; }
|
||||
constexpr ALWAYS_INLINE s64 GetMicroSeconds() const { return this->GetNanoSeconds() / (INT64_C(1000)); }
|
||||
constexpr ALWAYS_INLINE s64 GetMilliSeconds() const { return this->GetNanoSeconds() / (INT64_C(1000) * INT64_C(1000)); }
|
||||
|
@ -48,17 +41,60 @@ namespace ams {
|
|||
constexpr ALWAYS_INLINE s64 GetHours() const { return this->GetNanoSeconds() / (INT64_C(1000) * INT64_C(1000) * INT64_C(1000) * INT64_C( 60) * INT64_C( 60)); }
|
||||
constexpr ALWAYS_INLINE s64 GetDays() const { return this->GetNanoSeconds() / (INT64_C(1000) * INT64_C(1000) * INT64_C(1000) * INT64_C( 60) * INT64_C( 60) * INT64_C( 24)); }
|
||||
|
||||
constexpr ALWAYS_INLINE bool operator==(const TimeSpan &rhs) const { return this->ns == rhs.ns; }
|
||||
constexpr ALWAYS_INLINE bool operator!=(const TimeSpan &rhs) const { return this->ns != rhs.ns; }
|
||||
constexpr ALWAYS_INLINE bool operator<=(const TimeSpan &rhs) const { return this->ns <= rhs.ns; }
|
||||
constexpr ALWAYS_INLINE bool operator>=(const TimeSpan &rhs) const { return this->ns >= rhs.ns; }
|
||||
constexpr ALWAYS_INLINE bool operator< (const TimeSpan &rhs) const { return this->ns < rhs.ns; }
|
||||
constexpr ALWAYS_INLINE bool operator> (const TimeSpan &rhs) const { return this->ns > rhs.ns; }
|
||||
constexpr ALWAYS_INLINE friend bool operator==(const TimeSpanType &lhs, const TimeSpanType &rhs) { return lhs.ns == rhs.ns; }
|
||||
constexpr ALWAYS_INLINE friend bool operator!=(const TimeSpanType &lhs, const TimeSpanType &rhs) { return lhs.ns != rhs.ns; }
|
||||
constexpr ALWAYS_INLINE friend bool operator<=(const TimeSpanType &lhs, const TimeSpanType &rhs) { return lhs.ns <= rhs.ns; }
|
||||
constexpr ALWAYS_INLINE friend bool operator>=(const TimeSpanType &lhs, const TimeSpanType &rhs) { return lhs.ns >= rhs.ns; }
|
||||
constexpr ALWAYS_INLINE friend bool operator< (const TimeSpanType &lhs, const TimeSpanType &rhs) { return lhs.ns < rhs.ns; }
|
||||
constexpr ALWAYS_INLINE friend bool operator> (const TimeSpanType &lhs, const TimeSpanType &rhs) { return lhs.ns > rhs.ns; }
|
||||
|
||||
constexpr ALWAYS_INLINE TimeSpan &operator+=(TimeSpan rhs) { this->ns += rhs.ns; return *this; }
|
||||
constexpr ALWAYS_INLINE TimeSpan &operator-=(TimeSpan rhs) { this->ns -= rhs.ns; return *this; }
|
||||
constexpr ALWAYS_INLINE TimeSpan operator+(TimeSpan rhs) const { TimeSpan r(*this); return r += rhs; }
|
||||
constexpr ALWAYS_INLINE TimeSpan operator-(TimeSpan rhs) const { TimeSpan r(*this); return r -= rhs; }
|
||||
constexpr ALWAYS_INLINE TimeSpanType &operator+=(const TimeSpanType &rhs) { this->ns += rhs.ns; return *this; }
|
||||
constexpr ALWAYS_INLINE TimeSpanType &operator-=(const TimeSpanType &rhs) { this->ns -= rhs.ns; return *this; }
|
||||
|
||||
constexpr ALWAYS_INLINE friend TimeSpanType operator+(const TimeSpanType &lhs, const TimeSpanType &rhs) { TimeSpanType r(lhs); return r += rhs; }
|
||||
constexpr ALWAYS_INLINE friend TimeSpanType operator-(const TimeSpanType &lhs, const TimeSpanType &rhs) { TimeSpanType r(lhs); return r -= rhs; }
|
||||
};
|
||||
|
||||
class TimeSpan {
|
||||
private:
|
||||
using ZeroTag = const class ZeroTagImpl{} *;
|
||||
private:
|
||||
TimeSpanType ts;
|
||||
public:
|
||||
constexpr ALWAYS_INLINE TimeSpan(ZeroTag z = nullptr) : ts(TimeSpanType::FromNanoSeconds(0)) { /* ... */ }
|
||||
constexpr ALWAYS_INLINE TimeSpan(const TimeSpanType &t) : ts(t) { /* ... */ }
|
||||
|
||||
template<typename R, typename P>
|
||||
constexpr ALWAYS_INLINE TimeSpan(const std::chrono::duration<R, P>& c) : ts(TimeSpanType::FromNanoSeconds(static_cast<std::chrono::nanoseconds>(c).count())) { /* ... */ }
|
||||
public:
|
||||
static constexpr ALWAYS_INLINE TimeSpan FromNanoSeconds(s64 ns) { return TimeSpanType::FromNanoSeconds(ns); }
|
||||
static constexpr ALWAYS_INLINE TimeSpan FromMicroSeconds(s64 ms) { return TimeSpanType::FromMicroSeconds(ms); }
|
||||
static constexpr ALWAYS_INLINE TimeSpan FromMilliSeconds(s64 ms) { return TimeSpanType::FromMilliSeconds(ms); }
|
||||
static constexpr ALWAYS_INLINE TimeSpan FromSeconds(s64 s) { return TimeSpanType::FromSeconds(s); }
|
||||
static constexpr ALWAYS_INLINE TimeSpan FromMinutes(s64 m) { return TimeSpanType::FromMinutes(m); }
|
||||
static constexpr ALWAYS_INLINE TimeSpan FromHours(s64 h) { return TimeSpanType::FromHours(h); }
|
||||
static constexpr ALWAYS_INLINE TimeSpan FromDays(s64 d) { return TimeSpanType::FromDays(d); }
|
||||
|
||||
constexpr ALWAYS_INLINE s64 GetNanoSeconds() const { return this->ts.GetNanoSeconds(); }
|
||||
constexpr ALWAYS_INLINE s64 GetMicroSeconds() const { return this->ts.GetMicroSeconds(); }
|
||||
constexpr ALWAYS_INLINE s64 GetMilliSeconds() const { return this->ts.GetMilliSeconds(); }
|
||||
constexpr ALWAYS_INLINE s64 GetSeconds() const { return this->ts.GetSeconds(); }
|
||||
constexpr ALWAYS_INLINE s64 GetMinutes() const { return this->ts.GetMinutes(); }
|
||||
constexpr ALWAYS_INLINE s64 GetHours() const { return this->ts.GetHours(); }
|
||||
constexpr ALWAYS_INLINE s64 GetDays() const { return this->ts.GetDays(); }
|
||||
|
||||
constexpr ALWAYS_INLINE friend bool operator==(const TimeSpan &lhs, const TimeSpan &rhs) { return lhs.ts == rhs.ts; }
|
||||
constexpr ALWAYS_INLINE friend bool operator!=(const TimeSpan &lhs, const TimeSpan &rhs) { return lhs.ts != rhs.ts; }
|
||||
constexpr ALWAYS_INLINE friend bool operator<=(const TimeSpan &lhs, const TimeSpan &rhs) { return lhs.ts <= rhs.ts; }
|
||||
constexpr ALWAYS_INLINE friend bool operator>=(const TimeSpan &lhs, const TimeSpan &rhs) { return lhs.ts >= rhs.ts; }
|
||||
constexpr ALWAYS_INLINE friend bool operator< (const TimeSpan &lhs, const TimeSpan &rhs) { return lhs.ts < rhs.ts; }
|
||||
constexpr ALWAYS_INLINE friend bool operator> (const TimeSpan &lhs, const TimeSpan &rhs) { return lhs.ts > rhs.ts; }
|
||||
|
||||
constexpr ALWAYS_INLINE TimeSpan &operator+=(const TimeSpan &rhs) { this->ts += rhs.ts; return *this; }
|
||||
constexpr ALWAYS_INLINE TimeSpan &operator-=(const TimeSpan &rhs) { this->ts -= rhs.ts; return *this; }
|
||||
|
||||
constexpr ALWAYS_INLINE friend TimeSpan operator+(const TimeSpan &lhs, const TimeSpan &rhs) { TimeSpan r(lhs); return r += rhs; }
|
||||
constexpr ALWAYS_INLINE friend TimeSpan operator-(const TimeSpan &lhs, const TimeSpan &rhs) { TimeSpan r(lhs); return r -= rhs; }
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue