diff options
Diffstat (limited to 'source')
21 files changed, 36 insertions, 36 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index b8fbca02ad0..cdcb64fb094 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -624,7 +624,7 @@ void DM_to_mesh(DerivedMesh *dm, Mesh *me, Object *ob, const CustomData_MeshMask } /* skip the listbase */ - MEMCPY_STRUCT_OFS(me, &tmp, id.prev); + MEMCPY_STRUCT_AFTER(me, &tmp, id.prev); if (take_ownership) { if (alloctype == CD_ASSIGN) { diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 58813c9878d..e0823e98207 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -131,7 +131,7 @@ static void brush_defaults(Brush *brush) void BKE_brush_init(Brush *brush) { - BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(brush, id)); + BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(brush, id)); /* enable fake user by default */ id_fake_user_set(&brush->id); diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c index cfcf5eeed96..d01339f9ca7 100644 --- a/source/blender/blenkernel/intern/camera.c +++ b/source/blender/blenkernel/intern/camera.c @@ -54,7 +54,7 @@ void BKE_camera_init(Camera *cam) { - BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(cam, id)); + BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(cam, id)); cam->lens = 50.0f; cam->sensor_x = DEFAULT_SENSOR_WIDTH; diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 2c6392fdf90..f8205d37f53 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -138,7 +138,7 @@ void BKE_curve_free(Curve *cu) void BKE_curve_init(Curve *cu) { - /* BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(cu, id)); */ /* cu->type is already initialized... */ + /* BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(cu, id)); */ /* cu->type is already initialized... */ copy_v3_fl(cu->size, 1.0f); cu->flag = CU_FRONT | CU_BACK | CU_DEFORM_BOUNDS_OFF | CU_PATH_RADIUS; diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 177601c4746..9d0a0c872bb 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -293,7 +293,7 @@ void BKE_image_free(Image *ima) /* only image block itself */ static void image_init(Image *ima, short source, short type) { - BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(ima, id)); + BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(ima, id)); ima->ok = IMA_OK; diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index b3d1b71b1bd..f8ccddbe691 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -242,7 +242,7 @@ void BKE_lattice_resize(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb) void BKE_lattice_init(Lattice *lt) { - BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(lt, id)); + BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(lt, id)); lt->flag = LT_GRID; diff --git a/source/blender/blenkernel/intern/light.c b/source/blender/blenkernel/intern/light.c index b1ec5ba6954..ae68182c55a 100644 --- a/source/blender/blenkernel/intern/light.c +++ b/source/blender/blenkernel/intern/light.c @@ -46,7 +46,7 @@ void BKE_light_init(Light *la) { - BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(la, id)); + BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(la, id)); la->r = la->g = la->b = la->k = 1.0f; la->energy = 10.0f; diff --git a/source/blender/blenkernel/intern/lightprobe.c b/source/blender/blenkernel/intern/lightprobe.c index 1d46f1aa5d3..12568c9aa2a 100644 --- a/source/blender/blenkernel/intern/lightprobe.c +++ b/source/blender/blenkernel/intern/lightprobe.c @@ -33,7 +33,7 @@ void BKE_lightprobe_init(LightProbe *probe) { - BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(probe, id)); + BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(probe, id)); probe->grid_resolution_x = probe->grid_resolution_y = probe->grid_resolution_z = 4; probe->distinf = 2.5f; diff --git a/source/blender/blenkernel/intern/linestyle.c b/source/blender/blenkernel/intern/linestyle.c index 4ec9755bec8..47201d30b63 100644 --- a/source/blender/blenkernel/intern/linestyle.c +++ b/source/blender/blenkernel/intern/linestyle.c @@ -74,7 +74,7 @@ static const char *modifier_name[LS_MODIFIER_NUM] = { void BKE_linestyle_init(FreestyleLineStyle *linestyle) { - BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(linestyle, id)); + BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(linestyle, id)); linestyle->panel = LS_PANEL_STROKES; linestyle->r = linestyle->g = linestyle->b = 0.0f; diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index d821052f2f4..90b25e8fd49 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -127,7 +127,7 @@ void BKE_material_init_gpencil_settings(Material *ma) void BKE_material_init(Material *ma) { - BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(ma, id)); + BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(ma, id)); ma->r = ma->g = ma->b = 0.8; ma->specr = ma->specg = ma->specb = 1.0; diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index ae5cbcc4f49..d8aabcb6258 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -75,7 +75,7 @@ void BKE_mball_free(MetaBall *mb) void BKE_mball_init(MetaBall *mb) { - BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(mb, id)); + BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(mb, id)); mb->size[0] = mb->size[1] = mb->size[2] = 1.0; mb->texflag = MB_AUTOSPACE; diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 592f3a26a12..4a3eb6adcf6 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -492,7 +492,7 @@ static void mesh_tessface_clear_intern(Mesh *mesh, int free_customdata) void BKE_mesh_init(Mesh *me) { - BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(me, id)); + BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(me, id)); me->size[0] = me->size[1] = me->size[2] = 1.0; me->smoothresh = DEG2RADF(30); diff --git a/source/blender/blenkernel/intern/mesh_convert.c b/source/blender/blenkernel/intern/mesh_convert.c index 83a20758ab3..a307f53a890 100644 --- a/source/blender/blenkernel/intern/mesh_convert.c +++ b/source/blender/blenkernel/intern/mesh_convert.c @@ -1367,7 +1367,7 @@ void BKE_mesh_nomain_to_mesh( } /* skip the listbase */ - MEMCPY_STRUCT_OFS(mesh_dst, &tmp, id.prev); + MEMCPY_STRUCT_AFTER(mesh_dst, &tmp, id.prev); if (take_ownership) { if (alloctype == CD_ASSIGN) { diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index bdca469dc8e..02b6f64a7c7 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -808,7 +808,7 @@ void *BKE_object_obdata_add_from_type(Main *bmain, int type, const char *name) void BKE_object_init(Object *ob) { - /* BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(ob, id)); */ /* ob->type is already initialized... */ + /* BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(ob, id)); */ /* ob->type is already initialized... */ copy_v4_fl(ob->color, 1.0f); diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 580d99e9042..83df851f0d1 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -542,7 +542,7 @@ void BKE_scene_init(Scene *sce) SceneRenderView *srv; CurveMapping *mblur_shutter_curve; - BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(sce, id)); + BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(sce, id)); sce->cursor.rotation_mode = ROT_MODE_XYZ; diff --git a/source/blender/blenkernel/intern/speaker.c b/source/blender/blenkernel/intern/speaker.c index 25684dbbe22..70ca76d409b 100644 --- a/source/blender/blenkernel/intern/speaker.c +++ b/source/blender/blenkernel/intern/speaker.c @@ -32,7 +32,7 @@ void BKE_speaker_init(Speaker *spk) { - BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(spk, id)); + BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(spk, id)); spk->attenuation = 1.0f; spk->cone_angle_inner = 360.0f; diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index a340fadc0ea..ef77f847d83 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -205,7 +205,7 @@ void BKE_text_init(Text *ta) { TextLine *tmp; - BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(ta, id)); + BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(ta, id)); ta->name = NULL; diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index e3ce946c5cf..8cfe3d2476d 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -210,7 +210,7 @@ void BKE_texture_free(Tex *tex) void BKE_texture_default(Tex *tex) { - /* BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(tex, id)); */ /* Not here, can be called with some pointers set. :/ */ + /* BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(tex, id)); */ /* Not here, can be called with some pointers set. :/ */ tex->type = TEX_IMAGE; tex->ima = NULL; diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c index 4cc6ae190e0..2118f9adda9 100644 --- a/source/blender/blenkernel/intern/world.c +++ b/source/blender/blenkernel/intern/world.c @@ -70,7 +70,7 @@ void BKE_world_free(World *wrld) void BKE_world_init(World *wrld) { - BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(wrld, id)); + BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(wrld, id)); wrld->horr = 0.05f; wrld->horg = 0.05f; diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h index d3b285d0ddf..8e244f8b70f 100644 --- a/source/blender/blenlib/BLI_utildefines.h +++ b/source/blender/blenlib/BLI_utildefines.h @@ -428,29 +428,29 @@ extern "C" { ((void *)((char *)(v) + (ofs))) #endif -/* Like offsetof(typeof(), member), for non-gcc compilers */ -#define OFFSETOF_STRUCT(_struct, _member) \ - ((((char *)&((_struct)->_member)) - ((char *)(_struct))) + sizeof((_struct)->_member)) +/** Performs `offsetof(typeof(data), member) + sizeof((data)->member)` for non-gcc compilers. */ +#define OFFSETOF_STRUCT_AFTER(_struct, _member) \ + ((((const char *)&((_struct)->_member)) - ((const char *)(_struct))) + sizeof((_struct)->_member)) /** * memcpy helper, skipping the first part of a struct, * ensures 'struct_dst' isn't const and the offset can be computed at compile time. * This isn't inclusive, the value of \a member isn't copied. */ -#define MEMCPY_STRUCT_OFS(struct_dst, struct_src, member) { \ +#define MEMCPY_STRUCT_AFTER(struct_dst, struct_src, member) { \ CHECK_TYPE_NONCONST(struct_dst); \ ((void)(struct_dst == struct_src), \ - memcpy((char *)(struct_dst) + OFFSETOF_STRUCT(struct_dst, member), \ - (char *)(struct_src) + OFFSETOF_STRUCT(struct_dst, member), \ - sizeof(*(struct_dst)) - OFFSETOF_STRUCT(struct_dst, member))); \ -} (void)0 + memcpy((char *)(struct_dst) + OFFSETOF_STRUCT_AFTER(struct_dst, member), \ + (const char *)(struct_src) + OFFSETOF_STRUCT_AFTER(struct_dst, member), \ + sizeof(*(struct_dst)) - OFFSETOF_STRUCT_AFTER(struct_dst, member))); \ +} ((void)0) -#define MEMSET_STRUCT_OFS(struct_var, value, member) { \ +#define MEMSET_STRUCT_AFTER(struct_var, value, member) { \ CHECK_TYPE_NONCONST(struct_var); \ - memset((char *)(struct_var) + OFFSETOF_STRUCT(struct_var, member), \ + memset((char *)(struct_var) + OFFSETOF_STRUCT_AFTER(struct_var, member), \ value, \ - sizeof(*(struct_var)) - OFFSETOF_STRUCT(struct_var, member)); \ -} (void)0 + sizeof(*(struct_var)) - OFFSETOF_STRUCT_AFTER(struct_var, member)); \ +} ((void)0) /* defined * in memory_utils.c for now. I do not know where we should put it actually... */ @@ -458,10 +458,10 @@ extern "C" { extern bool BLI_memory_is_zero(const void *arr, const size_t arr_size); #endif -#define MEMCMP_STRUCT_OFS_IS_ZERO(struct_var, member) \ +#define MEMCMP_STRUCT_AFTER_IS_ZERO(struct_var, member) \ (BLI_memory_is_zero( \ - (char *)(struct_var) + OFFSETOF_STRUCT(struct_var, member), \ - sizeof(*(struct_var)) - OFFSETOF_STRUCT(struct_var, member))) + (const char *)(struct_var) + OFFSETOF_STRUCT_AFTER(struct_var, member), \ + sizeof(*(struct_var)) - OFFSETOF_STRUCT_AFTER(struct_var, member))) /* Warning-free macros for storing ints in pointers. Use these _only_ * for storing an int in a pointer, not a pointer in an int (64bit)! */ diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index d712d0671f8..0d331953f4b 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -381,10 +381,10 @@ typedef struct ProjPaintState { */ #define PROJ_PAINT_STATE_SHARED_MEMCPY(ps_dst, ps_src) \ - MEMCPY_STRUCT_OFS(ps_dst, ps_src, is_shared_user) + MEMCPY_STRUCT_AFTER(ps_dst, ps_src, is_shared_user) #define PROJ_PAINT_STATE_SHARED_CLEAR(ps) \ - MEMSET_STRUCT_OFS(ps, 0, is_shared_user) + MEMSET_STRUCT_AFTER(ps, 0, is_shared_user) bool is_shared_user; |