mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-31 13:10:34 +00:00
[gamecode] Create macros for progs sizeof and alignof
I wound up needing the idioms in too many places.
This commit is contained in:
parent
3c86660d4a
commit
e746e39738
3 changed files with 6 additions and 3 deletions
|
@ -62,6 +62,9 @@ typedef enum {
|
|||
ev_type_count // not a type, gives number of types
|
||||
} etype_t;
|
||||
|
||||
#define PR_SIZEOF(type) (sizeof (pr_##type##_t) / sizeof (pr_int_t))
|
||||
#define PR_ALIGNOF(type) (__alignof__ (pr_##type##_t) / __alignof__ (pr_int_t))
|
||||
|
||||
extern const pr_ushort_t pr_type_size[ev_type_count];
|
||||
extern const pr_ushort_t pr_type_alignment[ev_type_count];
|
||||
extern const char * const pr_type_name[ev_type_count];
|
||||
|
|
|
@ -33,13 +33,13 @@
|
|||
|
||||
#include "QF/progs.h"
|
||||
|
||||
#define EV_TYPE(type) (sizeof (pr_##type##_t) / sizeof (pr_int_t)),
|
||||
#define EV_TYPE(type) PR_SIZEOF(type),
|
||||
VISIBLE const pr_ushort_t pr_type_size[ev_type_count] = {
|
||||
#include "QF/progs/pr_type_names.h"
|
||||
0, // ev_invalid not a valid/simple type
|
||||
};
|
||||
|
||||
#define EV_TYPE(type) (__alignof__ (pr_##type##_t) / __alignof__ (pr_int_t)),
|
||||
#define EV_TYPE(type) PR_ALIGNOF(type),
|
||||
VISIBLE const pr_ushort_t pr_type_alignment[ev_type_count] = {
|
||||
#include "QF/progs/pr_type_names.h"
|
||||
0, // ev_invalid not a valid/simple type
|
||||
|
|
|
@ -64,7 +64,7 @@
|
|||
type_t type_##t = { \
|
||||
.type = ev_##t, \
|
||||
.name = #t, \
|
||||
.alignment = __alignof__(pr_##t##_t) / __alignof__ (pr_int_t), \
|
||||
.alignment = PR_ALIGNOF(t), \
|
||||
.meta = ty_basic, \
|
||||
{{ __builtin_choose_expr (ev_##t == ev_field \
|
||||
|| ev_##t == ev_func \
|
||||
|
|
Loading…
Reference in a new issue