mirror of
https://github.com/joncampbell123/dosbox-x.git
synced 2025-10-14 02:17:36 +08:00
Use offsetof to ensure MMX union packing is as expected
This commit is contained in:
@@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
#if C_FPU
|
#if C_FPU
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
typedef union {
|
typedef union {
|
||||||
|
|
||||||
uint64_t q;
|
uint64_t q;
|
||||||
@@ -36,13 +38,17 @@ typedef union {
|
|||||||
} sd;
|
} sd;
|
||||||
static_assert(sizeof(sd) == 8, "MMX packing error");
|
static_assert(sizeof(sd) == 8, "MMX packing error");
|
||||||
|
|
||||||
struct {
|
struct uw_t {
|
||||||
uint16_t w0,w1,w2,w3;
|
uint16_t w0,w1,w2,w3;
|
||||||
} uw;
|
} uw;
|
||||||
static_assert(sizeof(uw) == 8, "MMX packing error");
|
static_assert(sizeof(uw) == 8, "MMX packing error");
|
||||||
|
|
||||||
uint16_t uwa[4]; /* for PSHUFW */
|
uint16_t uwa[4]; /* for PSHUFW */
|
||||||
static_assert(sizeof(uwa) == 8, "MMX packing error");
|
static_assert(sizeof(uwa) == 8, "MMX packing error");
|
||||||
|
static_assert(offsetof(uw_t,w0) == 0, "MMX packing error");
|
||||||
|
static_assert(offsetof(uw_t,w1) == 2, "MMX packing error");
|
||||||
|
static_assert(offsetof(uw_t,w2) == 4, "MMX packing error");
|
||||||
|
static_assert(offsetof(uw_t,w3) == 6, "MMX packing error");
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
int16_t w0,w1,w2,w3;
|
int16_t w0,w1,w2,w3;
|
||||||
|
Reference in New Issue
Block a user