[vlc-devel] [PATCH 1/2] include: add vlc_search.h for differences between POSIX search.h and other OS

Steve Lhomme robux4 at ycbcr.xyz
Fri Jul 12 15:50:55 CEST 2019


---
 include/vlc_search.h | 52 ++++++++++++++++++++++++++++++++++++++++++++
 src/Makefile.am      |  3 ++-
 2 files changed, 54 insertions(+), 1 deletion(-)
 create mode 100644 include/vlc_search.h

diff --git a/include/vlc_search.h b/include/vlc_search.h
new file mode 100644
index 0000000000..6c87fa990d
--- /dev/null
+++ b/include/vlc_search.h
@@ -0,0 +1,52 @@
+/*****************************************************************************
+ * vlc_search.h: portability fixups included from config.h
+ *****************************************************************************
+ * Copyright © 2019 the VideoLAN project
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+/**
+ * \file
+ * This file is a collection of portability fixes
+ */
+
+#ifndef LIBVLC_SEARCH_H
+# define LIBVLC_SEARCH_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef _WIN32
+/* the Win32 prorotype of lfind() expects an unsigned int for 'nelp' */
+static inline void *vlc_lfind(const void *key, const void *base, size_t *nelp,
+                             size_t size, int(*cmp)(const void *, const void *))
+{
+    unsigned int n;
+    void *res = lfind (key, base, &n, size, cmp);
+    *nelp = n;
+    return res;
+}
+#else /* !_WIN32 */
+#define vlc_lfind(key, base, nelp, width, compar)  \
+            lfind(key, base, nelp, width, compar)
+#endif /* !_WIN32 */
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* !LIBVLC_SEARCH_H */
diff --git a/src/Makefile.am b/src/Makefile.am
index 006ece5f93..25f9a4fc8b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -88,6 +88,7 @@ pluginsinclude_HEADERS = \
 	../include/vlc_fingerprinter.h \
 	../include/vlc_interrupt.h \
 	../include/vlc_renderer_discovery.h \
+	../include/vlc_search.h \
 	../include/vlc_sort.h \
 	../include/vlc_sout.h \
 	../include/vlc_spu.h \
@@ -591,7 +592,7 @@ test_mrl_helpers_SOURCES = test/mrl_helpers.c
 test_arrays_SOURCES = test/arrays.c
 test_vector_SOURCES = test/vector.c
 test_shared_data_ptr_SOURCES = test/shared_data_ptr.cpp
-test_extensions_SOURCES = test/extensions.c 
+test_extensions_SOURCES = test/extensions.c
 test_playlist_SOURCES = playlist/test.c \
 	playlist/content.c \
 	playlist/control.c \
-- 
2.17.1



More information about the vlc-devel mailing list