Diego Elio Pettenò
2013-02-27 06:55:28 UTC
libdvdcss | branch: xdgcache | Diego Elio Pettenò <***@flameeyes.eu> | Wed Feb 27 07:52:56 2013 +0100| [6720bd34c8ec1260c6753606d336965d504e4e16] | committer: Diego Elio Pettenò
build: use an alternative method for making O_BINARY use conditional.
Instead of creating a new mode altogether, check for the definition of
O_BINARY in the headers, and if missing define it to zero.
configure.ac | 18 ++++++++++++++++--
src/device.c | 2 +-
src/device.h | 3 ---
3 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/configure.ac b/configure.ac
index a59428e..4049704 100644
--- a/configure.ac
+++ b/configure.ac
@@ -52,11 +52,25 @@ AC_C_CONST
AC_C_INLINE
AC_TYPE_SIZE_T
-AC_CHECK_HEADERS(unistd.h sys/param.h sys/uio.h limits.h pwd.h errno.h)
+AC_CHECK_HEADERS([unistd.h sys/param.h sys/uio.h limits.h pwd.h]dnl
+ [errno.h sys/types.h sys/stat.h fcntl.h io.h])
+
+AC_CHECK_DECL([O_BINARY], [],
+ [AC_DEFINE([O_BINARY], [0], [Define O_BINARY if missing])],
+ [
+ #if HAVE_SYS_TYPES_H
+ # include <sys/types.h>
+ #endif
+ #if HAVE_SYS_STAT_H
+ # include <sys/stat.h>
+ #endif
+ #if HAVE_FCNTL_H
+ # include <fcntl.h>
+ #endif
+ ])
AC_SYS_LARGEFILE
-AC_CHECK_HEADERS([sys/stat.h sys/types.h io.h])
AC_CACHE_CHECK(
[for posix mkdir()],
[css_cv_mkdir_posix], [
diff --git a/src/device.c b/src/device.c
index 6a2a7df..f78ffc0 100644
--- a/src/device.c
+++ b/src/device.c
@@ -480,7 +480,7 @@ int _dvdcss_close ( dvdcss_t dvdcss )
*****************************************************************************/
static int libc_open ( dvdcss_t dvdcss, char const *psz_device )
{
- dvdcss->i_fd = dvdcss->i_read_fd = open( psz_device, LIBC_OPEN_MODE );
+ dvdcss->i_fd = dvdcss->i_read_fd = open( psz_device, O_BINARY );
if( dvdcss->i_fd == -1 )
{
diff --git a/src/device.h b/src/device.h
index ab3ade1..4119b70 100644
--- a/src/device.h
+++ b/src/device.h
@@ -46,9 +46,6 @@ struct iovec
#if !defined(WIN32) && !defined(__OS2__)
# define DVDCSS_RAW_OPEN
-# define LIBC_OPEN_MODE 0
-#else
-# define LIBC_OPEN_MODE O_BINARY
#endif
build: use an alternative method for making O_BINARY use conditional.
Instead of creating a new mode altogether, check for the definition of
O_BINARY in the headers, and if missing define it to zero.
http://git.videolan.org/gitweb.cgi/libdvdcss.git/?a=commit;h=6720bd34c8ec1260c6753606d336965d504e4e16
---configure.ac | 18 ++++++++++++++++--
src/device.c | 2 +-
src/device.h | 3 ---
3 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/configure.ac b/configure.ac
index a59428e..4049704 100644
--- a/configure.ac
+++ b/configure.ac
@@ -52,11 +52,25 @@ AC_C_CONST
AC_C_INLINE
AC_TYPE_SIZE_T
-AC_CHECK_HEADERS(unistd.h sys/param.h sys/uio.h limits.h pwd.h errno.h)
+AC_CHECK_HEADERS([unistd.h sys/param.h sys/uio.h limits.h pwd.h]dnl
+ [errno.h sys/types.h sys/stat.h fcntl.h io.h])
+
+AC_CHECK_DECL([O_BINARY], [],
+ [AC_DEFINE([O_BINARY], [0], [Define O_BINARY if missing])],
+ [
+ #if HAVE_SYS_TYPES_H
+ # include <sys/types.h>
+ #endif
+ #if HAVE_SYS_STAT_H
+ # include <sys/stat.h>
+ #endif
+ #if HAVE_FCNTL_H
+ # include <fcntl.h>
+ #endif
+ ])
AC_SYS_LARGEFILE
-AC_CHECK_HEADERS([sys/stat.h sys/types.h io.h])
AC_CACHE_CHECK(
[for posix mkdir()],
[css_cv_mkdir_posix], [
diff --git a/src/device.c b/src/device.c
index 6a2a7df..f78ffc0 100644
--- a/src/device.c
+++ b/src/device.c
@@ -480,7 +480,7 @@ int _dvdcss_close ( dvdcss_t dvdcss )
*****************************************************************************/
static int libc_open ( dvdcss_t dvdcss, char const *psz_device )
{
- dvdcss->i_fd = dvdcss->i_read_fd = open( psz_device, LIBC_OPEN_MODE );
+ dvdcss->i_fd = dvdcss->i_read_fd = open( psz_device, O_BINARY );
if( dvdcss->i_fd == -1 )
{
diff --git a/src/device.h b/src/device.h
index ab3ade1..4119b70 100644
--- a/src/device.h
+++ b/src/device.h
@@ -46,9 +46,6 @@ struct iovec
#if !defined(WIN32) && !defined(__OS2__)
# define DVDCSS_RAW_OPEN
-# define LIBC_OPEN_MODE 0
-#else
-# define LIBC_OPEN_MODE O_BINARY
#endif