summaryrefslogtreecommitdiffstats
path: root/apps/plugins/sdl
diff options
context:
space:
mode:
authorFranklin Wei <git@fwei.tk>2019-07-20 19:52:30 -0400
committerFranklin Wei <git@fwei.tk>2019-07-21 15:13:35 -0400
commit2ca47176f9fffade0569a0c18f75536cd020a19c (patch)
treeb556d122d1270b761fb64f791d35fedad4854a4f /apps/plugins/sdl
parentf83de422fa7f4d107ce69a1be66cf35afb60314f (diff)
downloadrockbox-2ca47176f9fffade0569a0c18f75536cd020a19c.tar.gz
rockbox-2ca47176f9fffade0569a0c18f75536cd020a19c.tar.bz2
rockbox-2ca47176f9fffade0569a0c18f75536cd020a19c.zip
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
Diffstat (limited to 'apps/plugins/sdl')
-rw-r--r--apps/plugins/sdl/progs/quake/bspfile.h29
1 files changed, 15 insertions, 14 deletions
diff --git a/apps/plugins/sdl/progs/quake/bspfile.h b/apps/plugins/sdl/progs/quake/bspfile.h
index 308902632b..ac15ed7330 100644
--- a/apps/plugins/sdl/progs/quake/bspfile.h
+++ b/apps/plugins/sdl/progs/quake/bspfile.h
@@ -79,6 +79,7 @@ typedef struct
#define HEADER_LUMPS 15
+// packed to avoid unaligned accesses on ARM
typedef struct
{
float mins[3], maxs[3];
@@ -86,19 +87,19 @@ typedef struct
int headnode[MAX_MAP_HULLS];
int visleafs; // not including the solid leaf 0
int firstface, numfaces;
-} dmodel_t;
+} __attribute__((packed)) dmodel_t;
typedef struct
{
int version;
lump_t lumps[HEADER_LUMPS];
-} dheader_t;
+} __attribute__((packed)) dheader_t;
typedef struct
{
int nummiptex;
int dataofs[4]; // [nummiptex]
-} dmiptexlump_t;
+} __attribute__((packed)) dmiptexlump_t;
#define MIPLEVELS 4
typedef struct miptex_s
@@ -106,13 +107,13 @@ typedef struct miptex_s
char name[16];
unsigned width, height;
unsigned offsets[MIPLEVELS]; // four mip maps stored
-} miptex_t;
+} __attribute__((packed)) miptex_t;
typedef struct
{
float point[3];
-} dvertex_t;
+} __attribute__((packed)) dvertex_t;
// 0-2 are axial planes
@@ -130,7 +131,7 @@ typedef struct
float normal[3];
float dist;
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];
unsigned short firstface;
unsigned short numfaces; // counting both sides
-} dnode_t;
+} __attribute__((packed)) dnode_t;
typedef struct
{
int planenum;
short children[2]; // negative numbers are contents
-} dclipnode_t;
+} __attribute__((packed)) dclipnode_t;
typedef struct texinfo_s
@@ -174,7 +175,7 @@ typedef struct texinfo_s
float vecs[2][4]; // [s/t][xyz offset]
int miptex;
int flags;
-} texinfo_t;
+} __attribute__((packed)) texinfo_t;
#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
@@ -182,7 +183,7 @@ typedef struct texinfo_s
typedef struct
{
unsigned short v[2]; // vertex numbers
-} dedge_t;
+} __attribute__((packed)) dedge_t;
#define MAXLIGHTMAPS 4
typedef struct
@@ -197,7 +198,7 @@ typedef struct
// lighting info
byte styles[MAXLIGHTMAPS];
int lightofs; // start of [numstyles*surfsize] samples
-} dface_t;
+} __attribute__((packed)) dface_t;
@@ -222,7 +223,7 @@ typedef struct
unsigned short nummarksurfaces;
byte ambient_level[NUM_AMBIENTS];
-} dleaf_t;
+} __attribute__((packed)) dleaf_t;
//============================================================================
@@ -296,7 +297,7 @@ typedef struct epair_s
struct epair_s *next;
char *key;
char *value;
-} epair_t;
+} __attribute__((packed)) epair_t;
typedef struct
{
@@ -304,7 +305,7 @@ typedef struct
int firstbrush;
int numbrushes;
epair_t *epairs;
-} entity_t;
+} __attribute__((packed)) entity_t;
extern int num_entities;
extern entity_t entities[MAX_MAP_ENTITIES];