[libdvdnav-devel] [Git][videolan/libdvdread][master] 8 commits: msvc: remove shims for features guaranteed by C11
Jean-Baptiste Kempf (@jbk)
gitlab at videolan.org
Wed Jul 29 06:45:22 UTC 2026
Jean-Baptiste Kempf pushed to branch master at VideoLAN / libdvdread
Commits:
28a66bfd by Kacper Michajłow at 2026-07-29T08:44:41+02:00
msvc: remove shims for features guaranteed by C11
Building requires c_std=c11 since the Meson switch, which on MSVC
means VS 2019 16.8 or newer. There the inline keyword is supported
in C mode and the UCRT ships C99-conforming snprintf/vsnprintf.
In fact this fixes compilation on newer MSVC:
stdio.h(1422): warning C4005: 'vsnprintf': macro redefinition
msvc\include\unistd.h(68): note: see previous definition of 'vsnprintf'
- - - - -
fdf358d2 by Kacper Michajłow at 2026-07-29T08:44:41+02:00
ifo_read: add missing ifoFree_UD_PGCIT prototype
The function is exported with DVDREAD_API and called by consumers
freeing DVD-VR handles, but was never declared in the public header,
leaving the export unusable and triggering -Wmissing-prototypes.
Fixes: 81971a3
- - - - -
5b226266 by Kacper Michajłow at 2026-07-29T08:44:41+02:00
ifo_read: use C11 static_assert unconditionally
Since the switch to Meson the build requires c_std=c11, which
guarantees _Static_assert and the static_assert convenience macro
in <assert.h>. Drop the configure-time probe and the fallback
definitions and use static_assert directly.
The fallback was dead code anyway: Meson's set10() always defines
HAVE_STATIC_ASSERT (to 0 or 1), so the #ifndef guard could never
fire and a compiler without _Static_assert would have failed to
build regardless.
- - - - -
952beed2 by Kacper Michajłow at 2026-07-29T08:44:41+02:00
meson: drop the limits.h header check
<limits.h> is a standard C header and dvd_reader.c already includes
it unconditionally. The HAVE_LIMITS_H define is not used anywhere.
- - - - -
85285823 by Kacper Michajłow at 2026-07-29T08:44:41+02:00
msvc: remove unused os_types.h
Nothing in the tree includes it, anymore. Leftover from early days.
- - - - -
86873192 by Kacper Michajłow at 2026-07-29T08:44:41+02:00
meson: set the common Windows defines project-wide
Define WIN32_LEAN_AND_MEAN and NOMINMAX to slim down windows.h, and
_CRT_DECLARE_NONSTDC_NAMES so the UCRT declares the POSIX-style
open/read/close names that file_win32.c and dvd_reader.c use.
- - - - -
1a3501de by Kacper Michajłow at 2026-07-29T08:44:41+02:00
msvc: reduce the unistd.h shim to what libdvdread uses
Most things are no longer needed and only leftovers from back in the
day.
- - - - -
e3ac7232 by Kacper Michajłow at 2026-07-29T08:44:41+02:00
dvd_udf: remove NULL definition
- - - - -
7 changed files:
- meson.build
- − msvc/include/os_types.h
- msvc/include/unistd.h
- src/dvd_udf.c
- src/dvdread/ifo_read.h
- src/ifo_read.c
- src/meson.build
Changes:
=====================================
meson.build
=====================================
@@ -45,11 +45,16 @@ if host_machine.system() == 'sunos'
test_args += '-D__EXTENSIONS__'
endif
+if host_machine.system() == 'windows'
+ test_args += ['-DWIN32_LEAN_AND_MEAN', '-DNOMINMAX',
+ '-D_CRT_DECLARE_NONSTDC_NAMES', '-D_CRT_NONSTDC_NO_WARNINGS',
+ '-D_CRT_SECURE_NO_WARNINGS']
+endif
+
# Header checks
check_headers = [
'sys/param.h',
- 'limits.h',
'dirent.h',
]
@@ -82,8 +87,6 @@ elif cc.has_function('strerror_s', prefix: '#include <string.h>', args: test_arg
cdata.set('HAVE_STRERROR_S', 1)
endif
-cdata.set10('HAVE_STATIC_ASSERT', cc.compiles('_Static_assert(1, "The impossible happened.");', name : '_Static_assert'))
-
# External dependencies and libraries
# libdvdcss is loaded dynamically if it is not found or requested
=====================================
msvc/include/os_types.h deleted
=====================================
@@ -1,24 +0,0 @@
-#ifndef __OS_TYPES_H__
-#define __OS_TYPES_H__
-/*
- * win32 types
- * 04 Sept 2001 - Chris Wolf create.
- */
-
-typedef unsigned char uint_8;
-typedef unsigned short uint_16;
-typedef unsigned int uint_32;
-typedef signed char sint_32;
-typedef signed short sint_16;
-typedef signed int sint_8;
-
-#define snprintf _snprintf
-#define M_PI 3.14159265358979323846 /* pi */
-#define DLLENTRY __declspec(dllexport)
-
- // Temporarily hardcode this location
-#define AO_PLUGIN_PATH "c:\\Program Files\\Common Files\\Xiphophorus\\ao"
-
-#define SHARED_LIB_EXT ".dll"
-
-#endif /* __OS_TYPES_H__ */
=====================================
msvc/include/unistd.h
=====================================
@@ -20,37 +20,15 @@
* WIN32 PORT,
* by Matthew Grooms <elon at altavista.com>
*
- * unistd.h - This is mostly a catch all header that maps standard unix
- * libc calls to the equivalent win32 functions.
- *
+ * unistd.h - Maps the unix libc calls used by libdvdread to the
+ * equivalent win32 CRT functions.
*/
-#include <windows.h>
-#include <malloc.h>
-#include <errno.h>
-#include <direct.h>
-
-#include <config.h>
-
#ifndef _SYS_UNISTD_H_
#define _SYS_UNISTD_H_
-#define inline __inline
-
-#define mkdir( A, B ) _mkdir( A )
-#define lstat stat
-
-#ifndef S_ISDIR
-#define S_ISDIR(A) ( S_IFDIR & A )
-#endif
-
-#define S_IXUSR S_IEXEC
-#define S_IXGRP S_IEXEC
-#define S_IXOTH S_IEXEC
-
-#define M_PI 3.14159265358979323846 /* pi */
-
-#define bzero( A, B ) memset( A, 0, B )
+#include <io.h>
+#include <string.h>
#ifndef strcasecmp
#define strcasecmp _stricmp
@@ -60,10 +38,4 @@
#define strncasecmp _strnicmp
#endif
-#define snprintf _snprintf
-#define vsnprintf _vsnprintf
-
-// FIXME : I don't remember why this is here
-#define readlink
-
#endif
=====================================
src/dvd_udf.c
=====================================
@@ -70,11 +70,6 @@ static int DVDReadLBUDF( dvd_reader_t *ctx, uint32_t lb_number,
return block_count;
}
-
-#ifndef NULL
-#define NULL ((void *)0)
-#endif
-
struct Partition {
int valid;
uint16_t Flags;
=====================================
src/dvdread/ifo_read.h
=====================================
@@ -299,6 +299,7 @@ DVDREAD_API void ifoFree_TITLE_VOBU_ADMAP(ifo_handle_t *);
DVDREAD_API void ifoFree_TXTDT_MGI(ifo_handle_t *);
DVDREAD_API void ifoFree_TT(ifo_handle_t *);
DVDREAD_API void ifoFree_PGC_GI(ifo_handle_t *);
+DVDREAD_API void ifoFree_UD_PGCIT(ifo_handle_t *);
#ifdef __cplusplus
};
=====================================
src/ifo_read.c
=====================================
@@ -22,6 +22,7 @@
#include "config.h"
+#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
@@ -34,15 +35,6 @@
#include "dvdread_internal.h"
#include "dvdread/bitreader.h"
-#ifndef HAVE_STATIC_ASSERT
-#if defined(_MSC_VER)
-#include <crtdbg.h>
-#define _Static_assert(x, y) _STATIC_ASSERT(x)
-#else
-#define _Static_assert(x, y) // packed size checks not supported by this compiler
-#endif
-#endif
-
#define POINTER_SIZE sizeof(void*)
@@ -148,12 +140,12 @@ static inline int DVDFileSeek_( dvd_file_t *dvd_file, uint32_t offset ) {
#define STRINGIFY_NAME_( z ) #z
#define CHECK_STRUCT_SIZE(strt, ptrs, size) \
- _Static_assert(sizeof(strt) <= size + ptrs * POINTER_SIZE, STRINGIFY_NAME(strt) " bigger than " STRINGIFY_NAME(size)); \
- _Static_assert(sizeof(strt) >= size + ptrs * POINTER_SIZE, STRINGIFY_NAME(strt) " smaller than " STRINGIFY_NAME(size))
+ static_assert(sizeof(strt) <= size + ptrs * POINTER_SIZE, STRINGIFY_NAME(strt) " bigger than " STRINGIFY_NAME(size)); \
+ static_assert(sizeof(strt) >= size + ptrs * POINTER_SIZE, STRINGIFY_NAME(strt) " smaller than " STRINGIFY_NAME(size))
#define CHECK_STRUCT_SIZE_REF(strt, ptrs, size) \
- _Static_assert(sizeof(strt) <= size + ptrs * POINTER_SIZE + sizeof(int), STRINGIFY_NAME(strt) " bigger than " STRINGIFY_NAME(size)); \
- _Static_assert(sizeof(strt) >= size + ptrs * POINTER_SIZE + sizeof(int), STRINGIFY_NAME(strt) " smaller than " STRINGIFY_NAME(size))
+ static_assert(sizeof(strt) <= size + ptrs * POINTER_SIZE + sizeof(int), STRINGIFY_NAME(strt) " bigger than " STRINGIFY_NAME(size)); \
+ static_assert(sizeof(strt) >= size + ptrs * POINTER_SIZE + sizeof(int), STRINGIFY_NAME(strt) " smaller than " STRINGIFY_NAME(size))
/* size checks on packed structures */
CHECK_STRUCT_SIZE(dvd_time_t, 0, DVD_TIME_SIZE);
=====================================
src/meson.build
=====================================
@@ -32,10 +32,6 @@ else
api_export_flags = ['-DDVDREAD_API_EXPORT']
endif
-if host_machine.system() == 'windows'
- api_export_flags = [api_export_flags, '-D_CRT_SECURE_NO_WARNINGS']
-endif
-
# The final libdvdread library
libdvdread = library('dvdread', dvdread_src,
include_directories: dvdread_inc_dirs,
View it on GitLab: https://code.videolan.org/videolan/libdvdread/-/compare/8aab6551a3a5de40649a74d98cdfad003d5e4ba7...e3ac723283b49959776ef932b5817cd318585626
--
View it on GitLab: https://code.videolan.org/videolan/libdvdread/-/compare/8aab6551a3a5de40649a74d98cdfad003d5e4ba7...e3ac723283b49959776ef932b5817cd318585626
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help
More information about the libdvdnav-devel
mailing list