mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-07-07 01:52:14 +02:00
Fixed ContentId/PlaceHolderId alignment
This commit is contained in:
parent
b7f72323a7
commit
b17c556fcb
@ -45,7 +45,7 @@ namespace sts::ncm::impl {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
*out_handle = entry->handle;
|
*out_handle = entry->handle;
|
||||||
entry->id = InvalidUuid;
|
entry->id = InvalidPlaceHolderId;
|
||||||
entry->handle = nullptr;
|
entry->handle = nullptr;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -61,7 +61,7 @@ namespace sts::ncm::impl {
|
|||||||
|
|
||||||
PlaceHolderAccessor::CacheEntry *PlaceHolderAccessor::GetFreeEntry() {
|
PlaceHolderAccessor::CacheEntry *PlaceHolderAccessor::GetFreeEntry() {
|
||||||
/* Try to find an already free entry. */
|
/* Try to find an already free entry. */
|
||||||
CacheEntry* entry = this->FindInCache(InvalidUuid);
|
CacheEntry* entry = this->FindInCache(InvalidPlaceHolderId);
|
||||||
|
|
||||||
if (entry) {
|
if (entry) {
|
||||||
return entry;
|
return entry;
|
||||||
@ -95,7 +95,7 @@ namespace sts::ncm::impl {
|
|||||||
fclose(entry->handle);
|
fclose(entry->handle);
|
||||||
entry->handle = nullptr;
|
entry->handle = nullptr;
|
||||||
}
|
}
|
||||||
entry->id = InvalidUuid;
|
entry->id = InvalidPlaceHolderId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,7 +194,7 @@ namespace sts::ncm::impl {
|
|||||||
{
|
{
|
||||||
std::scoped_lock lock(this->cache_mutex);
|
std::scoped_lock lock(this->cache_mutex);
|
||||||
|
|
||||||
if (placeholder_id == InvalidUuid) {
|
if (placeholder_id == InvalidPlaceHolderId) {
|
||||||
*found_in_cache = false;
|
*found_in_cache = false;
|
||||||
return ResultSuccess;
|
return ResultSuccess;
|
||||||
}
|
}
|
||||||
@ -206,7 +206,7 @@ namespace sts::ncm::impl {
|
|||||||
return ResultSuccess;
|
return ResultSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
cache_entry->id = InvalidUuid;
|
cache_entry->id = InvalidPlaceHolderId;
|
||||||
f = cache_entry->handle;
|
f = cache_entry->handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,7 +234,7 @@ namespace sts::ncm::impl {
|
|||||||
|
|
||||||
void PlaceHolderAccessor::InvalidateAll() {
|
void PlaceHolderAccessor::InvalidateAll() {
|
||||||
for (auto &entry : this->caches) {
|
for (auto &entry : this->caches) {
|
||||||
if (entry.id != InvalidUuid) {
|
if (entry.id != InvalidPlaceHolderId) {
|
||||||
this->Invalidate(&entry);
|
this->Invalidate(&entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ namespace sts::ncm::impl {
|
|||||||
public:
|
public:
|
||||||
PlaceHolderAccessor() : cur_counter(0), delay_flush(false) {
|
PlaceHolderAccessor() : cur_counter(0), delay_flush(false) {
|
||||||
for (size_t i = 0; i < MaxCaches; i++) {
|
for (size_t i = 0; i < MaxCaches; i++) {
|
||||||
caches[i].id = InvalidUuid;
|
caches[i].id = InvalidPlaceHolderId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,9 +49,9 @@ namespace sts::ncm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ContentStorageInterface::ClearContentCache() {
|
void ContentStorageInterface::ClearContentCache() {
|
||||||
if (this->cached_content_id != InvalidUuid) {
|
if (this->cached_content_id != InvalidContentId) {
|
||||||
fclose(this->content_cache_file_handle);
|
fclose(this->content_cache_file_handle);
|
||||||
this->cached_content_id = InvalidUuid;
|
this->cached_content_id = InvalidContentId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,14 +34,53 @@ namespace sts::ncm {
|
|||||||
bool operator!=(const Uuid& other) const {
|
bool operator!=(const Uuid& other) const {
|
||||||
return !(*this == other);
|
return !(*this == other);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u8& operator[](size_t i) {
|
||||||
|
return uuid[i];
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static_assert(sizeof(Uuid) == 0x10, "Uuid definition!");
|
static_assert(sizeof(Uuid) == 0x10, "Uuid definition!");
|
||||||
|
|
||||||
static constexpr Uuid InvalidUuid = { { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } };
|
struct PlaceHolderId {
|
||||||
|
Uuid uuid;
|
||||||
|
|
||||||
typedef Uuid ContentId;
|
inline operator Uuid() const {
|
||||||
typedef Uuid PlaceHolderId;
|
return this->uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator==(const Uuid& other) const {
|
||||||
|
return this->uuid == other;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator!=(const Uuid& other) const {
|
||||||
|
return this->uuid != other;
|
||||||
|
}
|
||||||
|
} __attribute__((aligned(8)));
|
||||||
|
|
||||||
|
static_assert(__alignof__(PlaceHolderId) == 8, "PlaceHolderId definition!");
|
||||||
|
|
||||||
|
struct ContentId {
|
||||||
|
Uuid uuid;
|
||||||
|
|
||||||
|
inline operator Uuid() const {
|
||||||
|
return this->uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator==(const Uuid& other) const {
|
||||||
|
return this->uuid == other;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator!=(const Uuid& other) const {
|
||||||
|
return this->uuid != other;
|
||||||
|
}
|
||||||
|
} __attribute__((aligned(4)));
|
||||||
|
|
||||||
|
static_assert(__alignof__(ContentId) == 4, "ContentId definition!");
|
||||||
|
|
||||||
|
static constexpr Uuid InvalidUuid = { { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } };
|
||||||
|
static constexpr PlaceHolderId InvalidPlaceHolderId = { InvalidUuid };
|
||||||
|
static constexpr ContentId InvalidContentId = { InvalidUuid };
|
||||||
|
|
||||||
enum class ContentMetaType : u8 {
|
enum class ContentMetaType : u8 {
|
||||||
Unknown = 0x0,
|
Unknown = 0x0,
|
||||||
|
Loading…
Reference in New Issue
Block a user