home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / gnu / gcc / bug / 3040 < prev    next >
Encoding:
Text File  |  1992-12-22  |  4.1 KB  |  118 lines

  1. Newsgroups: gnu.gcc.bug
  2. Path: sparky!uunet!cis.ohio-state.edu!sedona.intel.com!tmcconne
  3. From: tmcconne@sedona.intel.com (Tom McConnell)
  4. Subject: gcc-2.3.2 / NCR-3350 SVR4.02 <sys/endian.h> bug
  5. Message-ID: <9212221659.AA31542@thunder.intel.com>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: GNUs Not Usenet
  8. Distribution: gnu
  9. Date: Tue, 22 Dec 1992 02:59:24 GMT
  10. Approved: bug-gcc@prep.ai.mit.edu
  11. Lines: 105
  12.  
  13.   Howdy.
  14.  
  15.   I have finished porting gcc-2.3.2 to the NCR-3350, and used it to compile
  16. X11R5p21 and libg++-2.3. This report concerns the <sys/endian.h> include file.
  17.  
  18.     Cheers,
  19.  
  20.     Tom McConnell
  21.  
  22.  Tom McConnell          |     Internet: tmcconne@sedona.intel.com
  23.  Intel, Corp. C3-91     |     Phone: (602)-554-8229
  24.  5000 W. Chandler Blvd. | The opinions expressed are my own. No one in 
  25.  Chandler, AZ  85226    | their right mind would claim them.
  26.  
  27. Problem: The definition of "htonl" and "ntohl" differ between <sys/endian.h>
  28.         and <sys/byteorder.h>.
  29.  
  30. Program: endian.c
  31.  
  32. /* Test <endian.h> */
  33. #include <stdio.h>
  34. #include <netinet/in.h>
  35. main()
  36. {
  37.     printf("<endian.h> \n");
  38. }
  39.  
  40. Example compile:
  41.  
  42. gcc -v    -c endian.c -o endian.o
  43. Reading specs from /stor/gnu/iAWS/lib/gcc-lib/ncr3000/2.3.2/specs
  44. gcc version 2.3.2
  45.  /stor/gnu/iAWS/lib/gcc-lib/ncr3000/2.3.2/cpp -lang-c -v -undef -D__GNUC__=2
  46.  -Di386 -Dunix -D__svr4__ -D__i386__ -D__unix__ -D__svr4__ -D__i386 -D__unix
  47.  -D__svr4__ -Asystem(unix) -Acpu(i386) -Amachine(i386) endian.c
  48.  /var/tmp/cca003Su.i
  49. GNU CPP version 2.3.2 (i386 System V Release 4)
  50.  /stor/gnu/iAWS/lib/gcc-lib/ncr3000/2.3.2/cc1 /var/tmp/cca003Su.i -quiet
  51.  -dumpbase endian.c -version -o /var/tmp/cca003Su.s
  52. GNU C version 2.3.2 (i386 System V Release 4) compiled by GNU C version 2.3.2.
  53. In file included from
  54.  /stor/gnu/iAWS/lib/gcc-lib/ncr3000/2.3.2/include/sys/endian.h:48, from
  55.  /stor/gnu/iAWS/lib/gcc-lib/ncr3000/2.3.2/include/netinet/in.h:42, from
  56.  endian.c:3:
  57. /stor/gnu/iAWS/lib/gcc-lib/ncr3000/2.3.2/include/sys/byteorder.h:27:
  58.  conflicting types for `htonl'
  59. /stor/gnu/iAWS/lib/gcc-lib/ncr3000/2.3.2/include/sys/endian.h:43:
  60.  previous declaration of `htonl'
  61. /stor/gnu/iAWS/lib/gcc-lib/ncr3000/2.3.2/include/sys/byteorder.h:28: warning:
  62.  static declaration for `htons' follows non-static
  63. /stor/gnu/iAWS/lib/gcc-lib/ncr3000/2.3.2/include/sys/byteorder.h:29:
  64.  conflicting types for `ntohl'
  65. /stor/gnu/iAWS/lib/gcc-lib/ncr3000/2.3.2/include/sys/endian.h:43:
  66.  previous declaration of `ntohl'
  67. /stor/gnu/iAWS/lib/gcc-lib/ncr3000/2.3.2/include/sys/byteorder.h:30: warning:
  68.  static declaration for `ntohs' follows non-static
  69. gmake: *** [endian.o] Error 1
  70.  
  71. Analysis: There are really two problems here: htonl() and ntohl() in endian.h
  72.          pass different parameters (unsigned int) than htonl() and ntohl()
  73.          in byteorder.h (unsigned long). Since the gcc-2.3.2 supplied
  74.          byteorder.h also includes the assembly code, the easy way out was 
  75.          to assume gcc-2.3.2 knew what it was doing. This may not be a good
  76.          assumption, but it seems to work.
  77.  
  78.           The second problem is that if both <sys/endian.h> and
  79.          <sys/byteorder.h> define the number conversion routines (ntohl, etc.),
  80.          the linker will complain about "fatal error: symbol `htonl`
  81.          multiply-defined".
  82.  
  83. Solution: Modify <sys/endian.h> so that if gcc is being used, do not define
  84.          the number conversion routines. Instead, rely on <sys/byteorder.h>
  85.          to define them.
  86.  
  87. Patch:
  88. This patch file was created on Tue Dec 22 09:38:19 MST 1992.
  89.  
  90. The top level directory was /a/stor/gnu/iAWS/lib/gcc-lib/ncr3000/2.3.2/include
  91.  
  92.  
  93. *** ./sys/endian.h_orig    Tue Dec 22 09:37:35 1992
  94. --- ./sys/endian.h    Mon Dec 21 20:35:10 1992
  95. ***************
  96. *** 39,42 ****
  97. --- 39,43 ----
  98.   #define    htons(x)    (x)
  99.   #else
  100. + #   if !defined (__GNUC__) && !defined (__GNUG__)
  101.   #    ifdef    __STDC__
  102.           unsigned short    ntohs(unsigned int), htons(unsigned int);
  103. ***************
  104. *** 46,50 ****
  105.           unsigned long    ntohl(), htonl();
  106.   #    endif
  107. ! #        include    <sys/byteorder.h>
  108.   #endif
  109.   
  110. --- 47,52 ----
  111.           unsigned long    ntohl(), htonl();
  112.   #    endif
  113. ! #   endif /* !defined (__GNUC__) && !defined (__GNUG__) */
  114. ! #   include    <sys/byteorder.h>
  115.   #endif
  116.   
  117.  
  118.