(I'm also CCing the FreeBSD port maintainer, as I imagine they want that
handled, too.)

Am Sat, 31 Aug 2013 10:03:46 +0200
schrieb Reinhard Tartler <siret...@gmail.com>: 

> Thomas, may I have your opinion on this patch? If you are d'accord,
> I'd upload it to debian/unstable for further testing.

OK, I see that I need to see more clear. The aliases need to be named
_64 and also need to use the correct type for offsets. I didn't design
lfs_alias.c to be so smart to derive the correct type from
LFS_ALIAS_BITS. With your patch, it still would use long arguments,
which I presume should fail at runtime with mplayer2. We need to
change the wrapper's argument to reflect whatever is native to the
platform, not the mpg123 build (it _is_ the same for kFreeBSD).

Please have a read of my musings,

  http://scm.orgis.org/view/mpg123/trunk/doc/LARGEFILE ,

and try the attached patch, which reflects the changes I did in mpg123
trunk, so that you can drop it for mpg123-1.16.0 (which I plan to
release once I got around fixing some decoder build choice).

I kindly ask everyone concerned to really test this on their platform
(including linking and running mplayer2 with mpg123 usage, for
example), as I don't have time to set up test installs for the variants
right now. I did check that the symbols get defined correctly on my
Linux system.
Index: src/libmpg123/lfs_alias.c
===================================================================
--- src/libmpg123/lfs_alias.c	(Revision 3382)
+++ src/libmpg123/lfs_alias.c	(Arbeitskopie)
@@ -67,9 +67,9 @@
 	my $name = $2;
 	my $args = $3;
 	next unless ($type =~ /off_t/ or $args =~ /off_t/ or ($name =~ /open/ and $name ne mpg123_open_feed));
-	$type =~ s/off_t/long/g;
+	$type =~ s/off_t/lfs_alias_t/g;
 	my @nargs = ();
-	$args =~ s/off_t/long/g;
+	$args =~ s/off_t/lfs_alias_t/g;
 	foreach my $a (split(/,/, $args))
 	{
 		$a =~ s/^.*\s\**([a-z_]+)$/$1/;
@@ -118,7 +118,7 @@
 #ifdef mpg123_decode_frame
 #undef mpg123_decode_frame
 #endif
-int attribute_align_arg ALIAS_NAME(mpg123_decode_frame)(mpg123_handle *mh, long *num, unsigned char **audio, size_t *bytes)
+int attribute_align_arg ALIAS_NAME(mpg123_decode_frame)(mpg123_handle *mh, lfs_alias_t *num, unsigned char **audio, size_t *bytes)
 {
 	return NATIVE_NAME(mpg123_decode_frame)(mh, num, audio, bytes);
 }
@@ -126,7 +126,7 @@
 #ifdef mpg123_framebyframe_decode
 #undef mpg123_framebyframe_decode
 #endif
-int attribute_align_arg ALIAS_NAME(mpg123_framebyframe_decode)(mpg123_handle *mh, long *num, unsigned char **audio, size_t *bytes)
+int attribute_align_arg ALIAS_NAME(mpg123_framebyframe_decode)(mpg123_handle *mh, lfs_alias_t *num, unsigned char **audio, size_t *bytes)
 {
 	return NATIVE_NAME(mpg123_framebyframe_decode)(mh, num, audio, bytes);
 }
@@ -134,7 +134,7 @@
 #ifdef mpg123_framepos
 #undef mpg123_framepos
 #endif
-long attribute_align_arg ALIAS_NAME(mpg123_framepos)(mpg123_handle *mh)
+lfs_alias_t attribute_align_arg ALIAS_NAME(mpg123_framepos)(mpg123_handle *mh)
 {
 	return NATIVE_NAME(mpg123_framepos)(mh);
 }
@@ -142,7 +142,7 @@
 #ifdef mpg123_tell
 #undef mpg123_tell
 #endif
-long attribute_align_arg ALIAS_NAME(mpg123_tell)(mpg123_handle *mh)
+lfs_alias_t attribute_align_arg ALIAS_NAME(mpg123_tell)(mpg123_handle *mh)
 {
 	return NATIVE_NAME(mpg123_tell)(mh);
 }
@@ -150,7 +150,7 @@
 #ifdef mpg123_tellframe
 #undef mpg123_tellframe
 #endif
-long attribute_align_arg ALIAS_NAME(mpg123_tellframe)(mpg123_handle *mh)
+lfs_alias_t attribute_align_arg ALIAS_NAME(mpg123_tellframe)(mpg123_handle *mh)
 {
 	return NATIVE_NAME(mpg123_tellframe)(mh);
 }
@@ -158,7 +158,7 @@
 #ifdef mpg123_tell_stream
 #undef mpg123_tell_stream
 #endif
-long attribute_align_arg ALIAS_NAME(mpg123_tell_stream)(mpg123_handle *mh)
+lfs_alias_t attribute_align_arg ALIAS_NAME(mpg123_tell_stream)(mpg123_handle *mh)
 {
 	return NATIVE_NAME(mpg123_tell_stream)(mh);
 }
@@ -166,7 +166,7 @@
 #ifdef mpg123_seek
 #undef mpg123_seek
 #endif
-long attribute_align_arg ALIAS_NAME(mpg123_seek)(mpg123_handle *mh, long sampleoff, int whence)
+lfs_alias_t attribute_align_arg ALIAS_NAME(mpg123_seek)(mpg123_handle *mh, lfs_alias_t sampleoff, int whence)
 {
 	return NATIVE_NAME(mpg123_seek)(mh, sampleoff, whence);
 }
@@ -174,7 +174,7 @@
 #ifdef mpg123_feedseek
 #undef mpg123_feedseek
 #endif
-long attribute_align_arg ALIAS_NAME(mpg123_feedseek)(mpg123_handle *mh, long sampleoff, int whence, long *input_offset)
+lfs_alias_t attribute_align_arg ALIAS_NAME(mpg123_feedseek)(mpg123_handle *mh, lfs_alias_t sampleoff, int whence, lfs_alias_t *input_offset)
 {
 	return NATIVE_NAME(mpg123_feedseek)(mh, sampleoff, whence, input_offset);
 }
@@ -182,7 +182,7 @@
 #ifdef mpg123_seek_frame
 #undef mpg123_seek_frame
 #endif
-long attribute_align_arg ALIAS_NAME(mpg123_seek_frame)(mpg123_handle *mh, long frameoff, int whence)
+lfs_alias_t attribute_align_arg ALIAS_NAME(mpg123_seek_frame)(mpg123_handle *mh, lfs_alias_t frameoff, int whence)
 {
 	return NATIVE_NAME(mpg123_seek_frame)(mh, frameoff, whence);
 }
@@ -190,7 +190,7 @@
 #ifdef mpg123_timeframe
 #undef mpg123_timeframe
 #endif
-long attribute_align_arg ALIAS_NAME(mpg123_timeframe)(mpg123_handle *mh, double sec)
+lfs_alias_t attribute_align_arg ALIAS_NAME(mpg123_timeframe)(mpg123_handle *mh, double sec)
 {
 	return NATIVE_NAME(mpg123_timeframe)(mh, sec);
 }
@@ -198,7 +198,7 @@
 #ifdef mpg123_index
 #undef mpg123_index
 #endif
-int attribute_align_arg ALIAS_NAME(mpg123_index)(mpg123_handle *mh, long **offsets, long *step, size_t *fill)
+int attribute_align_arg ALIAS_NAME(mpg123_index)(mpg123_handle *mh, lfs_alias_t **offsets, lfs_alias_t *step, size_t *fill)
 {
 	return NATIVE_NAME(mpg123_index)(mh, offsets, step, fill);
 }
@@ -206,7 +206,7 @@
 #ifdef mpg123_set_index
 #undef mpg123_set_index
 #endif
-int attribute_align_arg ALIAS_NAME(mpg123_set_index)(mpg123_handle *mh, long *offsets, long step, size_t fill)
+int attribute_align_arg ALIAS_NAME(mpg123_set_index)(mpg123_handle *mh, lfs_alias_t *offsets, lfs_alias_t step, size_t fill)
 {
 	return NATIVE_NAME(mpg123_set_index)(mh, offsets, step, fill);
 }
@@ -214,7 +214,7 @@
 #ifdef mpg123_position
 #undef mpg123_position
 #endif
-int attribute_align_arg ALIAS_NAME(mpg123_position)( mpg123_handle *mh, long frame_offset, long buffered_bytes, long *current_frame, long *frames_left, double *current_seconds, double *seconds_left)
+int attribute_align_arg ALIAS_NAME(mpg123_position)( mpg123_handle *mh, lfs_alias_t frame_offset, lfs_alias_t buffered_bytes, lfs_alias_t *current_frame, lfs_alias_t *frames_left, double *current_seconds, double *seconds_left)
 {
 	return NATIVE_NAME(mpg123_position)(mh, frame_offset, buffered_bytes, current_frame, frames_left, current_seconds, seconds_left);
 }
@@ -222,7 +222,7 @@
 #ifdef mpg123_length
 #undef mpg123_length
 #endif
-long attribute_align_arg ALIAS_NAME(mpg123_length)(mpg123_handle *mh)
+lfs_alias_t attribute_align_arg ALIAS_NAME(mpg123_length)(mpg123_handle *mh)
 {
 	return NATIVE_NAME(mpg123_length)(mh);
 }
@@ -230,7 +230,7 @@
 #ifdef mpg123_set_filesize
 #undef mpg123_set_filesize
 #endif
-int attribute_align_arg ALIAS_NAME(mpg123_set_filesize)(mpg123_handle *mh, long size)
+int attribute_align_arg ALIAS_NAME(mpg123_set_filesize)(mpg123_handle *mh, lfs_alias_t size)
 {
 	return NATIVE_NAME(mpg123_set_filesize)(mh, size);
 }
@@ -238,7 +238,7 @@
 #ifdef mpg123_replace_reader
 #undef mpg123_replace_reader
 #endif
-int attribute_align_arg ALIAS_NAME(mpg123_replace_reader)(mpg123_handle *mh, ssize_t (*r_read) (int, void *, size_t), long (*r_lseek)(int, long, int))
+int attribute_align_arg ALIAS_NAME(mpg123_replace_reader)(mpg123_handle *mh, ssize_t (*r_read) (int, void *, size_t), lfs_alias_t (*r_lseek)(int, lfs_alias_t, int))
 {
 	return NATIVE_NAME(mpg123_replace_reader)(mh, r_read, r_lseek);
 }
@@ -246,7 +246,7 @@
 #ifdef mpg123_replace_reader_handle
 #undef mpg123_replace_reader_handle
 #endif
-int attribute_align_arg ALIAS_NAME(mpg123_replace_reader_handle)(mpg123_handle *mh, ssize_t (*r_read) (void *, void *, size_t), long (*r_lseek)(void *, long, int), void (*cleanup)(void*))
+int attribute_align_arg ALIAS_NAME(mpg123_replace_reader_handle)(mpg123_handle *mh, ssize_t (*r_read) (void *, void *, size_t), lfs_alias_t (*r_lseek)(void *, lfs_alias_t, int), void (*cleanup)(void*))
 {
 	return NATIVE_NAME(mpg123_replace_reader_handle)(mh, r_read, r_lseek, cleanup);
 }
Index: configure.ac
===================================================================
--- configure.ac	(Revision 3382)
+++ configure.ac	(Arbeitskopie)
@@ -970,12 +970,16 @@
 dnl Others... we'll have to see.
 dnl Note: I started writing this with with multiline replacements.
 dnl Does not work. Automake insists on putting these into Makefiles where they break things.
+dnl It is also assumed that a system that does not set file offset bits is not
+dnl sensitive to largefile changes, i.e. FreeBSD always using 64 bit off_t.
 if test "x$ac_cv_sys_file_offset_bits" = x || echo "$ac_cv_sys_file_offset_bits" | $GREP  '@<:@^0-9@:>@' > /dev/null; then
 	dnl if it has non-numeric chars or is empty... ignore...
 	LFS_LOBJ=
+	largefile_sensitive=no
 else
 	# Add dual-mode wrapper code.
 	LFS_LOBJ=lfs_wrap.lo
+	largefile_sensitive=yes
 fi
 
 # Using the lower level macros instead of AC_TYPE_* for compatibility with not freshest autoconf.
@@ -993,19 +997,30 @@
 AC_CHECK_SIZEOF(int32_t)
 AC_CHECK_SIZEOF(long,4)
 
-# The alias functions want to know the native off_t bits.
-# "Native" also means large file offsets, if enabled, it's what is native to the mpg123 library.
-if test "x$ac_cv_sizeof_long" = "x"; then 
-  AC_MSG_ERROR([Cannot determine sizeof(long)?])
+dnl The native type used for aliases is what off_t maps to without any largefile-
+dnl enabling switches. So, it's long int if the system is largefile-senstive,
+dnl but it is actual plain off_t if the system does not have such switches.
+if test "x$largefile_sensitive" = xyes; then
+  lfs_alias_type=long
+  lfs_alias_size=$ac_cv_sizeof_long
 else
-  LFS_ALIAS_BITS=`expr "$ac_cv_sizeof_long" "*" "8"`
+  lfs_alias_type=off_t
+  lfs_alias_size=$ac_cv_sizeof_off_t
+fi
+
+if test "x$lfs_alias_size" = "x"; then 
+  AC_MSG_ERROR([Cannot determine sizeof(lfs_alias_t)?])
+else
+  LFS_ALIAS_BITS=`expr "$lfs_alias_size" "*" "8"`
+  AC_DEFINE_UNQUOTED([lfs_alias_t], $lfs_alias_type,
+    [Define to the native offset type (long or actually off_t).])
   AC_DEFINE_UNQUOTED([LFS_ALIAS_BITS], $LFS_ALIAS_BITS,
-    [Define this to the size of long type in bits, used for LFS small/native alias functions.])
+    [Define this to the size of native offset type in bits, used for LFS alias functions.])
 fi
 
 lfs_alias=enabled
 AC_ARG_ENABLE(lfs-alias,
-              [  --disable-lfs-alias disable alias wrappers for largefile bitness (mpg123_seek_32 in addition to mpg123_seek, mpg123_seek_64 as alias on x86-64) ],
+              [  --disable-lfs-alias disable alias wrappers for largefile bitness (mpg123_seek_32 or mpg123_seek_64 in addition to mpg123_seek, or the other way around; It is a mess, do not play with this!) ],
               [
                 if test "x$enableval" = xno; then
                   lfs_alias="disabled"
@@ -2341,6 +2356,7 @@
   echo "    The lib will (try to) support default offset size, too."
 fi
 echo "  LFS alias symbols ....... $lfs_alias ($LFS_ALIAS_BITS)"
+echo "  LFS alias type .......... $lfs_alias_type"
 
 echo -n "
   Core libmpg123 features:

Attachment: signature.asc
Description: PGP signature

Reply via email to