mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-04-22 20:44:49 +00:00
Fixed ContentId/PlaceHolderId alignment
This commit is contained in:
parent
c1734f062b
commit
15e8e32409
4 changed files with 51 additions and 12 deletions
|
@ -45,7 +45,7 @@ namespace sts::ncm::impl {
|
|||
return false;
|
||||
}
|
||||
*out_handle = entry->handle;
|
||||
entry->id = InvalidUuid;
|
||||
entry->id = InvalidPlaceHolderId;
|
||||
entry->handle = nullptr;
|
||||
return true;
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ namespace sts::ncm::impl {
|
|||
|
||||
PlaceHolderAccessor::CacheEntry *PlaceHolderAccessor::GetFreeEntry() {
|
||||
/* Try to find an already free entry. */
|
||||
CacheEntry* entry = this->FindInCache(InvalidUuid);
|
||||
CacheEntry* entry = this->FindInCache(InvalidPlaceHolderId);
|
||||
|
||||
if (entry) {
|
||||
return entry;
|
||||
|
@ -95,7 +95,7 @@ namespace sts::ncm::impl {
|
|||
fclose(entry->handle);
|
||||
entry->handle = nullptr;
|
||||
}
|
||||
entry->id = InvalidUuid;
|
||||
entry->id = InvalidPlaceHolderId;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -194,7 +194,7 @@ namespace sts::ncm::impl {
|
|||
{
|
||||
std::scoped_lock lock(this->cache_mutex);
|
||||
|
||||
if (placeholder_id == InvalidUuid) {
|
||||
if (placeholder_id == InvalidPlaceHolderId) {
|
||||
*found_in_cache = false;
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ namespace sts::ncm::impl {
|
|||
return ResultSuccess;
|
||||
}
|
||||
|
||||
cache_entry->id = InvalidUuid;
|
||||
cache_entry->id = InvalidPlaceHolderId;
|
||||
f = cache_entry->handle;
|
||||
}
|
||||
|
||||
|
@ -234,7 +234,7 @@ namespace sts::ncm::impl {
|
|||
|
||||
void PlaceHolderAccessor::InvalidateAll() {
|
||||
for (auto &entry : this->caches) {
|
||||
if (entry.id != InvalidUuid) {
|
||||
if (entry.id != InvalidPlaceHolderId) {
|
||||
this->Invalidate(&entry);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace sts::ncm::impl {
|
|||
public:
|
||||
PlaceHolderAccessor() : cur_counter(0), delay_flush(false) {
|
||||
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() {
|
||||
if (this->cached_content_id != InvalidUuid) {
|
||||
if (this->cached_content_id != InvalidContentId) {
|
||||
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 {
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
u8& operator[](size_t i) {
|
||||
return uuid[i];
|
||||
}
|
||||
};
|
||||
|
||||
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;
|
||||
typedef Uuid PlaceHolderId;
|
||||
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(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 {
|
||||
Unknown = 0x0,
|
||||
|
|
Loading…
Add table
Reference in a new issue