[gamecode] Add G_PACKED macro

Not sure when I'll use it, but as it avoids the null pointer check, it
should make for faster access to structs when reading or writing
multiple fields.
This commit is contained in:
Bill Currie 2020-03-25 22:36:04 +09:00
parent 48f737ecb6
commit 52dcb0a6e2

View file

@ -362,6 +362,21 @@ void PR_Undefined (progs_t *pr, const char *type, const char *name) __attribute_
*/ */
#define G_var(p,o,t) ((p)->pr_globals[o].t##_var) #define G_var(p,o,t) ((p)->pr_globals[o].t##_var)
/** Access a global as an arbitray type.
More direct than G_STRUCT
\par QC type:
\c struct etc small enough to fit in a single parameter
\param p pointer to ::progs_t VM struct
\param t C type of the structure
\param o offset into global data space
\return structure lvalue. use & to make a pointer of the
appropriate type.
\hideinitializer
*/
#define G_PACKED(p,t,o) (*(t *) &(p)->pr_globals[o])
/** Access a float global. Can be assigned to. /** Access a float global. Can be assigned to.
\par QC type: \par QC type: