[PATCH] lseek vs lseek64 again - Cygwin this time

Diego Biurrun diego at biurrun.de
Sun Nov 5 23:16:39 CET 2006


Hi,

libdvdcss currently fails to link on Cygwin with the following error
message:

/home/bond/libdvdcss/src/device.c:595: undefined reference to `_lseek64'

The problem is that Cygwin does not have lseek64.  In src/common.h
lseek64 is redefined to lseek for most platforms, but not for Cygwin.

Currently we have the following in src/common.h (irrelevant lines left
out):

#if defined( WIN32 )
#   if defined( __MINGW32__ )
#       define lseek64 _lseeki64
#   endif
#   if defined( _MSC_VER )
#   endif
#else
#   define lseek64 lseek
#endif

Unfortunately Cygwin defines WIN32 and thus does not hit the else case
where lseek64 gets redefined.

This block has things backwards.  If MinGW and MSC need special-casing,
then it should be confined in the smallest possible space.  My solution
is therefore to remove the else case from that block and redefine lseek
for MinGW and MSC:

#if defined( WIN32 )
#   if defined( __MINGW32__ )
#       define lseek _lseeki64
#   endif
#   if defined( _MSC_VER )
#       define lseek lseek64
#   endif
#endif

Of course lseek64 needs to be replaced by lseek in src/device.c.

The attached patch accomplished this, please apply.

Diego
-------------- next part --------------
Index: src/device.c
===================================================================
--- src/device.c	(revision 202)
+++ src/device.c	(working copy)
@@ -592,7 +592,7 @@
     }
 
     i_seek = (off_t)i_blocks * (off_t)DVDCSS_BLOCK_SIZE;
-    i_seek = lseek64( dvdcss->i_read_fd, i_seek, SEEK_SET );
+    i_seek = lseek( dvdcss->i_read_fd, i_seek, SEEK_SET );
 
     if( i_seek < 0 )
     {
Index: src/common.h
===================================================================
--- src/common.h	(revision 202)
+++ src/common.h	(working copy)
@@ -52,7 +52,7 @@
 
 /* several type definitions */
 #   if defined( __MINGW32__ )
-#       define lseek64 _lseeki64
+#       define lseek _lseeki64
 #       if !defined( _OFF_T_ )
 typedef long long _off_t;
 typedef _off_t off_t;
@@ -63,6 +63,7 @@
 #   endif
 
 #   if defined( _MSC_VER )
+#       define lseek lseek64
 #       if !defined( _OFF_T_DEFINED )
 typedef __int64 off_t;
 #           define _OFF_T_DEFINED
@@ -76,9 +77,5 @@
 #       define snprintf _snprintf  /* snprintf not defined in mingw32 (bug?) */
 #   endif
 
-#else
-
-#   define lseek64 lseek
-
 #endif
 


More information about the libdvdcss-devel mailing list