From 52dcb0a6e21ca21993a17d2b8df0c44494306885 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Wed, 25 Mar 2020 22:36:04 +0900 Subject: [PATCH] [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. --- include/QF/progs.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/QF/progs.h b/include/QF/progs.h index a42ae8f1f..3cd6a5c6c 100644 --- a/include/QF/progs.h +++ b/include/QF/progs.h @@ -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) +/** 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. \par QC type: