[RFC] Reduce namespace pollution on zlib.h
Xin LI
delphij at delphij.net
Fri Mar 26 18:34:15 UTC 2010
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
The recent zlib import has added some assumption that
_LARGEFILE_64_SOURCE is only defined on systems with System V style *64
interface. Moreover, I have added _FILE_OFFSET_BITS = 64 definition
into zconf.h so that it would pick up the 64 bit interface properly.
This unfortunately could cause some namespace pollution. As such, I
would propose the attached changes to zlib headers:
zconf.h:
* If _LARGEFILE_64_SOURCE is defined, set __FreeBSD_LARGEFILE_64_SOURCE
and undefine it, as it would break zlib.h
* If _FILE_OFFSET_BITS is undefined, set __FreeBSD_FILE_OFFSET_BITS and
define it as 64.
zlib.h:
* If __FreeBSD_LARGEFILE_64_SOURCE is defined and _LARGEFILE_64_SOURCE
undefined, undefine __FreeBSD_LARGEFILE_64_SOURCE and define
_LARGEFILE_64_SOURCE.
* If __FreeBSD_FILE_OFFSET_BITS is defined and _FILE_OFFSET_BITS is
defined, undefine both.
This approach is kind of mess, though, but would avoid massive changes
which I'd propose for next zlib release.
Comments? Objections?
Cheers,
- --
Xin LI <delphij at delphij.net> http://www.delphij.net/
FreeBSD - The Power to Serve! Live free or die
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (FreeBSD)
iQEcBAEBAgAGBQJLrP4XAAoJEATO+BI/yjfBk2YH/Ag38kdtjxAk0l2kdgnHPnZ7
Wf9uk+0ixgE8X2uHfkOeiVO99Ma47aFU/thS1qgXRIWqP/iQEMqOiUayubYnsCJk
K8quwzEuifM0hlIPzHxgzo5/e1O6GhUdIkJVJj+T//twG2BGXziYHMye/aph0iRa
kW5DEq469jBoz62N8FDn4iatZoXT5boBc0bE3GQCKJhUADbpC84vjCCHfdVx50mu
x5hEO88TNaWSn4AkPgs0xPBYQNM+w6t2g/CLNfylumIUVHcSs+v8sLKrxdqqvKNx
hn97KmDagy5BVaWaAFAqFclgfAVbjfa8NIaOr8egxnuVHXTzEzjHFUD7fS22Oqo=
=eOpg
-----END PGP SIGNATURE-----
-------------- next part --------------
Index: lib/libz/zconf.h
===================================================================
--- lib/libz/zconf.h (revision 205651)
+++ lib/libz/zconf.h (working copy)
@@ -375,6 +375,13 @@
# endif
#endif
+#if defined(__FreeBSD__) && defined(_LARGEFILE64_SOURCE)
+#if !defined(__FreeBSD_LARGEFILE64_SOURCE)
+#define __FreeBSD_LARGEFILE64_SOURCE
+#endif
+#undef _LARGEFILE64_SOURCE
+#endif
+
#ifdef _LARGEFILE64_SOURCE
# include <sys/types.h>
#endif
@@ -391,6 +398,9 @@
#include <sys/types.h>
#define z_off_t off_t
#ifndef _FILE_OFFSET_BITS
+#if !defined(__FreeBSD_FILE_OFFSET_BITS)
+#define __FreeBSD_FILE_OFFSET_BITS
+#endif
#define _FILE_OFFSET_BITS 64
#endif
Index: lib/libz/zlib.h
===================================================================
--- lib/libz/zlib.h (revision 205651)
+++ lib/libz/zlib.h (working copy)
@@ -1597,6 +1597,20 @@
ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void));
ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int));
+#if defined(__FreeBSD_LARGEFILE64_SOURCE)
+#undef __FreeBSD_LARGEFILE64_SOURCE
+#if !defined(_LARGEFILE64_SOURCE)
+#define _LARGEFILE64_SOURCE
+#endif
+#endif
+
+#if defined(__FreeBSD_FILE_OFFSET_BITS)
+#undef __FreeBSD_FILE_OFFSET_BITS
+#if defined(_FILE_OFFSET_BITS)
+#undef _FILE_OFFSET_BITS
+#endif
+#endif
+
#ifdef __cplusplus
}
#endif
More information about the freebsd-ports
mailing list