This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH: update to fixinc.svr4
- To: egcs-patches at egcs dot cygnus dot com
- Subject: PATCH: update to fixinc.svr4
- From: Robert Lipe <robertl at sco dot com>
- Date: Wed, 2 Jun 1999 22:25:29 -0500
- Cc: jpr at jpr dot com
[ Jeff, please consider this for both branch and trunk. ]
[ Bruce, since fast fixincludes isn't active on hosts where fixinc.svr4
is used, do we need to do anything like propogate this into
inclhack.def? ]
This problem has been the ghost in my attic for a while. From time to
time it rattles chains in my attic but never made itself visible enough
for me to do anything about it.
Here's the deal...
On the SVR5-based systems (perhaps this is a UNIX-98 thing or an IPV6
thing or just something to torment me) <arpa/inet.h> prototypes the
following:
in_addr_t htonl(in_addr_t hostlong);
in_port_t htons(in_port_t hostshort);
in_addr_t ntohl(in_addr_t netlong);
in_port_t ntohs(in_port_t netshort);
(An in_addr_t is ultimately a ulong. An in_port_t is a ushort.)
Now, GCC's fixinc.svr4 comes along and squishes <sys/byteorder.h> with
its own version. Unfortunately, in it the two functions named *s above
have an argument of a ulong, not a ushort. So any source program that
ends up including both <arpa/inet.h> and <sys/byteorder.h> (which
presumably means most network-aware programs) forces gcc to squawk
of this form:
/usr/include/arpa/inet.h:67: conflicting types for `htons'
/usr/local/lib/gcc-lib/i686-UnixWare7.0.1-sysv5/egcs-2.91.61/include/sys/byteorder.h:60: previous declaration of `htons'
/usr/include/arpa/inet.h:73: conflicting types for `ntohs'
/usr/local/lib/gcc-lib/i686-UnixWare7.0.1-sysv5/egcs-2.91.61/include/sys/byteorder.h:140: previous declaration of `ntohs'
I "fixed" this by making fixinc.svr4 whack the prototypes out of arpa.h.
The way that they're defined in GCC's byteorder.h should ensure that we
never see any ABI or compatibility issues.
JP, with this patch installed, I can build lynx with both udk-gcc and on UW7
and successfully connect to the httpd on localhost.
Wed Jun 2 22:21:34 CDT 1999 Robert Lipe <robertlipe@usa.net>
* fixinc.svr4: Fix <arpa/inet.h> by deleting protos for htons and
ntohs.
Index: fixinc.svr4
===================================================================
RCS file: /cvs/egcs/egcs/gcc/fixinc/fixinc.svr4,v
retrieving revision 1.5
diff -u -p -r1.5 fixinc.svr4
--- fixinc.svr4 1999/03/12 07:42:09 1.5
+++ fixinc.svr4 1999/06/03 03:24:02
@@ -1570,6 +1570,37 @@ if [ \! -z "$file_to_fix" ]; then
rm -f /tmp/$base
fi
+# If arpa/inet.h prototypes are incompatible with the ones we just
+# installed in <sys/byteorder.h>, just remove the protos.
+set -x
+file=arpa/inet.h
+base=`basename $file`
+if [ -r ${LIB}/$file ]; then
+ file_to_fix=${LIB}/$file
+else
+ if [ -r ${INPUT}/$file ]; then
+ file_to_fix=${INPUT}/$file
+ else
+ file_to_fix=""
+ fi
+fi
+if [ \! -z "$file_to_fix" ]; then
+ echo Checking $file_to_fix
+ sed -e '/^extern.*htons.*(in_port_t)/d' \
+ -e '/^extern.*ntohs.*(in_port_t)/d' \
+ $file_to_fix > /tmp/$base
+ if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
+ true
+ else
+ echo Fixed $file_to_fix
+ mkdir -p $LIB/`dirname $file`
+ rm -f ${LIB}/$file
+ cp /tmp/$base ${LIB}/$file
+ chmod a+r ${LIB}/$file
+ fi
+ rm -f /tmp/$base
+fi
+
echo 'Removing unneeded directories:'
cd $LIB
files=`find . -type d -print | sort -r`