<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 18, 2015 at 3:07 PM, Ilia Mirkin <span dir="ltr"><<a href="mailto:imirkin@alum.mit.edu" target="_blank">imirkin@alum.mit.edu</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">Why have the count as an entry in the enum? Can't you just do<br>
ARRAY_SIZE(_mesa_extension_table) ?<br>
<div><div class="h5"><br></div></div></blockquote><div> </div><div>The compiler doesn't know the size of the array by just looking at the header. To use ARRAY_SIZE, I'd have to modify the declaration of _mesa_extension_table to specify a size of MESA_EXTENSION_COUNT.<br></div><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div class="h5">
On Wed, Nov 18, 2015 at 6:01 PM, Nanley Chery <<a href="mailto:nanleychery@gmail.com">nanleychery@gmail.com</a>> wrote:<br>
> From: Nanley Chery <<a href="mailto:nanley.g.chery@intel.com">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">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>
> 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 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 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 obtaining a<br>
> + * copy of this software and associated documentation files (the "Software"),<br>
> + * to deal in the Software without restriction, including without limitation<br>
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
> + * and/or sell copies of the Software, and to permit persons to whom 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 next<br>
> + * paragraph) shall be included in all copies or substantial portions of the<br>
> + * Software.<br>
> + *<br>
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br>
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 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>
> + }<br>
> +}<br>
> --<br>
> 2.6.2<br>
><br>
</div></div>> _______________________________________________<br>
> mesa-dev mailing list<br>
> <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> <a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</blockquote></div><br></div></div>