[Code] Make union usage more consistent

This commit is contained in:
Triang3l
2021-11-01 22:56:24 +03:00
committed by Triang3l
parent dbd518f137
commit fdec0ab332
18 changed files with 148 additions and 125 deletions

View File

@@ -558,11 +558,11 @@ struct xex2_header {
struct xex2_page_descriptor {
union {
xe::be<uint32_t> value; // 0x0
struct {
xex2_section_type info : 4;
uint32_t page_count : 28;
};
xe::be<uint32_t> value; // 0x0
};
char data_digest[0x14]; // 0x4
};

View File

@@ -36,13 +36,13 @@ class UserProfile {
INVALID = 0xFF,
};
union Key {
uint32_t value;
struct {
uint32_t id : 14;
uint32_t unk : 2;
uint32_t size : 12;
uint32_t type : 4;
};
uint32_t value;
};
uint32_t setting_id;
Type type;

View File

@@ -32,7 +32,7 @@ void XNotifyListener::Initialize(uint64_t mask, uint32_t max_version) {
}
void XNotifyListener::EnqueueNotification(XNotificationID id, uint32_t data) {
auto key = XNotificationKey{id};
auto key = XNotificationKey(id);
// Ignore if the notification doesn't match our mask.
if ((mask_ & uint64_t(1ULL << key.mask_index)) == 0) {
return;

View File

@@ -13,6 +13,7 @@
#include <memory>
#include <unordered_map>
#include "xenia/base/assert.h"
#include "xenia/base/mutex.h"
#include "xenia/base/threading.h"
#include "xenia/kernel/xobject.h"
@@ -22,21 +23,21 @@ namespace xe {
namespace kernel {
union XNotificationKey {
XNotificationID id;
struct {
uint32_t local_id : 16;
uint32_t version : 9;
uint32_t mask_index : 6;
uint32_t : 1;
};
XNotificationID id;
static constexpr XNotificationID get_id(uint8_t mask_index,
uint16_t local_id) {
XNotificationKey key = {};
key.mask_index = mask_index;
key.local_id = local_id;
return key.id;
constexpr XNotificationKey(
XNotificationID notification_id = XNotificationID(0))
: id(notification_id) {
static_assert_size(*this, sizeof(id));
}
constexpr operator XNotificationID() { return id; }
};
class XNotifyListener : public XObject {