<html><head></head><body>Hi,<br><br>A macro is possible, probably:<br><br>#include<search.h><br>#define lfind(a,b,c,d,e) \<br>lfind(a,b&(unsigned){ *(c) },d,e)<br><br><br><div class="gmail_quote">Le 15 juillet 2019 10:07:26 GMT+03:00, Steve Lhomme <robux4@ycbcr.xyz> a écrit :<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">Hi<br><br>On 2019-07-12 16:35, Hugo Beauzée-Luyssen wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;">On Fri, Jul 12, 2019, at 3:51 PM, Steve Lhomme wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #ad7fa8; padding-left: 1ex;"><hr>   include/vlc_search.h | 52 ++++++++++++++++++++++++++++++++++++++++++++<br>   src/Makefile.am      |  3 ++-<br>   2 files changed, 54 insertions(+), 1 deletion(-)<br>   create mode 100644 include/vlc_search.h<br><br> diff --git a/include/vlc_search.h b/include/vlc_search.h<br> new file mode 100644<br> index 0000000000..6c87fa990d<br> --- /dev/null<br> +++ b/include/vlc_search.h<br> @@ -0,0 +1,52 @@<br> +/*****************************************************************************<br> + * vlc_search.h: portability fixups included from config.h<br> +<br> *****************************************************************************<br> + * Copyright © 2019 the VideoLAN project<br> + *<br> + * This program is free software; you can redistribute it and/or<br> modify it<br> + * under the terms of the GNU Lesser General Public License as<br> published by<br> + * the Free Software Foundation; either version 2.1 of the License, or<br> + * (at your option) any later version.<br> + *<br> + * This program is distributed in the hope that it will be useful,<br> + * but WITHOUT ANY WARRANTY; without even the implied warranty of<br> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br> + * GNU Lesser General Public License for more details.<br> + *<br> + * You should have received a copy of the GNU Lesser General Public<br> License<br> + * along with this program; if not, write to the Free Software<br> Foundation,<br> + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.<br> +<br> *****************************************************************************/<br> +<br> +/**<br> + * \file<br> + * This file is a collection of portability fixes<br> + */<br> +<br> +#ifndef LIBVLC_SEARCH_H<br> +# define LIBVLC_SEARCH_H 1<br> +<br> +#ifdef __cplusplus<br> +extern "C" {<br> +#endif<br> +<br> +#ifdef _WIN32<br> +/* the Win32 prorotype of lfind() expects an unsigned int for 'nelp' */<br></blockquote>Typo (proTotype)<br><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #ad7fa8; padding-left: 1ex;">+static inline void *vlc_lfind(const void *key, const void *base,<br>size_t *nelp,<br>+                             size_t size, int(*cmp)(const void *,<br>const void *))<br>+{<br>+    unsigned int n;<br>+    void *res = lfind (key, base, &n, size, cmp);<br>+    *nelp = n;<br>+    return res;<br></blockquote>I must say I don't understand what this wrapper does that wasn't already done by calling the function with an uint32_t* instead of a size_t*<br>If what you want is to fix the warning on the callsite, you can probably get away with a macro that casts the 3rd pointer no?<br></blockquote><br>Are "size_t" and "unsigned int" guaranteed to be the same on all Windows <br>compiler ? I think on 64 bits platforms it's not the case.<br><br>So we would need a wrapper with the proper size_t variable. To do that I <br>don't think you can do it as a pure macro because you also need to set <br>the value of the size_t nelp to the value of the unsigned int and then <br>pass that unsigned int as a pointer. (not sure the value on return needs <br>to be set back on the size_t, the lfind documentation is not clear)<br><br>So if it's not a macro, it should be an inline. But to do an inline you <br>need to include <search.h> so it knows about lfind(). This cannot be <br>added in vlc_fixups.h<br><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;">And in any case case:<br>- Does this need to be in a different file?<br></blockquote><br>IMO, yes.<br><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;">- It could be enable only when _WIN64 is defined<br></blockquote><br>OK but it doesn't hurt to have the same code between 32 and 64 bits Windows.<br><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;"><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #ad7fa8; padding-left: 1ex;">+}<br>+#else /* !_WIN32 */<br>+#define vlc_lfind(key, base, nelp, width, compar)  \<br>+            lfind(key, base, nelp, width, compar)<br>+#endif /* !_WIN32 */<br>+<br>+#ifdef __cplusplus<br>+} /* extern "C" */<br>+#endif<br>+<br>+#endif /* !LIBVLC_SEARCH_H */<br>diff --git a/src/Makefile.am b/src/Makefile.am<br>index 006ece5f93..25f9a4fc8b 100644<br>--- a/src/Makefile.am<br>+++ b/src/Makefile.am<br>@@ -88,6 +88,7 @@ pluginsinclude_HEADERS = \<br>     ../include/vlc_fingerprinter.h \<br>      ../include/vlc_interrupt.h \<br>          ../include/vlc_renderer_discovery.h \<br>+        ../include/vlc_search.h \<br>     ../include/vlc_sort.h \<br>       ../include/vlc_sout.h \<br>       ../include/vlc_spu.h \<br>@@ -591,7 +592,7 @@ test_mrl_helpers_SOURCES = test/mrl_helpers.c<br>  test_arrays_SOURCES = test/arrays.c<br>  test_vector_SOURCES = test/vector.c<br>  test_shared_data_ptr_SOURCES = test/shared_data_ptr.cpp<br>-test_extensions_SOURCES = test/extensions.c<br>+test_extensions_SOURCES = test/extensions.c<br></blockquote>Apparently my editor didn't remove the whitespace, sorry about that. Although this shouldn't be here :)<br></blockquote><br>ok<br><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;"><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #ad7fa8; padding-left: 1ex;">test_playlist_SOURCES = playlist/test.c \<br>      playlist/content.c \<br>  playlist/control.c \<br></blockquote>Regards,<br><br>-- <br>   Hugo Beauzée-Luyssen<br>   hugo@beauzee.fr<hr>vlc-devel mailing list<br>To unsubscribe or modify your subscription options:<br><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a><br><br></blockquote><hr>vlc-devel mailing list<br>To unsubscribe or modify your subscription options:<br><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a></pre></blockquote></div><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>