[Mesa-dev] [PATCH 06/21] mesa/macros: Add ARRAY_SIZE helper macro core mesa
Eric Anholt
eric at anholt.net
Mon Jun 11 13:34:27 PDT 2012
On Mon, 11 Jun 2012 09:07:19 -0600, Brian Paul <brianp at vmware.com> wrote:
> On 06/11/2012 12:59 AM, Pauli Nieminen wrote:
> > diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h
> > index d1df2ce..e05fa14 100644
> > --- a/src/mesa/main/macros.h
> > +++ b/src/mesa/main/macros.h
> > @@ -679,5 +679,8 @@ do { \
> > #define ENUM_TO_DOUBLE(E) ((GLdouble)(GLint)(E))
> > #define ENUM_TO_BOOLEAN(E) ((E) ? GL_TRUE : GL_FALSE)
> >
> > +#ifndef ARRAY_SIZE
> > +#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
> > +#endif
> >
> > #endif
>
>
> Core Mesa uses the Element() macro for this, defined in compiler.h.
> We should just use one or the other. I'd go with just using Element()
> everywhere for now to avoid churn.
On the other hand, ARRAY_SIZE is the macro from the linux kernel, which
we also use in libdrm and the 2d driver and most of piglit. It's nice
to be able to type the same thing across the driver project. It's also
very clear what it does, unlike a macro named Elements in vbo-related
code which makes me think of vertex elements.
But I'm fine with Mesa core continuing with Elements to avoid churn.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20120611/23452b26/attachment.pgp>
More information about the mesa-dev
mailing list