mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-29 05:31:26 +00:00
[qtypes] Remove field_offset macro
And use offsetof instead: it has been standard (enough) in C for a while.
This commit is contained in:
parent
9beb0093e6
commit
21cf636875
41 changed files with 105 additions and 109 deletions
|
@ -119,9 +119,9 @@ typedef struct pr_stashed_params_s {
|
|||
*/
|
||||
#define PR_SaveParams(pr) \
|
||||
_PR_SaveParams((pr), \
|
||||
alloca (field_offset (pr_stashed_params_t, \
|
||||
params[(pr)->pr_argc \
|
||||
* (pr)->pr_param_size])))
|
||||
alloca (offsetof (pr_stashed_params_t, \
|
||||
params[(pr)->pr_argc \
|
||||
* (pr)->pr_param_size])))
|
||||
|
||||
/** [INTERNAL] Save the current parameters to the provided stash.
|
||||
|
||||
|
|
|
@ -45,9 +45,6 @@
|
|||
#undef countof
|
||||
#define countof(x) (sizeof(x)/sizeof(x[0]))
|
||||
|
||||
#undef field_offset
|
||||
#define field_offset(type,field) ((size_t)&(((type *)0)->field))
|
||||
|
||||
#define MAX_QPATH 64
|
||||
|
||||
#ifndef _DEF_BYTE_
|
||||
|
|
|
@ -114,7 +114,7 @@ SND_Memory_Init (void)
|
|||
sfxbuffer_t *
|
||||
SND_Memory_AllocBuffer (unsigned samples)
|
||||
{
|
||||
size_t size = field_offset (sfxbuffer_t, data[samples]);
|
||||
size_t size = offsetof (sfxbuffer_t, data[samples]);
|
||||
// Z_Malloc (currently) clears memory, don't need that for the whole
|
||||
// buffer (just the header), but Z_TagMalloc // does not
|
||||
// +4 for sentinel
|
||||
|
|
|
@ -88,7 +88,7 @@ Mod_LoadAllSkins (mod_alias_ctx_t *alias_ctx, int numskins,
|
|||
pinskingroup = (daliasskingroup_t *) pskintype;
|
||||
groupskins = LittleLong (pinskingroup->numskins);
|
||||
|
||||
t = field_offset (maliasskingroup_t, skindescs[groupskins]);
|
||||
t = offsetof (maliasskingroup_t, skindescs[groupskins]);
|
||||
paliasskingroup = Hunk_AllocName (0, t, alias_ctx->mod->name);
|
||||
paliasskingroup->numskins = groupskins;
|
||||
|
||||
|
@ -185,8 +185,8 @@ Mod_LoadAliasGroup (mod_alias_ctx_t *alias_ctx, void *pin, int *posenum,
|
|||
frame->firstpose = (*posenum);
|
||||
frame->numposes = numframes;
|
||||
|
||||
paliasgroup = Hunk_AllocName (0, field_offset (maliasgroup_t,
|
||||
frames[numframes]),
|
||||
paliasgroup = Hunk_AllocName (0, offsetof (maliasgroup_t,
|
||||
frames[numframes]),
|
||||
mod->name);
|
||||
paliasgroup->numframes = numframes;
|
||||
frame->frame = (byte *) paliasgroup - (byte *) header;
|
||||
|
@ -263,7 +263,7 @@ Mod_LoadAliasModel (model_t *mod, void *buffer, cache_allocator_t allocator)
|
|||
|
||||
// allocate space for a working header, plus all the data except the
|
||||
// frame data, skin and group info
|
||||
size = field_offset (aliashdr_t, frames[LittleLong (pinmodel->numframes)]);
|
||||
size = offsetof (aliashdr_t, frames[LittleLong (pinmodel->numframes)]);
|
||||
header = Hunk_AllocName (0, size, mod->name);
|
||||
memset (header, 0, size);
|
||||
alias_ctx.header = header;
|
||||
|
|
|
@ -280,7 +280,7 @@ SubdividePolygon (int numverts, float *verts)
|
|||
return;
|
||||
}
|
||||
|
||||
poly = Hunk_Alloc (0, field_offset (glpoly_t, verts[numverts]));
|
||||
poly = Hunk_Alloc (0, offsetof (glpoly_t, verts[numverts]));
|
||||
poly->next = warpface->polys;
|
||||
warpface->polys = poly;
|
||||
poly->numverts = numverts;
|
||||
|
|
|
@ -123,7 +123,7 @@ find_group_frames (mspritegroup_t **group, dspritegroup_t *dgroup,
|
|||
int *frame_numbers, const char *modname)
|
||||
{
|
||||
int numframes = dgroup->numframes;
|
||||
size_t size = field_offset (mspritegroup_t, frames[numframes]);
|
||||
size_t size = offsetof (mspritegroup_t, frames[numframes]);
|
||||
*group = Hunk_AllocName (0, size, modname);
|
||||
(*group)->numframes = numframes;
|
||||
(*group)->intervals = Hunk_AllocName (0, numframes * sizeof (float),
|
||||
|
@ -193,8 +193,8 @@ Mod_LoadSpriteModel (model_t *mod, void *buffer)
|
|||
Sys_Error ("Mod_LoadSpriteModel: Invalid # of frames: %d", numframes);
|
||||
}
|
||||
|
||||
sprite = Hunk_AllocName (0, field_offset (msprite_t,
|
||||
frames[dsprite->numframes]),
|
||||
sprite = Hunk_AllocName (0, offsetof (msprite_t,
|
||||
frames[dsprite->numframes]),
|
||||
mod->name);
|
||||
sprite->type = dsprite->type;
|
||||
sprite->beamlength = dsprite->beamlength;
|
||||
|
|
|
@ -42,7 +42,7 @@ sw_Mod_SpriteLoadFrames (mod_sprite_ctx_t *ctx)
|
|||
for (int i = 0; i < ctx->numframes; i++) {
|
||||
__auto_type dframe = ctx->dframes[i];
|
||||
size_t pixels = dframe->width * dframe->height;
|
||||
size_t size = field_offset (mspriteframe_t, pixels[pixels]);
|
||||
size_t size = offsetof (mspriteframe_t, pixels[pixels]);
|
||||
mspriteframe_t *frame = Hunk_AllocName (0, size, ctx->mod->name);
|
||||
*ctx->frames[i] = frame;
|
||||
Mod_LoadSpriteFrame (frame, dframe);
|
||||
|
|
|
@ -244,7 +244,7 @@ VISIBLE hashtab_t *
|
|||
Hash_NewTable (int tsize, const char *(*gk)(const void*,void*),
|
||||
void (*f)(void*,void*), void *ud, hashctx_t **hctx)
|
||||
{
|
||||
hashtab_t *tab = calloc (1, field_offset (hashtab_t, tab[tsize]));
|
||||
hashtab_t *tab = calloc (1, offsetof (hashtab_t, tab[tsize]));
|
||||
if (!tab)
|
||||
return 0;
|
||||
tab->tab_size = tsize;
|
||||
|
|
|
@ -87,7 +87,7 @@ Draw_CrosshairPic (void)
|
|||
byte *data;
|
||||
int i, j, x, y, ind;
|
||||
|
||||
pic = malloc (field_offset (qpic_t, data[sizeof (crosshair_data)]));
|
||||
pic = malloc (offsetof (qpic_t, data[sizeof (crosshair_data)]));
|
||||
pic->width = CROSSHAIR_TILEX * CROSSHAIR_WIDTH;
|
||||
pic->height = CROSSHAIR_TILEY * CROSSHAIR_HEIGHT;
|
||||
// re-arrange the crosshair_data bytes so they're layed out properly for
|
||||
|
|
|
@ -312,7 +312,7 @@ Draw_Font8x8Pic (void)
|
|||
byte *out;
|
||||
int i, j, x, y, ind;
|
||||
|
||||
pic = calloc (1, field_offset (qpic_t, data[FONT_BYTES]));
|
||||
pic = calloc (1, offsetof (qpic_t, data[FONT_BYTES]));
|
||||
pic->width = FONT_HCHARS * FONT_WIDTH;
|
||||
pic->height = FONT_VCHARS * FONT_HEIGHT;
|
||||
// convert the bitmap data to pixel data in a 16x16 character "image"
|
||||
|
|
|
@ -172,7 +172,7 @@ gl_Draw_MakePic (int width, int height, const byte *data)
|
|||
glpic_t *gl;
|
||||
qpic_t *pic;
|
||||
|
||||
pic = malloc (field_offset (qpic_t, data[sizeof (glpic_t)]));
|
||||
pic = malloc (offsetof (qpic_t, data[sizeof (glpic_t)]));
|
||||
pic->width = width;
|
||||
pic->height = height;
|
||||
gl = (glpic_t *) pic->data;
|
||||
|
|
|
@ -806,7 +806,7 @@ GL_BuildSurfaceDisplayList (mod_brush_t *brush, msurface_t *surf)
|
|||
lnumverts = surf->numedges;
|
||||
|
||||
// draw texture
|
||||
poly = Hunk_Alloc (0, field_offset (glpoly_t, verts[lnumverts]));
|
||||
poly = Hunk_Alloc (0, offsetof (glpoly_t, verts[lnumverts]));
|
||||
poly->next = surf->polys;
|
||||
poly->flags = surf->flags;
|
||||
surf->polys = poly;
|
||||
|
|
|
@ -168,14 +168,14 @@ set_arrays (const shaderparam_t *vert, const shaderparam_t *norm,
|
|||
}
|
||||
|
||||
qfeglVertexAttribPointer (vert->location, 3, GL_UNSIGNED_SHORT,
|
||||
0, sizeof (aliasvrt_t),
|
||||
pose_offs + field_offset (aliasvrt_t, vertex));
|
||||
0, sizeof (aliasvrt_t),
|
||||
pose_offs + offsetof (aliasvrt_t, vertex));
|
||||
qfeglVertexAttribPointer (norm->location, 3, GL_SHORT,
|
||||
1, sizeof (aliasvrt_t),
|
||||
pose_offs + field_offset (aliasvrt_t, normal));
|
||||
1, sizeof (aliasvrt_t),
|
||||
pose_offs + offsetof (aliasvrt_t, normal));
|
||||
qfeglVertexAttribPointer (st->location, 2, GL_SHORT,
|
||||
0, sizeof (aliasvrt_t),
|
||||
pose_offs + field_offset (aliasvrt_t, st));
|
||||
0, sizeof (aliasvrt_t),
|
||||
pose_offs + offsetof (aliasvrt_t, st));
|
||||
}
|
||||
//#define TETRAHEDRON
|
||||
void
|
||||
|
|
|
@ -489,7 +489,7 @@ build_surf_displist (model_t **models, msurface_t *surf, int base,
|
|||
int numverts = surf->numedges;
|
||||
int numtris = numverts - 2;
|
||||
int numindices = numtris * 3;
|
||||
glslpoly_t *poly = malloc (field_offset (glslpoly_t, indices[numindices]));
|
||||
glslpoly_t *poly = malloc (offsetof (glslpoly_t, indices[numindices]));
|
||||
poly->count = numindices;
|
||||
for (int i = 0, ind = 0; i < numtris; i++) {
|
||||
// pretend we can use a triangle fan
|
||||
|
@ -870,12 +870,12 @@ draw_elechain (elechain_t *ec, int matloc, int vertloc, int tlstloc,
|
|||
continue;
|
||||
count = el->list->size / sizeof (GLushort);
|
||||
qfeglVertexAttribPointer (vertloc, 4, GL_FLOAT,
|
||||
0, sizeof (bspvert_t),
|
||||
el->base + field_offset (bspvert_t, vertex));
|
||||
0, sizeof (bspvert_t),
|
||||
el->base + offsetof (bspvert_t, vertex));
|
||||
if (tlstloc >= 0)
|
||||
qfeglVertexAttribPointer (tlstloc, 4, GL_FLOAT,
|
||||
0, sizeof (bspvert_t),
|
||||
el->base + field_offset (bspvert_t,tlst));
|
||||
0, sizeof (bspvert_t),
|
||||
el->base + offsetof (bspvert_t,tlst));
|
||||
qfeglDrawElements (GL_TRIANGLES, count,
|
||||
GL_UNSIGNED_SHORT, el->list->str);
|
||||
dstring_clear (el->list);
|
||||
|
|
|
@ -171,7 +171,7 @@ make_glpic (const char *name, qpic_t *p)
|
|||
qpic_t *pic = 0;
|
||||
|
||||
if (p) {
|
||||
pic = malloc (field_offset (qpic_t, data[sizeof (picdata_t)]));
|
||||
pic = malloc (offsetof (qpic_t, data[sizeof (picdata_t)]));
|
||||
pic->width = p->width;
|
||||
pic->height = p->height;
|
||||
__auto_type pd = (picdata_t *) pic->data;
|
||||
|
@ -227,7 +227,7 @@ pic_data (const char *name, int w, int h, const byte *data)
|
|||
qpic_t *pic;
|
||||
qpic_t *glpic;
|
||||
|
||||
pic = malloc (field_offset (qpic_t, data[w * h]));
|
||||
pic = malloc (offsetof (qpic_t, data[w * h]));
|
||||
pic->width = w;
|
||||
pic->height = h;
|
||||
memcpy (pic->data, data, pic->width * pic->height);
|
||||
|
|
|
@ -144,7 +144,7 @@ D_SCAlloc (int width, int size)
|
|||
Sys_Error ("D_SCAlloc: bad cache size %d", size);
|
||||
|
||||
// This adds the offset of data[0] in the surfcache_t struct.
|
||||
size += field_offset (surfcache_t, data);
|
||||
size += offsetof (surfcache_t, data);
|
||||
|
||||
#define SIZE_ALIGN (sizeof (surfcache_t *) - 1)
|
||||
size = (size + SIZE_ALIGN) & ~SIZE_ALIGN;
|
||||
|
|
|
@ -106,7 +106,7 @@ Draw_MakePic (int width, int height, const byte *data)
|
|||
qpic_t *pic;
|
||||
int size = width * height;
|
||||
|
||||
pic = malloc (field_offset (qpic_t, data[size]));
|
||||
pic = malloc (offsetof (qpic_t, data[size]));
|
||||
pic->width = width;
|
||||
pic->height = height;
|
||||
memcpy (pic->data, data, size);
|
||||
|
|
|
@ -36,10 +36,10 @@
|
|||
fprintf (output_file, "static parse_array_t parse_%s_%s_data = {\n",
|
||||
struct_name, field_name);
|
||||
[type writeParseData];
|
||||
fprintf (output_file, "\tfield_offset (%s, %s),\n",
|
||||
fprintf (output_file, "\toffsetof (%s, %s),\n",
|
||||
struct_name, value_field);
|
||||
if (size_field) {
|
||||
fprintf (output_file, "\tfield_offset (%s, %s),\n",
|
||||
fprintf (output_file, "\toffsetof (%s, %s),\n",
|
||||
struct_name, size_field);
|
||||
} else {
|
||||
fprintf (output_file, "\t-1,\n");
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
-writeField
|
||||
{
|
||||
Type *field_type = [Type findType: field.type];
|
||||
fprintf (output_file, "\t{\"%s\", field_offset (%s, %s), %s, %s, %s},\n",
|
||||
fprintf (output_file, "\t{\"%s\", offsetof (%s, %s), %s, %s, %s},\n",
|
||||
field_name, struct_name, field.name,
|
||||
[field_type parseType], [field_type parseFunc],
|
||||
[field_type parseData]);
|
||||
|
@ -38,7 +38,7 @@
|
|||
{
|
||||
Type *field_type = [Type findType: field.type];
|
||||
fprintf (output_file,
|
||||
"\t{\"%s\", &%s, (void *) field_offset (%s, %s)},\n",
|
||||
"\t{\"%s\", &%s, (void *) offsetof (%s, %s)},\n",
|
||||
field_name, [field_type cexprType], struct_name, field.name);
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ write_parse_data (CustomField *self, string indent)
|
|||
struct_name, field_name);
|
||||
for (int i = 0, count = [fields count]; i < count; i++) {
|
||||
string field = [[fields getObjectAtIndex:i] string];
|
||||
fprintf (output_file, "\tfield_offset (%s, %s),\n", struct_name, field);
|
||||
fprintf (output_file, "\toffsetof (%s, %s),\n", struct_name, field);
|
||||
}
|
||||
fprintf (output_file, "};\n");
|
||||
|
||||
|
@ -80,7 +80,7 @@ write_parse_data (CustomField *self, string indent)
|
|||
-writeSymbol
|
||||
{
|
||||
fprintf (output_file,
|
||||
"\t{\"%s\", 0/*FIXME*/, 0/*(void *) field_offset (%s, %s)*/},\n",
|
||||
"\t{\"%s\", 0/*FIXME*/, 0/*(void *) offsetof (%s, %s)*/},\n",
|
||||
field_name, struct_name, "FIXME");
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -23,10 +23,10 @@
|
|||
{
|
||||
fprintf (output_file, "static parse_data_t parse_%s_%s_data = {\n",
|
||||
struct_name, field_name);
|
||||
fprintf (output_file, "\tfield_offset (%s, %s),\n",
|
||||
fprintf (output_file, "\toffsetof (%s, %s),\n",
|
||||
struct_name, value_field);
|
||||
if (size_field) {
|
||||
fprintf (output_file, "\tfield_offset (%s, %s),\n",
|
||||
fprintf (output_file, "\toffsetof (%s, %s),\n",
|
||||
struct_name, size_field);
|
||||
} else {
|
||||
fprintf (output_file, "\tt-1,\n");
|
||||
|
|
|
@ -105,7 +105,7 @@
|
|||
-writeSymbol
|
||||
{
|
||||
fprintf (output_file,
|
||||
"\t{\"%s\", 0/*FIXME*/, (void *) field_offset (%s, %s)},\n",
|
||||
"\t{\"%s\", 0/*FIXME*/, (void *) offsetof (%s, %s)},\n",
|
||||
field_name, struct_name, value_field);
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
-writeSymbol
|
||||
{
|
||||
fprintf (output_file,
|
||||
"\t{\"%s\", %s, (void *) field_offset (%s, %s)},\n",
|
||||
"\t{\"%s\", %s, (void *) offsetof (%s, %s)},\n",
|
||||
field_name, [type exprType], struct_name, value_field);
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
fprintf (output_file, "static parse_single_t parse_%s_%s_data = {\n",
|
||||
struct_name, field_name);
|
||||
[type writeParseData];
|
||||
fprintf (output_file, "\tfield_offset (%s, %s),\n",
|
||||
fprintf (output_file, "\toffsetof (%s, %s),\n",
|
||||
struct_name, value_field);
|
||||
fprintf (output_file, "};\n");
|
||||
return self;
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
{
|
||||
fprintf (output_file, "static parse_string_t parse_%s_%s_data = {\n",
|
||||
struct_name, field_name);
|
||||
fprintf (output_file, "\tfield_offset (%s, %s),\n",
|
||||
fprintf (output_file, "\toffsetof (%s, %s),\n",
|
||||
struct_name, value_field);
|
||||
fprintf (output_file, "};\n");
|
||||
return self;
|
||||
|
|
|
@ -314,7 +314,7 @@ write_cexpr (Struct *self, Array *field_defs)
|
|||
}
|
||||
Type *field_type = [Type findType: field.type];
|
||||
fprintf (output_file,
|
||||
"\t{\"%s\", &%s, (void *) field_offset (%s, %s)},\n",
|
||||
"\t{\"%s\", &%s, (void *) offsetof (%s, %s)},\n",
|
||||
field.name, [field_type cexprType], [self outname],
|
||||
field.name);
|
||||
}
|
||||
|
@ -373,7 +373,7 @@ write_table (Struct *self, PLItem *field_dict, Array *field_defs,
|
|||
}
|
||||
if (have_pNext) {
|
||||
fprintf (output_file,
|
||||
"\t{\"@next\", field_offset (%s, pNext), "
|
||||
"\t{\"@next\", offsetof (%s, pNext), "
|
||||
"QFArray, parse_next, 0},\n", [self outname]);
|
||||
}
|
||||
for (int i = [field_defs count]; i-- > 0; ) {
|
||||
|
|
|
@ -964,7 +964,7 @@ parse_task_params (const plitem_t *item, void **data,
|
|||
#include "libs/video/renderer/vulkan/vkparse.cinc"
|
||||
|
||||
static exprsym_t qfv_renderframeset_t_symbols[] = {
|
||||
{"size", &cexpr_size_t, (void *)field_offset (qfv_renderframeset_t, size)},
|
||||
{"size", &cexpr_size_t, (void *) offsetof (qfv_renderframeset_t, size)},
|
||||
{ }
|
||||
};
|
||||
static exprtab_t qfv_renderframeset_t_symtab = {
|
||||
|
|
|
@ -127,19 +127,19 @@ push_alias_constants (const mat4f_t mat, float blend, byte *colors,
|
|||
|
||||
qfv_push_constants_t push_constants[] = {
|
||||
{ VK_SHADER_STAGE_VERTEX_BIT,
|
||||
field_offset (alias_push_constants_t, mat),
|
||||
offsetof (alias_push_constants_t, mat),
|
||||
sizeof (mat4f_t), mat },
|
||||
{ VK_SHADER_STAGE_VERTEX_BIT,
|
||||
field_offset (alias_push_constants_t, blend),
|
||||
offsetof (alias_push_constants_t, blend),
|
||||
sizeof (float), &constants.blend },
|
||||
{ VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||
field_offset (alias_push_constants_t, colors),
|
||||
offsetof (alias_push_constants_t, colors),
|
||||
sizeof (constants.colors), constants.colors },
|
||||
{ VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||
field_offset (alias_push_constants_t, base_color),
|
||||
offsetof (alias_push_constants_t, base_color),
|
||||
sizeof (constants.base_color), &constants.base_color },
|
||||
{ VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||
field_offset (alias_push_constants_t, fog),
|
||||
offsetof (alias_push_constants_t, fog),
|
||||
sizeof (constants.fog), &constants.fog },
|
||||
};
|
||||
QFV_PushConstants (device, cmd, layout, pass ? 5 : 2, push_constants);
|
||||
|
@ -167,28 +167,28 @@ push_fwd_constants (const mat4f_t mat, float blend, byte *colors,
|
|||
|
||||
qfv_push_constants_t push_constants[] = {
|
||||
{ VK_SHADER_STAGE_VERTEX_BIT,
|
||||
field_offset (fwd_push_constants_t, mat),
|
||||
offsetof (fwd_push_constants_t, mat),
|
||||
sizeof (mat4f_t), mat },
|
||||
{ VK_SHADER_STAGE_VERTEX_BIT,
|
||||
field_offset (fwd_push_constants_t, blend),
|
||||
offsetof (fwd_push_constants_t, blend),
|
||||
sizeof (float), &constants.blend },
|
||||
{ VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||
field_offset (fwd_push_constants_t, colors),
|
||||
offsetof (fwd_push_constants_t, colors),
|
||||
sizeof (constants.colors), constants.colors },
|
||||
{ VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||
field_offset (fwd_push_constants_t, ambient),
|
||||
offsetof (fwd_push_constants_t, ambient),
|
||||
sizeof (constants.ambient), &constants.ambient },
|
||||
{ VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||
field_offset (fwd_push_constants_t, shadelight),
|
||||
offsetof (fwd_push_constants_t, shadelight),
|
||||
sizeof (constants.shadelight), &constants.shadelight },
|
||||
{ VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||
field_offset (fwd_push_constants_t, lightvec),
|
||||
offsetof (fwd_push_constants_t, lightvec),
|
||||
sizeof (constants.lightvec), &constants.lightvec },
|
||||
{ VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||
field_offset (fwd_push_constants_t, base_color),
|
||||
offsetof (fwd_push_constants_t, base_color),
|
||||
sizeof (constants.base_color), &constants.base_color },
|
||||
{ VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||
field_offset (fwd_push_constants_t, fog),
|
||||
offsetof (fwd_push_constants_t, fog),
|
||||
sizeof (constants.fog), &constants.fog },
|
||||
};
|
||||
QFV_PushConstants (device, cmd, layout, 8, push_constants);
|
||||
|
@ -210,13 +210,13 @@ push_shadow_constants (const mat4f_t mat, float blend, uint16_t *matrix_base,
|
|||
|
||||
qfv_push_constants_t push_constants[] = {
|
||||
{ VK_SHADER_STAGE_VERTEX_BIT,
|
||||
field_offset (shadow_push_constants_t, mat),
|
||||
offsetof (shadow_push_constants_t, mat),
|
||||
sizeof (mat4f_t), mat },
|
||||
{ VK_SHADER_STAGE_VERTEX_BIT,
|
||||
field_offset (shadow_push_constants_t, blend),
|
||||
offsetof (shadow_push_constants_t, blend),
|
||||
sizeof (float), &constants.blend },
|
||||
{ VK_SHADER_STAGE_VERTEX_BIT,
|
||||
field_offset (shadow_push_constants_t, matrix_base),
|
||||
offsetof (shadow_push_constants_t, matrix_base),
|
||||
sizeof (uint32_t), &constants.matrix_base },
|
||||
};
|
||||
QFV_PushConstants (device, cmd, layout, 3, push_constants);
|
||||
|
|
|
@ -871,16 +871,16 @@ push_fragconst (QFV_BspQueue queue, VkPipelineLayout layout,
|
|||
|
||||
qfv_push_constants_t push_constants[] = {
|
||||
{ VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||
field_offset (bsp_frag_constants_t, fog),
|
||||
offsetof (bsp_frag_constants_t, fog),
|
||||
sizeof (constants.fog), &constants.fog },
|
||||
{ VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||
field_offset (bsp_frag_constants_t, time),
|
||||
offsetof (bsp_frag_constants_t, time),
|
||||
sizeof (constants.time), &constants.time },
|
||||
{ VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||
field_offset (bsp_frag_constants_t, alpha),
|
||||
offsetof (bsp_frag_constants_t, alpha),
|
||||
sizeof (constants.alpha), &constants.alpha },
|
||||
{ VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||
field_offset (bsp_frag_constants_t, turb_scale),
|
||||
offsetof (bsp_frag_constants_t, turb_scale),
|
||||
sizeof (constants.turb_scale), &constants.turb_scale },
|
||||
};
|
||||
QFV_PushConstants (device, cmd, layout, 4, push_constants);
|
||||
|
|
|
@ -643,7 +643,7 @@ pic_data (const char *name, int w, int h, const byte *data, vulkan_ctx_t *ctx)
|
|||
byte *picdata;
|
||||
|
||||
pic = cmemalloc (dctx->pic_memsuper,
|
||||
field_offset (qpic_t, data[sizeof (picdata_t)]));
|
||||
offsetof (qpic_t, data[sizeof (picdata_t)]));
|
||||
pic->width = w;
|
||||
pic->height = h;
|
||||
__auto_type pd = (picdata_t *) pic->data;
|
||||
|
@ -791,7 +791,7 @@ load_lmp (const char *path, vulkan_ctx_t *ctx)
|
|||
|
||||
qpic_t *pic;
|
||||
pic = cmemalloc (dctx->pic_memsuper,
|
||||
field_offset (qpic_t, data[sizeof (picdata_t)]));
|
||||
offsetof (qpic_t, data[sizeof (picdata_t)]));
|
||||
pic->width = p->width;
|
||||
pic->height = p->height;
|
||||
__auto_type pd = (picdata_t *) pic->data;
|
||||
|
|
|
@ -218,19 +218,19 @@ push_iqm_constants (const mat4f_t mat, float blend, byte *colors,
|
|||
|
||||
qfv_push_constants_t push_constants[] = {
|
||||
{ VK_SHADER_STAGE_VERTEX_BIT,
|
||||
field_offset (iqm_push_constants_t, mat),
|
||||
offsetof (iqm_push_constants_t, mat),
|
||||
sizeof (mat4f_t), mat },
|
||||
{ VK_SHADER_STAGE_VERTEX_BIT,
|
||||
field_offset (iqm_push_constants_t, blend),
|
||||
offsetof (iqm_push_constants_t, blend),
|
||||
sizeof (float), &constants.blend },
|
||||
{ VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||
field_offset (iqm_push_constants_t, colors),
|
||||
offsetof (iqm_push_constants_t, colors),
|
||||
sizeof (constants.colors), constants.colors },
|
||||
{ VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||
field_offset (iqm_push_constants_t, base_color),
|
||||
offsetof (iqm_push_constants_t, base_color),
|
||||
sizeof (constants.base_color), &constants.base_color },
|
||||
{ VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||
field_offset (iqm_push_constants_t, fog),
|
||||
offsetof (iqm_push_constants_t, fog),
|
||||
sizeof (constants.fog), &constants.fog },
|
||||
};
|
||||
QFV_PushConstants (device, cmd, layout, pass ? 5 : 2, push_constants);
|
||||
|
@ -258,28 +258,28 @@ push_fwd_constants (const mat4f_t mat, float blend, byte *colors,
|
|||
|
||||
qfv_push_constants_t push_constants[] = {
|
||||
{ VK_SHADER_STAGE_VERTEX_BIT,
|
||||
field_offset (fwd_push_constants_t, mat),
|
||||
offsetof (fwd_push_constants_t, mat),
|
||||
sizeof (mat4f_t), mat },
|
||||
{ VK_SHADER_STAGE_VERTEX_BIT,
|
||||
field_offset (fwd_push_constants_t, blend),
|
||||
offsetof (fwd_push_constants_t, blend),
|
||||
sizeof (float), &constants.blend },
|
||||
{ VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||
field_offset (fwd_push_constants_t, colors),
|
||||
offsetof (fwd_push_constants_t, colors),
|
||||
sizeof (constants.colors), constants.colors },
|
||||
{ VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||
field_offset (fwd_push_constants_t, ambient),
|
||||
offsetof (fwd_push_constants_t, ambient),
|
||||
sizeof (constants.ambient), &constants.ambient },
|
||||
{ VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||
field_offset (fwd_push_constants_t, shadelight),
|
||||
offsetof (fwd_push_constants_t, shadelight),
|
||||
sizeof (constants.shadelight), &constants.shadelight },
|
||||
{ VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||
field_offset (fwd_push_constants_t, lightvec),
|
||||
offsetof (fwd_push_constants_t, lightvec),
|
||||
sizeof (constants.lightvec), &constants.lightvec },
|
||||
{ VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||
field_offset (fwd_push_constants_t, base_color),
|
||||
offsetof (fwd_push_constants_t, base_color),
|
||||
sizeof (constants.base_color), &constants.base_color },
|
||||
{ VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||
field_offset (fwd_push_constants_t, fog),
|
||||
offsetof (fwd_push_constants_t, fog),
|
||||
sizeof (constants.fog), &constants.fog },
|
||||
};
|
||||
QFV_PushConstants (device, cmd, layout, 8, push_constants);
|
||||
|
@ -301,13 +301,13 @@ push_shadow_constants (const mat4f_t mat, float blend, uint16_t *matrix_base,
|
|||
|
||||
qfv_push_constants_t push_constants[] = {
|
||||
{ VK_SHADER_STAGE_VERTEX_BIT,
|
||||
field_offset (shadow_push_constants_t, mat),
|
||||
offsetof (shadow_push_constants_t, mat),
|
||||
sizeof (mat4f_t), mat },
|
||||
{ VK_SHADER_STAGE_VERTEX_BIT,
|
||||
field_offset (shadow_push_constants_t, blend),
|
||||
offsetof (shadow_push_constants_t, blend),
|
||||
sizeof (float), &constants.blend },
|
||||
{ VK_SHADER_STAGE_VERTEX_BIT,
|
||||
field_offset (shadow_push_constants_t, matrix_base),
|
||||
offsetof (shadow_push_constants_t, matrix_base),
|
||||
sizeof (uint32_t), &constants.matrix_base },
|
||||
};
|
||||
QFV_PushConstants (device, cmd, layout, 3, push_constants);
|
||||
|
|
|
@ -1401,13 +1401,13 @@ lighting_draw_lights (const exprval_t **params, exprval_t *result,
|
|||
};
|
||||
qfv_push_constants_t push_constants[] = {
|
||||
{ VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||
field_offset (light_push_constants_t, fog),
|
||||
offsetof (light_push_constants_t, fog),
|
||||
sizeof (fog), &fog },
|
||||
{ VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||
field_offset (light_push_constants_t, CascadeDepths),
|
||||
offsetof (light_push_constants_t, CascadeDepths),
|
||||
sizeof (depths), &depths },
|
||||
{ VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||
field_offset (light_push_constants_t, queue),
|
||||
offsetof (light_push_constants_t, queue),
|
||||
sizeof (queue), &queue },
|
||||
};
|
||||
QFV_PushConstants (device, cmd, layout, 3, push_constants);
|
||||
|
|
|
@ -361,10 +361,10 @@ particle_physics (const exprval_t **params, exprval_t *result, exprctx_t *ectx)
|
|||
};
|
||||
qfv_push_constants_t push_constants[] = {
|
||||
{ VK_SHADER_STAGE_COMPUTE_BIT,
|
||||
field_offset (particle_push_constants_t, gravity),
|
||||
offsetof (particle_push_constants_t, gravity),
|
||||
sizeof (vec4f_t), &constants.gravity },
|
||||
{ VK_SHADER_STAGE_COMPUTE_BIT,
|
||||
field_offset (particle_push_constants_t, dT),
|
||||
offsetof (particle_push_constants_t, dT),
|
||||
sizeof (float), &constants.dT },
|
||||
};
|
||||
QFV_PushConstants (device, cmd, layout, 2, push_constants);
|
||||
|
|
|
@ -644,13 +644,13 @@ SV_Punish (int mode)
|
|||
cmd = "cuff";
|
||||
cmd_do = "cuffed";
|
||||
//FIXME cmd_undo = "un-cuffed";
|
||||
field_offs = field_offset (client_t, cuff_time);
|
||||
field_offs = offsetof (client_t, cuff_time);
|
||||
break;
|
||||
case 1:
|
||||
cmd = "mute";
|
||||
cmd_do = "muted";
|
||||
//FIXME cmd_undo = "can speak";
|
||||
field_offs = field_offset (client_t, lockedtill);
|
||||
field_offs = offsetof (client_t, lockedtill);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ num_textures (const void *data)
|
|||
return va (0, " %7d", LittleLong (d->nummiptex));
|
||||
}
|
||||
|
||||
#define O(f) field_offset (bsp_t, f)
|
||||
#define O(f) offsetof (bsp_t, f)
|
||||
static lumpinfo_t lump_info[] = {
|
||||
{ "entities", O(entdata), O(entdatasize) },
|
||||
{ "planes", O(planes), O(numplanes) },
|
||||
|
|
|
@ -329,8 +329,7 @@ FixFaceEdges (face_t *f)
|
|||
if (v->t < t2 - T_EPSILON) {
|
||||
tjuncs++;
|
||||
// insert a new vertex here
|
||||
fp = realloc (fp, field_offset (winding_t,
|
||||
points[fp->numpoints + 1]));
|
||||
fp = realloc (fp, offsetof (winding_t, points[fp->numpoints + 1]));
|
||||
for (k = fp->numpoints; k > j; k--) {
|
||||
VectorCopy (fp->points[k - 1], fp->points[k]);
|
||||
}
|
||||
|
|
|
@ -252,7 +252,7 @@ typedef struct ex_value_s {
|
|||
#include "tools/qfcc/include/vec_types.h"
|
||||
};
|
||||
} ex_value_t;
|
||||
#define value_size (sizeof(ex_value_t) - field_offset(ex_value_t, raw_value))
|
||||
#define value_size (sizeof(ex_value_t) - offsetof(ex_value_t, raw_value))
|
||||
|
||||
typedef struct {
|
||||
const type_t *type; ///< type to view the expression
|
||||
|
|
|
@ -127,7 +127,7 @@ merge (ex_boollist_t *l1, ex_boollist_t *l2)
|
|||
return l1;
|
||||
if (!l1)
|
||||
return l2;
|
||||
m = malloc (field_offset (ex_boollist_t, e[l1->size + l2->size]));
|
||||
m = malloc (offsetof (ex_boollist_t, e[l1->size + l2->size]));
|
||||
m->size = l1->size + l2->size;
|
||||
memcpy (m->e, l1->e, l1->size * sizeof (expr_t *));
|
||||
memcpy (m->e + l1->size, l2->e, l2->size * sizeof (expr_t *));
|
||||
|
@ -139,7 +139,7 @@ make_list (const expr_t *e)
|
|||
{
|
||||
ex_boollist_t *m;
|
||||
|
||||
m = malloc (field_offset (ex_boollist_t, e[1]));
|
||||
m = malloc (offsetof (ex_boollist_t, e[1]));
|
||||
m->size = 1;
|
||||
m->e[0] = (expr_t *) e;
|
||||
return m;
|
||||
|
|
|
@ -81,7 +81,7 @@ qfo_new_encoding (const type_t *type, int size, defspace_t *space)
|
|||
qfot_type_t *enc;
|
||||
def_t *def;
|
||||
|
||||
size += field_offset (qfot_type_t, type);
|
||||
size += offsetof (qfot_type_t, type);
|
||||
size /= sizeof (pr_type_t);
|
||||
|
||||
def = new_def (type->encoding, 0, space, sc_static);
|
||||
|
@ -113,7 +113,7 @@ qfo_encode_func (const type_t *type, defspace_t *space)
|
|||
return_type_def = qfo_encode_type (type->func.ret_type, space);
|
||||
for (i = 0; i < param_count; i++)
|
||||
param_type_defs[i] = qfo_encode_type (type->func.param_types[i], space);
|
||||
size = field_offset (qfot_func_t, param_types[param_count]);
|
||||
size = offsetof (qfot_func_t, param_types[param_count]);
|
||||
|
||||
def = qfo_new_encoding (type, size, space);
|
||||
enc = D_POINTER (qfot_type_t, def);
|
||||
|
@ -187,7 +187,7 @@ qfo_encode_struct (const type_t *type, defspace_t *space)
|
|||
num_fields++;
|
||||
}
|
||||
|
||||
size = field_offset (qfot_struct_t, fields[num_fields]);
|
||||
size = offsetof (qfot_struct_t, fields[num_fields]);
|
||||
def = qfo_new_encoding (type, size, space);
|
||||
enc = D_POINTER (qfot_type_t, def);
|
||||
strct = &enc->strct;
|
||||
|
|
|
@ -72,7 +72,7 @@ typedef struct {
|
|||
ex_pointer_t pointer;
|
||||
};
|
||||
} immediate_t;
|
||||
#define imm_size (sizeof(immediate_t) - field_offset(immediate_t, raw_imm))
|
||||
#define imm_size (sizeof(immediate_t) - offsetof(immediate_t, raw_imm))
|
||||
|
||||
static hashtab_t *value_table;
|
||||
ALLOC_STATE (ex_value_t, values);
|
||||
|
@ -303,7 +303,7 @@ new_type_value (const type_t *type, const pr_type_t *data)
|
|||
{
|
||||
size_t typeSize = type_size (type) * sizeof (pr_type_t);
|
||||
ex_value_t val = {};
|
||||
if (typeSize > sizeof (val) - field_offset (ex_value_t, raw_value)) {
|
||||
if (typeSize > sizeof (val) - offsetof (ex_value_t, raw_value)) {
|
||||
internal_error (0, "value too large");
|
||||
}
|
||||
set_val_type (&val, type);
|
||||
|
|
|
@ -164,7 +164,7 @@ NewWinding (threaddata_t *thread, int points)
|
|||
winding_t *winding;
|
||||
unsigned size;
|
||||
|
||||
size = field_offset (winding_t, points[points]);
|
||||
size = offsetof (winding_t, points[points]);
|
||||
winding = Hunk_RawAlloc (thread->hunk, size);
|
||||
memset (winding, 0, size);
|
||||
winding->id = thread->winding_id++;
|
||||
|
@ -179,7 +179,7 @@ CopyWinding (threaddata_t *thread, const winding_t *w)
|
|||
unsigned size;
|
||||
winding_t *copy;
|
||||
|
||||
size = field_offset (winding_t, points[w->numpoints]);
|
||||
size = offsetof (winding_t, points[w->numpoints]);
|
||||
copy = Hunk_RawAlloc (thread->hunk, size);
|
||||
memcpy (copy, w, size);
|
||||
copy->original = false;
|
||||
|
|
Loading…
Reference in a new issue