forked from len0rd/rockbox
quake: pack structs which could potentially be unaligned
The d*_t structs are from "d"isk, which means they could be unaligned. Packing them saves me from having to rewrite every single access to them. Change-Id: I6d5a9525fff368bf29bdb85cf1672fce02ce3396
This commit is contained in:
parent
f83de422fa
commit
2ca47176f9
1 changed files with 15 additions and 14 deletions
|
@ -79,6 +79,7 @@ typedef struct
|
||||||
|
|
||||||
#define HEADER_LUMPS 15
|
#define HEADER_LUMPS 15
|
||||||
|
|
||||||
|
// packed to avoid unaligned accesses on ARM
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
float mins[3], maxs[3];
|
float mins[3], maxs[3];
|
||||||
|
@ -86,19 +87,19 @@ typedef struct
|
||||||
int headnode[MAX_MAP_HULLS];
|
int headnode[MAX_MAP_HULLS];
|
||||||
int visleafs; // not including the solid leaf 0
|
int visleafs; // not including the solid leaf 0
|
||||||
int firstface, numfaces;
|
int firstface, numfaces;
|
||||||
} dmodel_t;
|
} __attribute__((packed)) dmodel_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int version;
|
int version;
|
||||||
lump_t lumps[HEADER_LUMPS];
|
lump_t lumps[HEADER_LUMPS];
|
||||||
} dheader_t;
|
} __attribute__((packed)) dheader_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int nummiptex;
|
int nummiptex;
|
||||||
int dataofs[4]; // [nummiptex]
|
int dataofs[4]; // [nummiptex]
|
||||||
} dmiptexlump_t;
|
} __attribute__((packed)) dmiptexlump_t;
|
||||||
|
|
||||||
#define MIPLEVELS 4
|
#define MIPLEVELS 4
|
||||||
typedef struct miptex_s
|
typedef struct miptex_s
|
||||||
|
@ -106,13 +107,13 @@ typedef struct miptex_s
|
||||||
char name[16];
|
char name[16];
|
||||||
unsigned width, height;
|
unsigned width, height;
|
||||||
unsigned offsets[MIPLEVELS]; // four mip maps stored
|
unsigned offsets[MIPLEVELS]; // four mip maps stored
|
||||||
} miptex_t;
|
} __attribute__((packed)) miptex_t;
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
float point[3];
|
float point[3];
|
||||||
} dvertex_t;
|
} __attribute__((packed)) dvertex_t;
|
||||||
|
|
||||||
|
|
||||||
// 0-2 are axial planes
|
// 0-2 are axial planes
|
||||||
|
@ -130,7 +131,7 @@ typedef struct
|
||||||
float normal[3];
|
float normal[3];
|
||||||
float dist;
|
float dist;
|
||||||
int type; // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate
|
int type; // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate
|
||||||
} dplane_t;
|
} __attribute__((packed)) dplane_t;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -160,13 +161,13 @@ typedef struct
|
||||||
short maxs[3];
|
short maxs[3];
|
||||||
unsigned short firstface;
|
unsigned short firstface;
|
||||||
unsigned short numfaces; // counting both sides
|
unsigned short numfaces; // counting both sides
|
||||||
} dnode_t;
|
} __attribute__((packed)) dnode_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int planenum;
|
int planenum;
|
||||||
short children[2]; // negative numbers are contents
|
short children[2]; // negative numbers are contents
|
||||||
} dclipnode_t;
|
} __attribute__((packed)) dclipnode_t;
|
||||||
|
|
||||||
|
|
||||||
typedef struct texinfo_s
|
typedef struct texinfo_s
|
||||||
|
@ -174,7 +175,7 @@ typedef struct texinfo_s
|
||||||
float vecs[2][4]; // [s/t][xyz offset]
|
float vecs[2][4]; // [s/t][xyz offset]
|
||||||
int miptex;
|
int miptex;
|
||||||
int flags;
|
int flags;
|
||||||
} texinfo_t;
|
} __attribute__((packed)) texinfo_t;
|
||||||
#define TEX_SPECIAL 1 // sky or slime, no lightmap or 256 subdivision
|
#define TEX_SPECIAL 1 // sky or slime, no lightmap or 256 subdivision
|
||||||
|
|
||||||
// note that edge 0 is never used, because negative edge nums are used for
|
// note that edge 0 is never used, because negative edge nums are used for
|
||||||
|
@ -182,7 +183,7 @@ typedef struct texinfo_s
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
unsigned short v[2]; // vertex numbers
|
unsigned short v[2]; // vertex numbers
|
||||||
} dedge_t;
|
} __attribute__((packed)) dedge_t;
|
||||||
|
|
||||||
#define MAXLIGHTMAPS 4
|
#define MAXLIGHTMAPS 4
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -197,7 +198,7 @@ typedef struct
|
||||||
// lighting info
|
// lighting info
|
||||||
byte styles[MAXLIGHTMAPS];
|
byte styles[MAXLIGHTMAPS];
|
||||||
int lightofs; // start of [numstyles*surfsize] samples
|
int lightofs; // start of [numstyles*surfsize] samples
|
||||||
} dface_t;
|
} __attribute__((packed)) dface_t;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -222,7 +223,7 @@ typedef struct
|
||||||
unsigned short nummarksurfaces;
|
unsigned short nummarksurfaces;
|
||||||
|
|
||||||
byte ambient_level[NUM_AMBIENTS];
|
byte ambient_level[NUM_AMBIENTS];
|
||||||
} dleaf_t;
|
} __attribute__((packed)) dleaf_t;
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
@ -296,7 +297,7 @@ typedef struct epair_s
|
||||||
struct epair_s *next;
|
struct epair_s *next;
|
||||||
char *key;
|
char *key;
|
||||||
char *value;
|
char *value;
|
||||||
} epair_t;
|
} __attribute__((packed)) epair_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
@ -304,7 +305,7 @@ typedef struct
|
||||||
int firstbrush;
|
int firstbrush;
|
||||||
int numbrushes;
|
int numbrushes;
|
||||||
epair_t *epairs;
|
epair_t *epairs;
|
||||||
} entity_t;
|
} __attribute__((packed)) entity_t;
|
||||||
|
|
||||||
extern int num_entities;
|
extern int num_entities;
|
||||||
extern entity_t entities[MAX_MAP_ENTITIES];
|
extern entity_t entities[MAX_MAP_ENTITIES];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue