More shared header cleanup.

This commit is contained in:
Ben Vanik
2014-08-16 19:07:21 -07:00
parent 4675161902
commit 6cb9ca432f
11 changed files with 77 additions and 97 deletions

View File

@@ -10,60 +10,12 @@
#ifndef XENIA_TYPES_H_
#define XENIA_TYPES_H_
#include <cstdint>
#include <functional>
#include <poly/platform.h>
#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_