<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 18, 2015 at 4:08 PM, Emil Velikov <span dir="ltr"><<a href="mailto:emil.l.velikov@gmail.com" target="_blank">emil.l.velikov@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span>On 18 November 2015 at 23:40, Nanley Chery <<a href="mailto:nanleychery@gmail.com" target="_blank">nanleychery@gmail.com</a>> wrote:<br>
> On Wed, Nov 18, 2015 at 3:07 PM, Ilia Mirkin <<a href="mailto:imirkin@alum.mit.edu" target="_blank">imirkin@alum.mit.edu</a>> wrote:<br>
>><br>
>> Why have the count as an entry in the enum? Can't you just do<br>
>> ARRAY_SIZE(_mesa_extension_table) ?<br>
>><br>
><br>
> The compiler doesn't know the size of the array by just looking at the<br>
> header. To use ARRAY_SIZE, I'd have to modify the declaration of<br>
> _mesa_extension_table to specify a size of MESA_EXTENSION_COUNT.<br>
><br>
</span>Afaict there is no declaration, only a definition of the array. That<br>
aside I'm not sure what makes you think that - we have dozens of cases<br>
in mesa which use this approach.<br>
<div><div><br></div></div></blockquote><div><br></div><div>The array is declared in extensions.h and defined in extensions.c. <br><br>I compiled the test using the ARRAY_SIZE macro and got the following error:<br>mesa_extensions.cpp:40:53: error: invalid application of ‘sizeof’ to incomplete type ‘const mesa_extension []’<br><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div>
>> On Wed, Nov 18, 2015 at 6:01 PM, Nanley Chery <<a href="mailto:nanleychery@gmail.com" target="_blank">nanleychery@gmail.com</a>><br>
>> wrote:<br>
>> > From: Nanley Chery <<a href="mailto:nanley.g.chery@intel.com" target="_blank">nanley.g.chery@intel.com</a>><br>
>> ><br>
>> > Enable developers to know if the table's alphabetical sorting<br>
>> > is maintained or lost.<br>
>> ><br>
>> > Signed-off-by: Nanley Chery <<a href="mailto:nanley.g.chery@intel.com" target="_blank">nanley.g.chery@intel.com</a>><br>
>> > ---<br>
>> >  src/mesa/main/extensions.h              |  1 +<br>
>> >  src/mesa/main/tests/Makefile.am         |  1 +<br>
>> >  src/mesa/main/tests/mesa_extensions.cpp | 47<br>
>> > +++++++++++++++++++++++++++++++++<br>
>> >  3 files changed, 49 insertions(+)<br>
>> >  create mode 100644 src/mesa/main/tests/mesa_extensions.cpp<br>
>> ><br>
>> > diff --git a/src/mesa/main/extensions.h b/src/mesa/main/extensions.h<br>
>> > index 1615e1c..7114c96 100644<br>
>> > --- a/src/mesa/main/extensions.h<br>
>> > +++ b/src/mesa/main/extensions.h<br>
>> > @@ -85,6 +85,7 @@ enum {<br>
>> >  #define EXT(name_str, ...) MESA_EXTENSION_##name_str,<br>
>> >  #include "extensions_table.h"<br>
>> >  #undef EXT<br>
>> > +   MESA_EXTENSION_COUNT<br>
>> >  };<br>
>> ><br>
>> ><br>
>> > diff --git a/src/mesa/main/tests/Makefile.am<br>
>> > b/src/mesa/main/tests/Makefile.am<br>
>> > index bd7ab73..d6977e2 100644<br>
>> > --- a/src/mesa/main/tests/Makefile.am<br>
>> > +++ b/src/mesa/main/tests/Makefile.am<br>
>> > @@ -27,6 +27,7 @@ AM_CPPFLAGS += -DHAVE_SHARED_GLAPI<br>
>> >  main_test_SOURCES +=                   \<br>
>> >         dispatch_sanity.cpp             \<br>
>> >         mesa_formats.cpp                        \<br>
>> > +       mesa_extensions.cpp                     \<br>
>> >         program_state_string.cpp<br>
>> ><br>
>> >  main_test_LDADD += \<br>
>> > diff --git a/src/mesa/main/tests/mesa_extensions.cpp<br>
>> > b/src/mesa/main/tests/mesa_extensions.cpp<br>
>> > new file mode 100644<br>
>> > index 0000000..5154ae1<br>
>> > --- /dev/null<br>
>> > +++ b/src/mesa/main/tests/mesa_extensions.cpp<br>
>> > @@ -0,0 +1,47 @@<br>
>> > +/*<br>
>> > + * Copyright © 2015 Intel Corporation<br>
>> > + *<br>
>> > + * Permission is hereby granted, free of charge, to any person<br>
>> > obtaining a<br>
>> > + * copy of this software and associated documentation files (the<br>
>> > "Software"),<br>
>> > + * to deal in the Software without restriction, including without<br>
>> > limitation<br>
>> > + * the rights to use, copy, modify, merge, publish, distribute,<br>
>> > sublicense,<br>
>> > + * and/or sell copies of the Software, and to permit persons to whom<br>
>> > the<br>
>> > + * Software is furnished to do so, subject to the following conditions:<br>
>> > + *<br>
>> > + * The above copyright notice and this permission notice (including the<br>
>> > next<br>
>> > + * paragraph) shall be included in all copies or substantial portions<br>
>> > of the<br>
>> > + * Software.<br>
>> > + *<br>
>> > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,<br>
>> > EXPRESS OR<br>
>> > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF<br>
>> > MERCHANTABILITY,<br>
>> > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT<br>
>> > SHALL<br>
>> > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
>> > OTHER<br>
>> > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
>> > ARISING<br>
>> > + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER<br>
>> > + * DEALINGS IN THE SOFTWARE.<br>
>> > + */<br>
>> > +<br>
>> > +/**<br>
>> > + * \name mesa_extensions.cpp<br>
>> > + *<br>
>> > + * Verify that the extensions table is sorted.<br>
>> > + *<br>
>> > + */<br>
>> > +<br>
>> > +#include <gtest/gtest.h><br>
>> > +#include "main/mtypes.h"<br>
>> > +#include "main/extensions.h"<br>
>> > +<br>
>> > +/**<br>
>> > + * Debug/test: verify the extension table is alphabetically sorted.<br>
>> > + */<br>
>> > +TEST(MesaExtensionsTest, AlphabeticallySorted)<br>
>> > +{<br>
>> > +   for (int i = 0; i < MESA_EXTENSION_COUNT - 1; ++i) {<br>
>> > +      const char * current_str = _mesa_extension_table[i].name;<br>
>> > +      const char * next_str = _mesa_extension_table[i+1].name;<br>
>> > +<br>
>> > +      /* We expect the extension table to be alphabetically sorted */<br>
>> > +      ASSERT_LT(strcmp(current_str, next_str), 0);<br>
</div></div>Am I day dreaming or something's wrong here. On the last iteration<br>
you'll end up comparing the final extension name against ... null ?<br>
<span><font color="#888888"><br></font></span></blockquote><div><br></div><div>The last iteration compares the 2nd-to-last extension name against the last extension name.<br><br></div><div>Regards,<br></div><div>Nanley<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span><font color="#888888">
-Emil<br>
</font></span></blockquote></div><br></div></div>