[Mesa-dev] [PATCH v2 01/11] vulkan: util: add macros to extract extension/offset number from enums

Jason Ekstrand jason at jlekstrand.net
Tue Oct 3 18:13:28 UTC 2017


On Tue, Oct 3, 2017 at 9:43 AM, Chad Versace <chadversary at chromium.org>
wrote:

> On Tue 03 Oct 2017, Lionel Landwerlin wrote:
> > v2: Simplify offset enum computation (Jason)
> >
> > Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
> > ---
> >  src/vulkan/util/vk_util.h | 6 ++++++
> >  1 file changed, 6 insertions(+)
> >
> > diff --git a/src/vulkan/util/vk_util.h b/src/vulkan/util/vk_util.h
> > index 2ed601f881e..8c8cb64d513 100644
> > --- a/src/vulkan/util/vk_util.h
> > +++ b/src/vulkan/util/vk_util.h
> > @@ -199,4 +199,10 @@ __vk_find_struct(void *start, VkStructureType sType)
> >
> >  uint32_t vk_get_driver_version(void);
> >
> > +#define VK_EXT_OFFSET (1000000000UL)
> > +#define vk_enum_extension(__enum) \
> > +   ((__enum) >= VK_EXT_OFFSET ? ((((__enum) - VK_EXT_OFFSET) / 1000UL)
> + 1) : 0)
> > +#define vk_enum_offset(__enum) \
> > +   ((__enum) >= VK_EXT_OFFSET ? ((__enum) % 1000) : (__enum))
>
> The macro functions, when called, look like regular functions due to
> being lowercase. But they don't behave like functions; their arguments
> suffer from the multiple evaluation disease.
>
> Please rename the macros to be all uppercase, so callers' expectations
> will be set correctly. Or, even better, define them as inline
> functions.


+1 to static inline
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20171003/f3f68a89/attachment-0001.html>


More information about the mesa-dev mailing list