[libdvdnav-devel] [Git][videolan/libdvdread][master] 11 commits: dvd_reader: remove unused defines

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Wed Jul 29 18:40:54 UTC 2026



Jean-Baptiste Kempf pushed to branch master at VideoLAN / libdvdread


Commits:
68b335b6 by Kacper Michajłow at 2026-07-29T19:49:49+02:00
dvd_reader: remove unused defines

- - - - -
d18158bf by Kacper Michajłow at 2026-07-29T19:50:59+02:00
msvc: remove unused dlfcn.h compat header

HAVE_DLFCN_H is only defined on non-Windows hosts and the dlopen()
fallback in dvd_input.c uses LoadLibrary/GetProcAddress on Windows,
so this header is never included.

- - - - -
d158545a by Kacper Michajłow at 2026-07-29T19:51:28+02:00
msvc: remove unused dirent compat sources

file_win32.c uses the native Win32 directory APIs and file_posix.c is
only built on non-Windows hosts, so nothing includes this dirent.h and
dirent.c in not a part of the build after file_win32.c was introduced.

- - - - -
ff087ab9 by Kacper Michajłow at 2026-07-29T19:52:27+02:00
dvd_reader: remove redundant ssize_t typedef

All ssize_t uses in this header come after the dvd_filesystem.h
include.

- - - - -
ea70b753 by Kacper Michajłow at 2026-07-29T19:53:19+02:00
file_posix: remove redundant OS/2 open flags branch

The generic #ifdef O_BINARY right below already adds the flag on
platforms that define it, so the OS/2 special case did nothing extra.

- - - - -
abc7c663 by Kacper Michajłow at 2026-07-29T19:53:43+02:00
dvd_udf: remove unused includes

- - - - -
d000dee9 by Kacper Michajłow at 2026-07-29T19:54:07+02:00
dvd_reader: remove unused unistd.h include

- - - - -
9df5f403 by Kacper Michajłow at 2026-07-29T19:54:32+02:00
file_posix: include dirent.h unconditionally

opendir()/readdir() are used unconditionally right below, so the
HAVE_DIRENT_H guard protected nothing.

- - - - -
23289c7c by Kacper Michajłow at 2026-07-29T19:55:14+02:00
ifo_read: remove pointless DVD_BLOCK_LEN guard

It is not defined anywhere else, so the #ifndef could never be false.

- - - - -
4fff2441 by Kacper Michajłow at 2026-07-29T20:03:27+02:00
ifo_types: use attribute packing whenever available

__attribute__((packed)) has been supported since GCC 2.95 (1999), so
the version check is long obsolete. Also check for __clang__
explicitly for clang targeting a *-windows-msvc triple.

- - - - -
0b21c45f by Kacper Michajłow at 2026-07-29T20:04:04+02:00
attributes: modernize visibility attribute check

Symbol visibility attributes exist since GCC 4.0 (2005), so drop the
version check. Also check for __clang__ explicitly for clang builds
targeting a *-windows-msvc triple.

- - - - -


11 changed files:

- meson.build
- − msvc/contrib/dirent/dirent.c
- − msvc/contrib/dirent/dirent.h
- − msvc/include/dlfcn.h
- src/dvd_reader.c
- src/dvd_udf.c
- src/dvdread/attributes.h
- src/dvdread/dvd_reader.h
- src/dvdread/ifo_types.h
- src/file/file_posix.c
- src/ifo_read.c


Changes:

=====================================
meson.build
=====================================
@@ -20,7 +20,7 @@ cdata = configuration_data()
 dvdread_inc_dirs = include_directories('.', 'src', 'src/dvdread')
 if cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl'
     # extra POSIX headers not found in the Windows SDK
-    dvdread_inc_dirs = [dvdread_inc_dirs, include_directories('msvc/include', 'msvc/contrib/dirent')]
+    dvdread_inc_dirs = [dvdread_inc_dirs, include_directories('msvc/include')]
 endif
 
 # The version number for the shared library
@@ -55,7 +55,6 @@ endif
 
 check_headers = [
     'sys/param.h',
-    'dirent.h',
 ]
 
 foreach h : check_headers


=====================================
msvc/contrib/dirent/dirent.c deleted
=====================================
@@ -1,135 +0,0 @@
-/*
-
-    Implementation of POSIX directory browsing functions and types for Win32.
-
-    Kevlin Henney (mailto:kevlin at acm.org), March 1997.
-
-    Copyright Kevlin Henney, 1997. All rights reserved.
-
-    Permission to use, copy, modify, and distribute this software and its
-    documentation for any purpose is hereby granted without fee, provided
-    that this copyright and permissions notice appear in all copies and
-    derivatives, and that no charge may be made for the software and its
-    documentation except to cover cost of distribution.
-
-    This software is supplied "as is" without express or implied warranty.
-
-    But that said, if there are any problems please get in touch.
-
-*/
-
-#include <dirent.h>
-#include <errno.h>
-#include <io.h>
-#include <stdlib.h>
-#include <string.h>
-
-#ifndef DIR
-
-struct DIR
-{
-    long                handle; /* -1 for failed rewind */
-    struct _finddata_t  info;
-    struct dirent       result; /* d_name null iff first time */
-    char                *name;  /* NTBS */
-};
-
-#endif
-
-DIR *opendir(const char *name)
-{
-    DIR *dir = 0;
-
-    if(name && name[0])
-    {
-        size_t base_length = strlen(name);
-        const char *all = /* the root directory is a special case... */
-            strchr("/\\", name[base_length - 1]) ? "*" : "/*";
-
-        if((dir = malloc(sizeof *dir)) != 0 &&
-           (dir->name = malloc(base_length + strlen(all) + 1)) != 0)
-        {
-            strcat(strcpy(dir->name, name), all);
-
-            if((dir->handle = _findfirst(dir->name, &dir->info)) != -1)
-            {
-                dir->result.d_name = 0;
-            }
-            else /* rollback */
-            {
-                free(dir->name);
-                free(dir);
-                dir = 0;
-            }
-        }
-        else /* rollback */
-        {
-            free(dir);
-            dir   = 0;
-            errno = ENOMEM;
-        }
-    }
-    else
-    {
-        errno = EINVAL;
-    }
-
-    return dir;
-}
-
-int closedir(DIR *dir)
-{
-    int result = -1;
-
-    if(dir)
-    {
-        if(dir->handle != -1)
-        {
-            result = _findclose(dir->handle);
-        }
-
-        free(dir->name);
-        free(dir);
-    }
-
-    if(result == -1) /* map all errors to EBADF */
-    {
-        errno = EBADF;
-    }
-
-    return result;
-}
-
-struct dirent *readdir(DIR *dir)
-{
-    struct dirent *result = 0;
-
-    if(dir && dir->handle != -1)
-    {
-        if(!dir->result.d_name || _findnext(dir->handle, &dir->info) != -1)
-        {
-            result         = &dir->result;
-            result->d_name = dir->info.name;
-        }
-    }
-    else
-    {
-        errno = EBADF;
-    }
-
-    return result;
-}
-
-void rewinddir(DIR *dir)
-{
-    if(dir && dir->handle != -1)
-    {
-        _findclose(dir->handle);
-        dir->handle = _findfirst(dir->name, &dir->info);
-        dir->result.d_name = 0;
-    }
-    else
-    {
-        errno = EBADF;
-    }
-}


=====================================
msvc/contrib/dirent/dirent.h deleted
=====================================
@@ -1,32 +0,0 @@
-/*
-
-    Declaration of POSIX directory browsing functions and types for Win32.
-
-    Kevlin Henney (mailto:kevlin at acm.org), March 1997.
-
-    Copyright Kevlin Henney, 1997. All rights reserved.
-
-    Permission to use, copy, modify, and distribute this software and its
-    documentation for any purpose is hereby granted without fee, provided
-    that this copyright and permissions notice appear in all copies and
-    derivatives, and that no charge may be made for the software and its
-    documentation except to cover cost of distribution.
-
-*/
-
-#ifndef DIRENT_INCLUDED
-#define DIRENT_INCLUDED
-
-typedef struct DIR DIR;
-
-struct dirent
-{
-    char *d_name;
-};
-
-DIR           *opendir(const char *);
-int           closedir(DIR *);
-struct dirent *readdir(DIR *);
-void          rewinddir(DIR *);
-
-#endif


=====================================
msvc/include/dlfcn.h deleted
=====================================
@@ -1,18 +0,0 @@
-#ifndef __DLFCN_H__
-# define __DLFCN_H__
-
-extern void *dlopen  (const char *file, int mode);
-extern int   dlclose (void *handle);
-extern void *dlsym   (void * handle, const char * name);
-extern char *dlerror (void);
-
-/* These don't mean anything on windows */
-#define RTLD_NEXT      ((void *) -1l)
-#define RTLD_DEFAULT   ((void *) 0)
-#define RTLD_LAZY                                       -1
-#define RTLD_NOW                                        -1
-#define RTLD_BINDING_MASK -1
-#define RTLD_NOLOAD                             -1
-#define RTLD_GLOBAL                             -1
-
-#endif /* __DLFCN_H__ */


=====================================
src/dvd_reader.c
=====================================
@@ -26,7 +26,6 @@
 #include <stdio.h>          /* fprintf */
 #include <errno.h>          /* errno, EIN* */
 #include <string.h>         /* memcpy, strlen */
-#include <unistd.h>         /* close */
 #include <limits.h>         /* PATH_MAX */
 #include <ctype.h>          /* isalpha */
 
@@ -59,11 +58,6 @@
   (((uint64_t)(bytes) + DVD_VIDEO_LB_LEN - 1) / DVD_VIDEO_LB_LEN)
 
 #if defined(_MSC_VER)
-// sys/stat.h values
-#define S_ISREG(m)  (((m) & _S_IFMT) == _S_IFREG)
-#define S_ISBLK(m) 0
-#define S_ISCHR(m) 0
-
 #define PATH_MAX _MAX_PATH
 #endif
 


=====================================
src/dvd_udf.c
=====================================
@@ -37,8 +37,6 @@
 #endif
 
 #include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
 #include <inttypes.h>
 
 #include "dvdread_internal.h"


=====================================
src/dvdread/attributes.h
=====================================
@@ -23,7 +23,7 @@
 #ifdef DVDREAD_API_EXPORT
 #  if defined(_WIN32) || defined(__OS2__)
 #    define DVDREAD_API  __declspec(dllexport)
-#  elif defined(__GNUC__) && __GNUC__ >= 4
+#  elif defined(__GNUC__) || defined(__clang__)
 #    define DVDREAD_API  __attribute__((visibility("default")))
 #  endif
 #else


=====================================
src/dvdread/dvd_reader.h
=====================================
@@ -32,11 +32,6 @@
 #include <inttypes.h>
 #include <stdarg.h>
 
-#if defined(_MSC_VER) && !defined(ssize_t)
-#include <basetsd.h>
-typedef SSIZE_T ssize_t;
-#endif
-
 #include <dvdread/attributes.h>
 
 /**


=====================================
src/dvdread/ifo_types.h
=====================================
@@ -28,11 +28,9 @@
 
 #undef ATTRIBUTE_PACKED
 
-#if defined(__GNUC__)
-# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
-#  define ATTRIBUTE_PACKED __attribute__ ((packed))
-#  define PRAGMA_PACK 0
-# endif
+#if defined(__GNUC__) || defined(__clang__)
+# define ATTRIBUTE_PACKED __attribute__ ((packed))
+# define PRAGMA_PACK 0
 #endif
 
 #if !defined(ATTRIBUTE_PACKED)


=====================================
src/file/file_posix.c
=====================================
@@ -29,9 +29,7 @@
 
 #include <sys/stat.h>
 #include <fcntl.h>
-#if defined(HAVE_DIRENT_H)
 #include <dirent.h>
-#endif
 
 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
 #  if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 24)
@@ -65,15 +63,9 @@ static void *file_open_default(dvd_reader_filesystem_h *fs, const char* filename
 
     int *handle;
     int fd;
-    int flags = 0;
+    int flags = O_RDONLY;
     int mode  = 0;
 
-    #if defined(__OS2__) // not posix but kept here for legacy compatibility reasons
-    flags = O_RDONLY | O_BINARY;
-    #else
-    flags = O_RDONLY;
-    #endif
-
 #ifdef O_CLOEXEC
     flags |= O_CLOEXEC;
 #endif


=====================================
src/ifo_read.c
=====================================
@@ -36,11 +36,7 @@
 #include "dvdread/bitreader.h"
 
 #define POINTER_SIZE  sizeof(void*)
-
-
-#ifndef DVD_BLOCK_LEN
 #define DVD_BLOCK_LEN 2048
-#endif
 
 #define PRIV(a) container_of(a, struct ifo_handle_private_s, handle)
 



View it on GitLab: https://code.videolan.org/videolan/libdvdread/-/compare/21cdfe9f23079277e0b4858b6ca37abd8d94ec7e...0b21c45f648a38947ee2bbc75c9a1bd577d96b71

-- 
View it on GitLab: https://code.videolan.org/videolan/libdvdread/-/compare/21cdfe9f23079277e0b4858b6ca37abd8d94ec7e...0b21c45f648a38947ee2bbc75c9a1bd577d96b71
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