diff --git a/src/alloy/core.h b/src/alloy/core.h index c465fe9d5..e8a2c6637 100644 --- a/src/alloy/core.h +++ b/src/alloy/core.h @@ -14,7 +14,5 @@ #include #include #include -#include -#include #endif // ALLOY_CORE_H_ diff --git a/src/alloy/frontend/ppc/ppc_context.h b/src/alloy/frontend/ppc/ppc_context.h index b9858323a..f3365e192 100644 --- a/src/alloy/frontend/ppc/ppc_context.h +++ b/src/alloy/frontend/ppc/ppc_context.h @@ -12,6 +12,7 @@ #include #include +#include namespace alloy { namespace runtime { class Runtime; @@ -37,7 +38,7 @@ using vec128_t = alloy::vec128_t; // 128-256: VR #pragma pack(push, 4) -typedef struct XECACHEALIGN64 PPCContext_s { +typedef struct alignas(64) PPCContext_s { // Must be stored at 0x0 for now. // TODO(benvanik): find a nice way to describe this to the JIT. runtime::ThreadState* thread_state; diff --git a/src/alloy/vec128.h b/src/alloy/vec128.h index cedb39bc9..35caef5d1 100644 --- a/src/alloy/vec128.h +++ b/src/alloy/vec128.h @@ -11,10 +11,11 @@ #define ALLOY_VEC128_H_ #include +#include namespace alloy { -typedef struct XECACHEALIGN vec128_s { +typedef struct alignas(16) vec128_s { union { struct { float x; diff --git a/src/poly/platform.h b/src/poly/platform.h index b0463c0bc..05be89e48 100644 --- a/src/poly/platform.h +++ b/src/poly/platform.h @@ -123,12 +123,6 @@ XE_CPU: 32BIT | 64BIT | BIGENDIAN | LITTLEENDIAN #define XE_CPU_LITTLEENDIAN 1 #endif // [big endian flags] -#if XE_CPU_32BIT -#define XE_ALIGNMENT 8 -#else -#define XE_ALIGNMENT 16 -#endif // 32BIT - #if XE_PLATFORM_WINCE || XE_PLATFORM_WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN diff --git a/src/xenia/emulator.h b/src/xenia/emulator.h index 0c05d3d0b..77ffabd40 100644 --- a/src/xenia/emulator.h +++ b/src/xenia/emulator.h @@ -14,24 +14,36 @@ #include #include -#include -#include #include - - -XEDECLARECLASS1(xe, ExportResolver); -XEDECLARECLASS2(xe, apu, AudioSystem); -XEDECLARECLASS2(xe, cpu, Processor); -XEDECLARECLASS2(xe, gpu, GraphicsSystem); -XEDECLARECLASS2(xe, hid, InputSystem); -XEDECLARECLASS2(xe, kernel, KernelState); -XEDECLARECLASS2(xe, kernel, XamModule); -XEDECLARECLASS2(xe, kernel, XboxkrnlModule); -XEDECLARECLASS3(xe, kernel, fs, FileSystem); -XEDECLARECLASS2(xe, ui, Window); - +#include +#include +#include namespace xe { +namespace apu { +class AudioSystem; +} // namespace apu +namespace cpu { +class Processor; +} // namespace cpu +namespace gpu { +class GraphicsSystem; +} // namespace gpu +namespace hid { +class InputSystem; +} // namespace hid +namespace kernel { +class XamModule; +class XboxkrnlModule; +} // namespace kernel +namespace ui { +class Window; +} // namespace ui +} // namespace xe + +namespace xe { + +class ExportResolver; class Emulator { public: diff --git a/src/xenia/gpu/xenos/ucode.h b/src/xenia/gpu/xenos/ucode.h index 2727b0328..f6130bcd3 100644 --- a/src/xenia/gpu/xenos/ucode.h +++ b/src/xenia/gpu/xenos/ucode.h @@ -18,6 +18,25 @@ namespace gpu { namespace xenos { +#if XE_COMPILER_MSVC +#define XEPACKEDSTRUCT(name, value) \ + __pragma(pack(push, 1)) struct name##_s value __pragma(pack(pop)); \ + typedef struct name##_s name; +#define XEPACKEDSTRUCTANONYMOUS(value) \ + __pragma(pack(push, 1)) struct value __pragma(pack(pop)); +#define XEPACKEDUNION(name, value) \ + __pragma(pack(push, 1)) union name##_s value __pragma(pack(pop)); \ + typedef union name##_s name; +#elif XE_COMPILER_GNUC +#define XEPACKEDSTRUCT(name, value) \ + struct __attribute__((packed)) name +#define XEPACKEDSTRUCTANONYMOUS(value) \ + struct __attribute__((packed)) +#define XEPACKEDUNION(name, value) \ + union __attribute__((packed)) name +#endif // MSVC + + // This code comes from the freedreno project: // https://github.com/freedreno/freedreno/blob/master/includes/instr-a2xx.h /* diff --git a/src/xenia/gpu/xenos/xenos.h b/src/xenia/gpu/xenos/xenos.h index c224f336b..ef5837fe2 100644 --- a/src/xenia/gpu/xenos/xenos.h +++ b/src/xenia/gpu/xenos/xenos.h @@ -11,7 +11,7 @@ #define XENIA_GPU_XENOS_XENOS_H_ #include - +#include namespace xe { namespace gpu { diff --git a/src/xenia/kernel/kernel_state.h b/src/xenia/kernel/kernel_state.h index 3587e3c46..611c5cb27 100644 --- a/src/xenia/kernel/kernel_state.h +++ b/src/xenia/kernel/kernel_state.h @@ -23,23 +23,24 @@ #include #include - -XEDECLARECLASS1(xe, Emulator); -XEDECLARECLASS2(xe, cpu, Processor); -XEDECLARECLASS2(xe, kernel, Dispatcher); -XEDECLARECLASS2(xe, kernel, XModule); -XEDECLARECLASS2(xe, kernel, XNotifyListener); -XEDECLARECLASS2(xe, kernel, XThread); -XEDECLARECLASS2(xe, kernel, XUserModule); -XEDECLARECLASS3(xe, kernel, fs, FileSystem); - +namespace xe { +class Emulator; +namespace cpu { +class Processor; +} // namespace cpu +} // namespace xe namespace xe { namespace kernel { +class Dispatcher; +class XModule; +class XNotifyListener; +class XThread; +class XUserModule; class KernelState { -public: + public: KernelState(Emulator* emulator); ~KernelState(); @@ -72,33 +73,33 @@ public: void UnregisterNotifyListener(XNotifyListener* listener); void BroadcastNotification(XNotificationID id, uint32_t data); - void CompleteOverlapped(uint32_t overlapped_ptr, X_RESULT result, uint32_t length = 0); - void CompleteOverlappedImmediate(uint32_t overlapped_ptr, X_RESULT result, uint32_t length = 0); + void CompleteOverlapped(uint32_t overlapped_ptr, X_RESULT result, + uint32_t length = 0); + void CompleteOverlappedImmediate(uint32_t overlapped_ptr, X_RESULT result, + uint32_t length = 0); -private: - Emulator* emulator_; - Memory* memory_; + private: + Emulator* emulator_; + Memory* memory_; cpu::Processor* processor_; fs::FileSystem* file_system_; - Dispatcher* dispatcher_; + Dispatcher* dispatcher_; std::unique_ptr app_manager_; std::unique_ptr user_profile_; - ObjectTable* object_table_; - std::mutex object_mutex_; + ObjectTable* object_table_; + std::mutex object_mutex_; std::unordered_map threads_by_id_; std::vector notify_listeners_; - XUserModule* executable_module_; + XUserModule* executable_module_; friend class XObject; }; - } // namespace kernel } // namespace xe - #endif // XENIA_KERNEL_KERNEL_STATE_H_ diff --git a/src/xenia/logging.h b/src/xenia/logging.h index 9b29ea778..8e2f29fd5 100644 --- a/src/xenia/logging.h +++ b/src/xenia/logging.h @@ -26,6 +26,8 @@ #define XE_OPTION_LOG_KERNEL 1 #define XE_OPTION_LOG_FS 1 +#define XE_EMPTY_MACRO do { } while(0) + #if XE_COMPILER_GNUC #define XE_LOG_LINE_ATTRIBUTE __attribute__ ((format (printf, 5, 6))) #else diff --git a/src/xenia/malloc.h b/src/xenia/malloc.h index c3f5ec754..cfe6304e5 100644 --- a/src/xenia/malloc.h +++ b/src/xenia/malloc.h @@ -21,6 +21,7 @@ void *xe_realloc(void *ptr, const size_t old_size, const size_t new_size); void *xe_recalloc(void *ptr, const size_t old_size, const size_t new_size); void xe_free(void *ptr); +typedef __declspec(align(16)) volatile void xe_aligned_void_t; xe_aligned_void_t *xe_malloc_aligned(const size_t size); void xe_free_aligned(xe_aligned_void_t *ptr); diff --git a/src/xenia/types.h b/src/xenia/types.h index 559fc9917..0fe6f7661 100644 --- a/src/xenia/types.h +++ b/src/xenia/types.h @@ -10,60 +10,12 @@ #ifndef XENIA_TYPES_H_ #define XENIA_TYPES_H_ -#include -#include - -#include - - -#define XE_EMPTY_MACRO do { } while(0) - #define XEDECLARECLASS1(ns1, name) \ namespace ns1 { class name; } #define XEDECLARECLASS2(ns1, ns2, name) \ namespace ns1 { namespace ns2 { \ class name; \ } } -#define XEDECLARECLASS3(ns1, ns2, ns3, name) \ - namespace ns1 { namespace ns2 { namespace ns3 { \ - class name; \ - } } } -#define XEDECLARECLASS4(ns1, ns2, ns3, ns4, name) \ - namespace ns1 { namespace ns2 { namespace ns3 { namespace ns4 { \ - class name; \ - } } } } - -#if XE_COMPILER_MSVC -#define XEPACKEDSTRUCT(name, value) \ - __pragma(pack(push, 1)) struct name##_s value __pragma(pack(pop)); \ - typedef struct name##_s name; -#define XEPACKEDSTRUCTANONYMOUS(value) \ - __pragma(pack(push, 1)) struct value __pragma(pack(pop)); -#define XEPACKEDUNION(name, value) \ - __pragma(pack(push, 1)) union name##_s value __pragma(pack(pop)); \ - typedef union name##_s name; -#elif XE_COMPILER_GNUC -#define XEPACKEDSTRUCT(name, value) \ - struct __attribute__((packed)) name -#define XEPACKEDSTRUCTANONYMOUS(value) \ - struct __attribute__((packed)) -#define XEPACKEDUNION(name, value) \ - union __attribute__((packed)) name -#endif // MSVC - -#if XE_COMPILER_MSVC -// http://msdn.microsoft.com/en-us/library/83ythb65.aspx -#define XECACHEALIGN __declspec(align(XE_ALIGNMENT)) -#define XECACHEALIGN64 __declspec(align(64)) -#elif XE_COMPILER_GNUC -// http://gcc.gnu.org/onlinedocs/gcc/Type-Attributes.html -#define XECACHEALIGN __attribute__ ((aligned(XE_ALIGNMENT))) -#define XECACHEALIGN64 __attribute__ ((aligned(64))) -#else -#define XECACHEALIGN -#define XECACHEALIGN64 -#endif // MSVC -typedef XECACHEALIGN volatile void xe_aligned_void_t; #define XEFAIL() goto XECLEANUP #define XEEXPECT(expr) if (!(expr) ) { goto XECLEANUP; } @@ -74,5 +26,4 @@ typedef XECACHEALIGN volatile void xe_aligned_void_t; #define XEEXPECTNULL(expr) if ( (expr) != NULL ) { goto XECLEANUP; } #define XEEXPECTNOTNULL(expr) if ( (expr) == NULL ) { goto XECLEANUP; } - #endif // XENIA_TYPES_H_