[Mesa-dev] [PATCH 1/4] gallium/u_inlines: normalize naming, use dst & src, style fixes (v2)
From: Marek Olšák v2: update comments Reviewed-by: Michel Dänzer Tested-by: Dieter Nützel --- src/gallium/auxiliary/util/u_inlines.h | 94 +- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/src/gallium/auxiliary/util/u_inlines.h b/src/gallium/auxiliary/util/u_inlines.h index dee6f8f2d9e..6e149a31926 100644 --- a/src/gallium/auxiliary/util/u_inlines.h +++ b/src/gallium/auxiliary/util/u_inlines.h @@ -45,139 +45,139 @@ extern "C" { #endif /* * Reference counting helper functions. */ static inline void -pipe_reference_init(struct pipe_reference *reference, unsigned count) +pipe_reference_init(struct pipe_reference *dst, unsigned count) { - p_atomic_set(>count, count); + p_atomic_set(>count, count); } static inline boolean -pipe_is_referenced(struct pipe_reference *reference) +pipe_is_referenced(struct pipe_reference *src) { - return p_atomic_read(>count) != 0; + return p_atomic_read(>count) != 0; } /** * Update reference counting. * The old thing pointed to, if any, will be unreferenced. - * Both 'ptr' and 'reference' may be NULL. + * Both 'dst' and 'src' may be NULL. * \return TRUE if the object's refcount hits zero and should be destroyed. */ static inline boolean -pipe_reference_described(struct pipe_reference *ptr, - struct pipe_reference *reference, +pipe_reference_described(struct pipe_reference *dst, + struct pipe_reference *src, debug_reference_descriptor get_desc) { boolean destroy = FALSE; - if(ptr != reference) { - /* bump the reference.count first */ - if (reference) { - assert(pipe_is_referenced(reference)); - p_atomic_inc(>count); - debug_reference(reference, get_desc, 1); + if (dst != src) { + /* bump the src.count first */ + if (src) { + assert(pipe_is_referenced(src)); + p_atomic_inc(>count); + debug_reference(src, get_desc, 1); } - if (ptr) { - assert(pipe_is_referenced(ptr)); - if (p_atomic_dec_zero(>count)) { + if (dst) { + assert(pipe_is_referenced(dst)); + if (p_atomic_dec_zero(>count)) destroy = TRUE; - } - debug_reference(ptr, get_desc, -1); + + debug_reference(dst, get_desc, -1); } } return destroy; } static inline boolean -pipe_reference(struct pipe_reference *ptr, struct pipe_reference *reference) +pipe_reference(struct pipe_reference *dst, struct pipe_reference *src) { - return pipe_reference_described(ptr, reference, + return pipe_reference_described(dst, src, (debug_reference_descriptor) debug_describe_reference); } static inline void -pipe_surface_reference(struct pipe_surface **ptr, struct pipe_surface *surf) +pipe_surface_reference(struct pipe_surface **dst, struct pipe_surface *src) { - struct pipe_surface *old_surf = *ptr; + struct pipe_surface *old_dst = *dst; - if (pipe_reference_described(&(*ptr)->reference, >reference, + if (pipe_reference_described(&(*dst)->reference, >reference, (debug_reference_descriptor) debug_describe_surface)) - old_surf->context->surface_destroy(old_surf->context, old_surf); - *ptr = surf; + old_dst->context->surface_destroy(old_dst->context, old_dst); + *dst = src; } /** * Similar to pipe_surface_reference() but always set the pointer to NULL * and pass in an explicit context. The explicit context avoids the problem * of using a deleted context's surface_destroy() method when freeing a surface * that's shared by multiple contexts. */ static inline void pipe_surface_release(struct pipe_context *pipe, struct pipe_surface **ptr) { if (pipe_reference_described(&(*ptr)->reference, NULL, (debug_reference_descriptor) debug_describe_surface)) pipe->surface_destroy(pipe, *ptr); *ptr = NULL; } static inline void -pipe_resource_reference(struct pipe_resource **ptr, struct pipe_resource *tex) +pipe_resource_reference(struct pipe_resource **dst, struct pipe_resource *src) { - struct pipe_resource *old_tex = *ptr; + struct pipe_resource *old_dst = *dst; - if (pipe_reference_described(&(*ptr)->reference, >reference, + if (pipe_reference_described(&(*dst)->reference, >reference, (debug_reference_descriptor) debug_describe_resource)) { /* Avoid recursion, which would prevent inlining this function */ do { - struct pipe_resource *next = old_tex->next; + struct pipe_resource *next = old_dst->next; - old_tex->screen->resource_destroy(old_tex->screen, old_tex); - old_tex = next; - } while
Re: [Mesa-dev] [PATCH 1/4] gallium/u_inlines: normalize naming, use dst & src, style fixes
Hi Marek, there are two comments that will be confusing if they are not updated as well: On Sat, 2018-09-01 at 02:54 -0400, Marek Olšák wrote: > From: Marek Olšák > > --- > src/gallium/auxiliary/util/u_inlines.h | 86 +- > 1 file changed, 43 insertions(+), 43 deletions(-) > > diff --git a/src/gallium/auxiliary/util/u_inlines.h > b/src/gallium/auxiliary/util/u_inlines.h > index dee6f8f2d9e..7eb243779f7 100644 > --- a/src/gallium/auxiliary/util/u_inlines.h > +++ b/src/gallium/auxiliary/util/u_inlines.h > @@ -45,139 +45,139 @@ [...] > /** > * Update reference counting. > * The old thing pointed to, if any, will be unreferenced. > * Both 'ptr' and 'reference' may be NULL. * Both 'dst' and 'src' may be NULL. > * \return TRUE if the object's refcount hits zero and should be destroyed. > */ > static inline boolean > -pipe_reference_described(struct pipe_reference *ptr, > - struct pipe_reference *reference, > +pipe_reference_described(struct pipe_reference *dst, > + struct pipe_reference *src, > debug_reference_descriptor get_desc) [...] > /** > * Set *ptr to \p view with proper reference counting. * Set *dst to \p src with proper reference counting. > * > * The caller must guarantee that \p view and *ptr must have been created in * The caller must guarantee that \p src and *dst must have been created in > * the same context (if they exist), and that this must be the current > context. > */ > static inline void > -pipe_sampler_view_reference(struct pipe_sampler_view **ptr, > -struct pipe_sampler_view *view) > +pipe_sampler_view_reference(struct pipe_sampler_view **dst, > +struct pipe_sampler_view *src) regards Philipp ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/4] gallium/u_inlines: normalize naming, use dst & src, style fixes
For the series Tested-by: Dieter Nützel Dieter Am 01.09.2018 08:54, schrieb Marek Olšák: From: Marek Olšák --- src/gallium/auxiliary/util/u_inlines.h | 86 +- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/src/gallium/auxiliary/util/u_inlines.h b/src/gallium/auxiliary/util/u_inlines.h index dee6f8f2d9e..7eb243779f7 100644 --- a/src/gallium/auxiliary/util/u_inlines.h +++ b/src/gallium/auxiliary/util/u_inlines.h @@ -45,139 +45,139 @@ extern "C" { #endif /* * Reference counting helper functions. */ static inline void -pipe_reference_init(struct pipe_reference *reference, unsigned count) +pipe_reference_init(struct pipe_reference *dst, unsigned count) { - p_atomic_set(>count, count); + p_atomic_set(>count, count); } static inline boolean -pipe_is_referenced(struct pipe_reference *reference) +pipe_is_referenced(struct pipe_reference *src) { - return p_atomic_read(>count) != 0; + return p_atomic_read(>count) != 0; } /** * Update reference counting. * The old thing pointed to, if any, will be unreferenced. * Both 'ptr' and 'reference' may be NULL. * \return TRUE if the object's refcount hits zero and should be destroyed. */ static inline boolean -pipe_reference_described(struct pipe_reference *ptr, - struct pipe_reference *reference, +pipe_reference_described(struct pipe_reference *dst, + struct pipe_reference *src, debug_reference_descriptor get_desc) { boolean destroy = FALSE; - if(ptr != reference) { + if (dst != src) { /* bump the reference.count first */ - if (reference) { - assert(pipe_is_referenced(reference)); - p_atomic_inc(>count); - debug_reference(reference, get_desc, 1); + if (src) { + assert(pipe_is_referenced(src)); + p_atomic_inc(>count); + debug_reference(src, get_desc, 1); } - if (ptr) { - assert(pipe_is_referenced(ptr)); - if (p_atomic_dec_zero(>count)) { + if (dst) { + assert(pipe_is_referenced(dst)); + if (p_atomic_dec_zero(>count)) destroy = TRUE; - } - debug_reference(ptr, get_desc, -1); + + debug_reference(dst, get_desc, -1); } } return destroy; } static inline boolean -pipe_reference(struct pipe_reference *ptr, struct pipe_reference *reference) +pipe_reference(struct pipe_reference *dst, struct pipe_reference *src) { - return pipe_reference_described(ptr, reference, + return pipe_reference_described(dst, src, (debug_reference_descriptor) debug_describe_reference); } static inline void -pipe_surface_reference(struct pipe_surface **ptr, struct pipe_surface *surf) +pipe_surface_reference(struct pipe_surface **dst, struct pipe_surface *src) { - struct pipe_surface *old_surf = *ptr; + struct pipe_surface *old_dst = *dst; - if (pipe_reference_described(&(*ptr)->reference, >reference, + if (pipe_reference_described(&(*dst)->reference, >reference, (debug_reference_descriptor) debug_describe_surface)) - old_surf->context->surface_destroy(old_surf->context, old_surf); - *ptr = surf; + old_dst->context->surface_destroy(old_dst->context, old_dst); + *dst = src; } /** * Similar to pipe_surface_reference() but always set the pointer to NULL * and pass in an explicit context. The explicit context avoids the problem * of using a deleted context's surface_destroy() method when freeing a surface * that's shared by multiple contexts. */ static inline void pipe_surface_release(struct pipe_context *pipe, struct pipe_surface **ptr) { if (pipe_reference_described(&(*ptr)->reference, NULL, (debug_reference_descriptor) debug_describe_surface)) pipe->surface_destroy(pipe, *ptr); *ptr = NULL; } static inline void -pipe_resource_reference(struct pipe_resource **ptr, struct pipe_resource *tex) +pipe_resource_reference(struct pipe_resource **dst, struct pipe_resource *src) { - struct pipe_resource *old_tex = *ptr; + struct pipe_resource *old_dst = *dst; - if (pipe_reference_described(&(*ptr)->reference, >reference, + if (pipe_reference_described(&(*dst)->reference, >reference, (debug_reference_descriptor) debug_describe_resource)) { /* Avoid recursion, which would prevent inlining this function */ do { - struct pipe_resource *next = old_tex->next; + struct pipe_resource *next = old_dst->next; - old_tex->screen->resource_destroy(old_tex->screen, old_tex); - old_tex = next; - } while (pipe_reference_described(_tex->reference, NULL, +
Re: [Mesa-dev] [PATCH 1/4] gallium/u_inlines: normalize naming, use dst & src, style fixes
On 2018-09-01 8:54 a.m., Marek Olšák wrote: > From: Marek Olšák Nice cleanup. This patch and patch 4 are Reviewed-by: Michel Dänzer -- Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/4] gallium/u_inlines: normalize naming, use dst & src, style fixes
From: Marek Olšák --- src/gallium/auxiliary/util/u_inlines.h | 86 +- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/src/gallium/auxiliary/util/u_inlines.h b/src/gallium/auxiliary/util/u_inlines.h index dee6f8f2d9e..7eb243779f7 100644 --- a/src/gallium/auxiliary/util/u_inlines.h +++ b/src/gallium/auxiliary/util/u_inlines.h @@ -45,139 +45,139 @@ extern "C" { #endif /* * Reference counting helper functions. */ static inline void -pipe_reference_init(struct pipe_reference *reference, unsigned count) +pipe_reference_init(struct pipe_reference *dst, unsigned count) { - p_atomic_set(>count, count); + p_atomic_set(>count, count); } static inline boolean -pipe_is_referenced(struct pipe_reference *reference) +pipe_is_referenced(struct pipe_reference *src) { - return p_atomic_read(>count) != 0; + return p_atomic_read(>count) != 0; } /** * Update reference counting. * The old thing pointed to, if any, will be unreferenced. * Both 'ptr' and 'reference' may be NULL. * \return TRUE if the object's refcount hits zero and should be destroyed. */ static inline boolean -pipe_reference_described(struct pipe_reference *ptr, - struct pipe_reference *reference, +pipe_reference_described(struct pipe_reference *dst, + struct pipe_reference *src, debug_reference_descriptor get_desc) { boolean destroy = FALSE; - if(ptr != reference) { + if (dst != src) { /* bump the reference.count first */ - if (reference) { - assert(pipe_is_referenced(reference)); - p_atomic_inc(>count); - debug_reference(reference, get_desc, 1); + if (src) { + assert(pipe_is_referenced(src)); + p_atomic_inc(>count); + debug_reference(src, get_desc, 1); } - if (ptr) { - assert(pipe_is_referenced(ptr)); - if (p_atomic_dec_zero(>count)) { + if (dst) { + assert(pipe_is_referenced(dst)); + if (p_atomic_dec_zero(>count)) destroy = TRUE; - } - debug_reference(ptr, get_desc, -1); + + debug_reference(dst, get_desc, -1); } } return destroy; } static inline boolean -pipe_reference(struct pipe_reference *ptr, struct pipe_reference *reference) +pipe_reference(struct pipe_reference *dst, struct pipe_reference *src) { - return pipe_reference_described(ptr, reference, + return pipe_reference_described(dst, src, (debug_reference_descriptor) debug_describe_reference); } static inline void -pipe_surface_reference(struct pipe_surface **ptr, struct pipe_surface *surf) +pipe_surface_reference(struct pipe_surface **dst, struct pipe_surface *src) { - struct pipe_surface *old_surf = *ptr; + struct pipe_surface *old_dst = *dst; - if (pipe_reference_described(&(*ptr)->reference, >reference, + if (pipe_reference_described(&(*dst)->reference, >reference, (debug_reference_descriptor) debug_describe_surface)) - old_surf->context->surface_destroy(old_surf->context, old_surf); - *ptr = surf; + old_dst->context->surface_destroy(old_dst->context, old_dst); + *dst = src; } /** * Similar to pipe_surface_reference() but always set the pointer to NULL * and pass in an explicit context. The explicit context avoids the problem * of using a deleted context's surface_destroy() method when freeing a surface * that's shared by multiple contexts. */ static inline void pipe_surface_release(struct pipe_context *pipe, struct pipe_surface **ptr) { if (pipe_reference_described(&(*ptr)->reference, NULL, (debug_reference_descriptor) debug_describe_surface)) pipe->surface_destroy(pipe, *ptr); *ptr = NULL; } static inline void -pipe_resource_reference(struct pipe_resource **ptr, struct pipe_resource *tex) +pipe_resource_reference(struct pipe_resource **dst, struct pipe_resource *src) { - struct pipe_resource *old_tex = *ptr; + struct pipe_resource *old_dst = *dst; - if (pipe_reference_described(&(*ptr)->reference, >reference, + if (pipe_reference_described(&(*dst)->reference, >reference, (debug_reference_descriptor) debug_describe_resource)) { /* Avoid recursion, which would prevent inlining this function */ do { - struct pipe_resource *next = old_tex->next; + struct pipe_resource *next = old_dst->next; - old_tex->screen->resource_destroy(old_tex->screen, old_tex); - old_tex = next; - } while (pipe_reference_described(_tex->reference, NULL, + old_dst->screen->resource_destroy(old_dst->screen, old_dst); + old_dst = next; + } while