home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: gnu.gcc.bug
- Path: sparky!uunet!cis.ohio-state.edu!sedona.intel.com!tmcconne
- From: tmcconne@sedona.intel.com (Tom McConnell)
- Subject: gcc-2.3.2 / NCR-3350 SVR4.02 <sys/endian.h> bug
- Message-ID: <9212221659.AA31542@thunder.intel.com>
- Sender: gnulists@ai.mit.edu
- Organization: GNUs Not Usenet
- Distribution: gnu
- Date: Tue, 22 Dec 1992 02:59:24 GMT
- Approved: bug-gcc@prep.ai.mit.edu
- Lines: 105
-
- Howdy.
-
- I have finished porting gcc-2.3.2 to the NCR-3350, and used it to compile
- X11R5p21 and libg++-2.3. This report concerns the <sys/endian.h> include file.
-
- Cheers,
-
- Tom McConnell
-
- Tom McConnell | Internet: tmcconne@sedona.intel.com
- Intel, Corp. C3-91 | Phone: (602)-554-8229
- 5000 W. Chandler Blvd. | The opinions expressed are my own. No one in
- Chandler, AZ 85226 | their right mind would claim them.
-
- Problem: The definition of "htonl" and "ntohl" differ between <sys/endian.h>
- and <sys/byteorder.h>.
-
- Program: endian.c
-
- /* Test <endian.h> */
- #include <stdio.h>
- #include <netinet/in.h>
- main()
- {
- printf("<endian.h> \n");
- }
-
- Example compile:
-
- gcc -v -c endian.c -o endian.o
- Reading specs from /stor/gnu/iAWS/lib/gcc-lib/ncr3000/2.3.2/specs
- gcc version 2.3.2
- /stor/gnu/iAWS/lib/gcc-lib/ncr3000/2.3.2/cpp -lang-c -v -undef -D__GNUC__=2
- -Di386 -Dunix -D__svr4__ -D__i386__ -D__unix__ -D__svr4__ -D__i386 -D__unix
- -D__svr4__ -Asystem(unix) -Acpu(i386) -Amachine(i386) endian.c
- /var/tmp/cca003Su.i
- GNU CPP version 2.3.2 (i386 System V Release 4)
- /stor/gnu/iAWS/lib/gcc-lib/ncr3000/2.3.2/cc1 /var/tmp/cca003Su.i -quiet
- -dumpbase endian.c -version -o /var/tmp/cca003Su.s
- GNU C version 2.3.2 (i386 System V Release 4) compiled by GNU C version 2.3.2.
- In file included from
- /stor/gnu/iAWS/lib/gcc-lib/ncr3000/2.3.2/include/sys/endian.h:48, from
- /stor/gnu/iAWS/lib/gcc-lib/ncr3000/2.3.2/include/netinet/in.h:42, from
- endian.c:3:
- /stor/gnu/iAWS/lib/gcc-lib/ncr3000/2.3.2/include/sys/byteorder.h:27:
- conflicting types for `htonl'
- /stor/gnu/iAWS/lib/gcc-lib/ncr3000/2.3.2/include/sys/endian.h:43:
- previous declaration of `htonl'
- /stor/gnu/iAWS/lib/gcc-lib/ncr3000/2.3.2/include/sys/byteorder.h:28: warning:
- static declaration for `htons' follows non-static
- /stor/gnu/iAWS/lib/gcc-lib/ncr3000/2.3.2/include/sys/byteorder.h:29:
- conflicting types for `ntohl'
- /stor/gnu/iAWS/lib/gcc-lib/ncr3000/2.3.2/include/sys/endian.h:43:
- previous declaration of `ntohl'
- /stor/gnu/iAWS/lib/gcc-lib/ncr3000/2.3.2/include/sys/byteorder.h:30: warning:
- static declaration for `ntohs' follows non-static
- gmake: *** [endian.o] Error 1
-
- Analysis: There are really two problems here: htonl() and ntohl() in endian.h
- pass different parameters (unsigned int) than htonl() and ntohl()
- in byteorder.h (unsigned long). Since the gcc-2.3.2 supplied
- byteorder.h also includes the assembly code, the easy way out was
- to assume gcc-2.3.2 knew what it was doing. This may not be a good
- assumption, but it seems to work.
-
- The second problem is that if both <sys/endian.h> and
- <sys/byteorder.h> define the number conversion routines (ntohl, etc.),
- the linker will complain about "fatal error: symbol `htonl`
- multiply-defined".
-
- Solution: Modify <sys/endian.h> so that if gcc is being used, do not define
- the number conversion routines. Instead, rely on <sys/byteorder.h>
- to define them.
-
- Patch:
- This patch file was created on Tue Dec 22 09:38:19 MST 1992.
-
- The top level directory was /a/stor/gnu/iAWS/lib/gcc-lib/ncr3000/2.3.2/include
-
-
- *** ./sys/endian.h_orig Tue Dec 22 09:37:35 1992
- --- ./sys/endian.h Mon Dec 21 20:35:10 1992
- ***************
- *** 39,42 ****
- --- 39,43 ----
- #define htons(x) (x)
- #else
- + # if !defined (__GNUC__) && !defined (__GNUG__)
- # ifdef __STDC__
- unsigned short ntohs(unsigned int), htons(unsigned int);
- ***************
- *** 46,50 ****
- unsigned long ntohl(), htonl();
- # endif
- ! # include <sys/byteorder.h>
- #endif
-
- --- 47,52 ----
- unsigned long ntohl(), htonl();
- # endif
- ! # endif /* !defined (__GNUC__) && !defined (__GNUG__) */
- ! # include <sys/byteorder.h>
- #endif
-
-
-