Discussion:
[libdvdcss-devel] build: use an alternative method for making O_BINARY use conditional.
Diego Elio Pettenò
2013-02-27 06:55:28 UTC
Permalink
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.
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
Diego Elio Pettenò
2013-02-27 06:57:52 UTC
Permalink
Post by Diego Elio Pettenò
build: use an alternative method for making O_BINARY use conditional.
I would like to cherry-pick this into buildfixes and into the next 1.2.13.
--
Diego Elio Pettenò — Flameeyes
***@flameeyes.eu — http://blog.flameeyes.eu/
Reimar Döffinger
2013-02-27 07:22:38 UTC
Permalink
Post by Diego Elio Pettenò
Post by Diego Elio Pettenò
build: use an alternative method for making O_BINARY use conditional.
I would like to cherry-pick this into buildfixes and into the next 1.2.13.
Honestly, a #ifndef in the code seems much simpler and cleaner to me, involving configure for that kind of thing seems very much like overkill.
Though maybe I am also somewhat biased by Windows being so ridiculously slow at executing those configure checks.
Jean-Baptiste Kempf
2013-02-27 07:24:30 UTC
Permalink
Post by Reimar Döffinger
Though maybe I am also somewhat biased by Windows being so ridiculously slow at executing those configure checks.
Seeing how small libdvdcss is, I doubt this is an issue...
--
Jean-Baptiste Kempf
http://www.jbkempf.com/ - +33 672 704 734
Sent from my Electronic Device
Diego Elio Pettenò
2013-02-27 07:03:58 UTC
Permalink
libdvdcss | branch: master | Diego Elio Pettenò <***@flameeyes.eu> | Wed Feb 27 07:52:56 2013 +0100| [2af9a1e3d10677c2aca1d798b2df4dd8044c258b] | 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.
http://git.videolan.org/gitweb.cgi/libdvdcss.git/?a=commit;h=2af9a1e3d10677c2aca1d798b2df4dd8044c258b
---

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 7e9c162..a736aac 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
Diego Elio Pettenò
2013-02-27 07:09:23 UTC
Permalink
libdvdcss | branch: xdgcache | Diego Elio Pettenò <***@flameeyes.eu> | Wed Feb 27 07:52:56 2013 +0100| [2af9a1e3d10677c2aca1d798b2df4dd8044c258b] | 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.
http://git.videolan.org/gitweb.cgi/libdvdcss.git/?a=commit;h=2af9a1e3d10677c2aca1d798b2df4dd8044c258b
---

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 7e9c162..a736aac 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
Diego Biurrun
2013-02-27 09:47:05 UTC
Permalink
Post by Diego Elio Pettenò
--- a/configure.ac
+++ b/configure.ac
@@ -52,11 +52,25 @@ AC_C_CONST
-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])
What's the "dnl" at the end of the line for?

Diego
Diego Elio Pettenò
2013-02-27 09:50:49 UTC
Permalink
Post by Diego Biurrun
What's the "dnl" at the end of the line for?
Discard till New Line (included)

basically it takes the newline out of the equation.
--
Diego Elio Pettenò — Flameeyes
***@flameeyes.eu — http://blog.flameeyes.eu/
Loading...