[Zlib-devel] zlib 1.2.3.2 available for testing

Lasse Collin lasse.collin at tukaani.org
Wed Sep 6 15:04:05 EDT 2006


Mark Adler wrote:
> On Sep 6, 2006, at 4:12 AM, Lasse Collin wrote:
> > In other words, 99% of apps on those
> > systems can't use any functions of zlib that have z_off_t in their
> > declaration. That's why I think it is good to make zlib to use
> > large file support by default.
>
> ...
>
> > Mark Brown's suggestion to implement both 32-bit and 64-bit
> > versions of
> > functions that use off_t is definitely the most correct solution.
> > That would keep ABI backwards compatible when adding 64-bit
> > functions.
>
> Wait -- doesn't your second suggestion say to keep the 32-bit z_off_t
> as the default for backward compatibility, in contradiction to the
> first suggestion?  For backward compatibility, the current gzseek()
> and gztell() need to be retained with the current compiler options
> for off_t.  Then the second suggestion would be to add gzseek64() and
> gztell64() functions using a 64-bit type for z_off_t.

The second suggestion is an addition to the first one, not a 
contradiction. See below.

> The current scheme in configure is to #define _LARGEFILE64_SOURCE and
> use off64_t.  In that case, the original off_t is still an available
> type, which I'd need to define a compatible z_off_t to currently
> compiled zlibs.  I would then use z_off_t for gzseek() and gztell(),
> and off64_t for gzseek64() and gztell64().  Then I can't use -
> D_FILE_OFFSET_BITS=64, since that will redefine off_t, and I won't
> have access to the original.  But then what happens if the user
> application uses -D_FILE_OFFSET_BITS=64 -- then zlib.h can't get at
> off_t!  So what's the solution here?

Do it like it is done in C libraries: provide different function 
prototypes depending on _FILE_OFFSET_BITS, and use #define to rename 
them. Example:

typedef off_t z_off_t;
#if !defined(_FILE_OFFSET_BITS) || _FILE_OFFSET_BITS == 32
ZEXTERN z_off_t ZEXPORT    gzseek OF((gzFile file,
                                      z_off_t offset, int whence));
#elif _FILE_OFFSET_BITS == 64
ZEXTERN z_off_t ZEXPORT    gzseek64 OF((gzFile file,
                                      z_off_t offset, int whence));
#define gzseek gzseek64
#else
#error Invalid value in _FILE_OFFSET_BITS.
#endif

When building zlib, you may need to build some files 
without -D_FILE_OFFSET_BITS=64.

> > Backwards compatiblity with old binaries is the reason why 32-bit
> > GNU/Linux supports both 32-bit and 64-bit off_t.
>
> They should have just changed off_t and made everyone recompile.
> What a horrible mess.

Sure, it is a mess, but tolerable when you have an idea about how it 
works. When large file support was introduced, people didn't feel like 
bumping major soname of libc, which would have required rebuilding 
_all_ applications. Not very fun if you needed large file support only 
for one or two apps, and even less fun on non-free proprietary systems. 
64-bit platforms never had this problem, and some operating systems 
such as OpenBSD have always defined off_t to be 64-bit on 32-bit archs.

-- 
Lasse Collin  |  IRC: Larhzu @ IRCnet & Freenode




More information about the Zlib-devel mailing list