mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-18 01:46:47 +00:00
sm/tipc: ensure technical-correctness of sins (no page cost)
This commit is contained in:
parent
f98c7cba98
commit
fcc7ce49d9
2 changed files with 19 additions and 11 deletions
|
@ -96,14 +96,14 @@ namespace ams::tipc {
|
||||||
};
|
};
|
||||||
static_assert(std::is_standard_layout<DeferrableBaseImpl>::value);
|
static_assert(std::is_standard_layout<DeferrableBaseImpl>::value);
|
||||||
|
|
||||||
template<typename Interface>
|
template<size_t _MessageBufferRequiredSize>
|
||||||
class DeferrableBase : public DeferrableBaseImpl {
|
class DeferrableBaseImplWithBuffer : public DeferrableBaseImpl {
|
||||||
private:
|
private:
|
||||||
static constexpr size_t MessageBufferRequiredSize = Interface::MaximumRequestSize;
|
static constexpr size_t MessageBufferRequiredSize = _MessageBufferRequiredSize;
|
||||||
private:
|
private:
|
||||||
u8 m_message_buffer[MessageBufferRequiredSize];
|
u8 m_message_buffer[MessageBufferRequiredSize];
|
||||||
public:
|
public:
|
||||||
DeferrableBase();
|
DeferrableBaseImplWithBuffer();
|
||||||
private:
|
private:
|
||||||
static consteval size_t GetMessageBufferOffset();
|
static consteval size_t GetMessageBufferOffset();
|
||||||
};
|
};
|
||||||
|
@ -112,17 +112,25 @@ namespace ams::tipc {
|
||||||
return AMS_OFFSETOF(DeferrableBaseImpl, m_message_buffer_base);
|
return AMS_OFFSETOF(DeferrableBaseImpl, m_message_buffer_base);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Interface>
|
template<size_t _MessageBufferRequiredSize>
|
||||||
consteval size_t DeferrableBase<Interface>::GetMessageBufferOffset() {
|
consteval size_t DeferrableBaseImplWithBuffer<_MessageBufferRequiredSize>::GetMessageBufferOffset() {
|
||||||
return AMS_OFFSETOF(DeferrableBase<Interface>, m_message_buffer);
|
return AMS_OFFSETOF(DeferrableBaseImplWithBuffer<_MessageBufferRequiredSize>, m_message_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Interface>
|
template<size_t _MessageBufferRequiredSize>
|
||||||
ALWAYS_INLINE DeferrableBase<Interface>::DeferrableBase() : DeferrableBaseImpl(MessageBufferRequiredSize) {
|
ALWAYS_INLINE DeferrableBaseImplWithBuffer<_MessageBufferRequiredSize>::DeferrableBaseImplWithBuffer() : DeferrableBaseImpl(MessageBufferRequiredSize) {
|
||||||
static_assert(GetMessageBufferOffsetBase() == GetMessageBufferOffset());
|
static_assert(GetMessageBufferOffsetBase() == GetMessageBufferOffset());
|
||||||
static_assert(sizeof(DeferrableBase<Interface>) >= sizeof(DeferrableBaseImpl) + MessageBufferRequiredSize);
|
static_assert(sizeof(DeferrableBaseImplWithBuffer<_MessageBufferRequiredSize>) >= sizeof(DeferrableBaseImpl) + MessageBufferRequiredSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename Interface, size_t MaximumDefaultRequestSize = 0>
|
||||||
|
class DeferrableBase : public DeferrableBaseImplWithBuffer<std::max(Interface::MaximumRequestSize, MaximumDefaultRequestSize)> {
|
||||||
|
private:
|
||||||
|
using BaseImpl = DeferrableBaseImplWithBuffer<std::max(Interface::MaximumRequestSize, MaximumDefaultRequestSize)>;
|
||||||
|
public:
|
||||||
|
using BaseImpl::BaseImpl;
|
||||||
|
};
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
concept IsDeferrable = std::derived_from<T, impl::DeferrableBaseTag>;
|
concept IsDeferrable = std::derived_from<T, impl::DeferrableBaseTag>;
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
namespace ams::sm {
|
namespace ams::sm {
|
||||||
|
|
||||||
/* Service definition. */
|
/* Service definition. */
|
||||||
class UserService : public tipc::DeferrableBase<sm::impl::IUserInterface> {
|
class UserService : public tipc::DeferrableBase<sm::impl::IUserInterface, /* Maximum deferrable CMIF message size: */ 0x20 + util::AlignUp(sizeof(sm::ServiceName), sizeof(u32))> {
|
||||||
private:
|
private:
|
||||||
os::ProcessId m_process_id;
|
os::ProcessId m_process_id;
|
||||||
bool m_initialized;
|
bool m_initialized;
|
||||||
|
|
Loading…
Reference in a new issue