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

Steve Lhomme robux4 at ycbcr.xyz
Fri Jul 12 15:53:18 CEST 2019


Like swab on Windows that doesn't have the proper prototype.
---
 include/vlc_unistd.h | 48 ++++++++++++++++++++++++++++++++++++++++++++
 src/Makefile.am      |  1 +
 2 files changed, 49 insertions(+)
 create mode 100644 include/vlc_unistd.h

diff --git a/include/vlc_unistd.h b/include/vlc_unistd.h
new file mode 100644
index 0000000000..89a11685b9
--- /dev/null
+++ b/include/vlc_unistd.h
@@ -0,0 +1,48 @@
+/*****************************************************************************
+ * vlc_unistd.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_UNISTD_H
+# define LIBVLC_UNISTD_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef _WIN32
+/* the Win32 prorotype of swab() expects a non-const src */
+static inline void vlc_swab(const void * src, void * dest, ssize_t nbytes)
+{
+    char *csrc = (char*)src;
+    swab (csrc, dest, nbytes);
+}
+#else /* !_WIN32 */
+#define vlc_swab(src, dst, nbytes)   swab(src, dst, nbytes)
+#endif /* !_WIN32 */
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* !LIBVLC_SEARCH_H */
diff --git a/src/Makefile.am b/src/Makefile.am
index 8c56c0e165..006ece5f93 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -101,6 +101,7 @@ pluginsinclude_HEADERS = \
 	../include/vlc_timestamp_helper.h \
 	../include/vlc_thumbnailer.h \
 	../include/vlc_tls.h \
+	../include/vlc_unistd.h \
 	../include/vlc_url.h \
 	../include/vlc_variables.h \
 	../include/vlc_vector.h \
-- 
2.17.1



More information about the vlc-devel mailing list