[vlc-commits] [Git][videolan/vlc][master] 3 commits: vlc_fixups: do warn about "deprecated" ANSI calls on Windows GDK
Steve Lhomme (@robUx4)
gitlab at videolan.org
Tue Feb 28 10:36:27 UTC 2023
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
6946b06a by Steve Lhomme at 2023-02-28T10:10:27+00:00
vlc_fixups: do warn about "deprecated" ANSI calls on Windows GDK
These functions are not available when linking, so we should avoid using them.
Also mingw-w64 understands _CRT_NONSTDC_NO_DEPRECATE but not
_CRT_NONSTDC_NO_WARNINGS.
- - - - -
cedea4d0 by Steve Lhomme at 2023-02-28T10:10:27+00:00
configure: don't the check presence of stricmp
_stricmp a Windows thing that is present in all the CRT, even in UCRT.
The stricmp() deprecated variant doesn't seem to exist elsewhere.
In some configuration it's not possible to link with stricmp() even though
_stricmp() is available.
- - - - -
105babe3 by Steve Lhomme at 2023-02-28T10:10:27+00:00
windows: use the native read/write/etc calls
When compiling with the GDK the POSIX variants are defined but not available
for linking. We can just the Windows variants that are always available.
Do the proper redirection in our custom unistd.h used with the Platform SDK.
- - - - -
10 changed files:
- compat/readv.c
- compat/strcasecmp.c
- compat/windows/unistd.h
- compat/writev.c
- config.h.meson
- configure.ac
- include/vlc_fixups.h
- meson.build
- modules/audio_output/waveout.c
- src/win32/filesystem.c
Changes:
=====================================
compat/readv.c
=====================================
@@ -26,11 +26,7 @@
#include <stdlib.h>
#include <string.h>
-#ifdef _WIN32
-# include <io.h>
-#else
-# include <unistd.h>
-#endif
+#include <unistd.h>
ssize_t readv(int fd, const struct iovec *iov, int iovcnt)
{
=====================================
compat/strcasecmp.c
=====================================
@@ -28,8 +28,8 @@
int strcasecmp (const char *s1, const char *s2)
{
-#ifdef HAVE_STRICMP
- return stricmp (s1, s2);
+#ifdef _WIN32
+ return _stricmp (s1, s2);
#else
for (size_t i = 0;; i++)
{
=====================================
compat/windows/unistd.h
=====================================
@@ -9,8 +9,12 @@
// Windows is not a real POSIX system and doesn't provide this header
// provide a dummy one so the code can compile
+#if defined(_GAMING_XBOX_SCARLETT) || defined(_GAMING_XBOX_XBOXONE) || defined(_XBOX_ONE)
+# define _CRT_DECLARE_NONSTDC_NAMES 0
+#else
// many functions commonly found in unistd.h are found in io.h and process.h
-#define _CRT_DECLARE_NONSTDC_NAMES 1
+# define _CRT_DECLARE_NONSTDC_NAMES 1
+#endif
#include <io.h>
#include <process.h>
@@ -25,5 +29,16 @@
// _getpid() exists but it returns an int, not a pid_t
typedef int pid_t;
+// redirect missing functions from the GDK
+#define strdup(s) _strdup(s)
+
+#define read(fd, dst, count) _read(fd, dst, count)
+#define write(fd, src, count) _write(fd, src, count)
+#define close(fd) _close(fd)
+#define dup(fd) _dup(fd)
+#define dup2(fd, f2) _dup2(fd,f2)
+#define setmode(fd, m) _setmode(fd,m)
+#define fdopen(a, b) _fdopen(a, b)
+
#endif // WINSDK_UNISTD_H__
=====================================
compat/writev.c
=====================================
@@ -26,11 +26,7 @@
#include <stdlib.h>
#include <string.h>
-#ifdef _WIN32
-# include <io.h>
-#else
-# include <unistd.h>
-#endif
+#include <unistd.h>
ssize_t writev(int fd, const struct iovec *iov, int iovcnt)
{
=====================================
config.h.meson
=====================================
@@ -464,9 +464,6 @@
/* Define to 1 if you have the `strdup' function. */
#mesondefine HAVE_STRDUP
-/* Define to 1 if you have the `stricmp' function. */
-#mesondefine HAVE_STRICMP
-
/* Define to 1 if you have the `strlcpy' function. */
#mesondefine HAVE_STRLCPY
=====================================
configure.ac
=====================================
@@ -750,7 +750,7 @@ dnl Check for system libs needed
need_libc=false
dnl Check for usual libc functions
-AC_CHECK_FUNCS([accept4 dup3 fcntl flock fstatat fstatvfs fork getmntent_r getenv getpwuid_r isatty memalign mkostemp mmap open_memstream newlocale pipe2 posix_fadvise setlocale stricmp uselocale wordexp])
+AC_CHECK_FUNCS([accept4 dup3 fcntl flock fstatat fstatvfs fork getmntent_r getenv getpwuid_r isatty memalign mkostemp mmap open_memstream newlocale pipe2 posix_fadvise setlocale uselocale wordexp])
AC_REPLACE_FUNCS([aligned_alloc asprintf atof atoll dirfd fdopendir flockfile fsync getdelim getpid gmtime_r lfind lldiv localtime_r memrchr nrand48 poll posix_memalign readv recvmsg rewind sendmsg setenv strcasecmp strcasestr strdup strlcpy strndup strnlen strnstr strsep strtof strtok_r strtoll swab tdestroy tfind timegm timespec_get strverscmp vasprintf writev])
AC_REPLACE_FUNCS([gettimeofday])
AC_CHECK_FUNC(fdatasync,,
=====================================
include/vlc_fixups.h
=====================================
@@ -28,8 +28,11 @@
#if defined(_MSC_VER)
// disable common warnings when compiling POSIX code
-#ifndef _CRT_NONSTDC_NO_WARNINGS
-#define _CRT_NONSTDC_NO_WARNINGS 1
+#ifndef _CRT_NONSTDC_NO_DEPRECATE
+// the POSIX variants are not available in the GDK
+# if !(defined(_GAMING_XBOX_SCARLETT) || defined(_GAMING_XBOX_XBOXONE) || defined(_XBOX_ONE))
+# define _CRT_NONSTDC_NO_DEPRECATE
+# endif
#endif
#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS 1
=====================================
meson.build
=====================================
@@ -558,7 +558,6 @@ check_functions = [
['open_memstream', '#include <stdio.h>'],
['pipe2', '#include <unistd.h>'],
['posix_fadvise', '#include <fcntl.h>'],
- ['stricmp', '#include <string.h>'],
['strcoll', '#include <string.h>'],
['wordexp', '#include <wordexp.h>'],
=====================================
modules/audio_output/waveout.c
=====================================
@@ -753,7 +753,7 @@ static uint32_t findDeviceID(char *psz_device_name)
_snwprintf( dev_name, MAXPNAMELEN + 32, device_name_fmt,
caps.szPname, caps.wMid, caps.wPid );
char *u8 = FromWide(dev_name);
- if( !stricmp(u8, psz_device_name) )
+ if( !_stricmp(u8, psz_device_name) )
{
free( u8 );
return i;
=====================================
src/win32/filesystem.c
=====================================
@@ -37,17 +37,13 @@
#include <fcntl.h>
#include <winsock2.h>
#include <direct.h>
+#include <unistd.h>
#include <vlc_common.h>
#include <vlc_charset.h>
#include <vlc_fs.h>
#include "libvlc.h" /* vlc_mkdir */
-#ifdef _MSC_VER
-# define __STDC__ 1
-# include <io.h> /* _pipe */
-#endif
-
#ifndef NTDDI_WIN10_RS3
#define NTDDI_WIN10_RS3 0x0A000004
#endif
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/f8cd81e4f59ca91c6ca959390e29154141a25b56...105babe317e94d75b9c3da96322211bdcc776a5d
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/f8cd81e4f59ca91c6ca959390e29154141a25b56...105babe317e94d75b9c3da96322211bdcc776a5d
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list