public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* RE: IRIX64 6.5, gcc 2.95.1:  weird inet_ntoa() behaviour
@ 2000-05-24 16:10 Billinghurst, David (CRTS)
  0 siblings, 0 replies; 3+ messages in thread
From: Billinghurst, David (CRTS) @ 2000-05-24 16:10 UTC (permalink / raw)
  To: 'Denis Vakatov'; +Cc: gcc

I thougth this was in the gcc FAQ, but .. 


From
http://toolbox.sgi.com/TasteOfDT/public/freeware/Installable/gcc-2.95.2.html
[From Jim Wilson] Gcc does not correctly pass/return structures which are
smaller than 16 bytes and which are not 8 bytes. The problem is very
involved and difficult to fix. It affects a number of other targets also,
but irix6 is affected the most, because it is a 64 bit target, and 4 byte
structures are common. The exact problem is that structures are being padded
at the wrong end, e.g. a 4 byte structure is loaded into the lower 4 bytes
of the register when it should be loaded into the upper 4 bytes of the
register. 
Gcc is consistent with itself, but not consistent with the SGI C compiler
[and the SGI supplied runtime libraries], so the only failures that can
happen are when there are library functions that take/return such
structures. There are very few such library functions. I can only recall
seeing a few of them: inet_ntoa, inet_aton, inet_lnaof, inet_netof, and
semctl.


+++++++++++++++++++++++++++++++++++++++++
(Mr) David Billinghurst
Comalco Research Centre
PO Box 316, Thomastown, Vic, Australia, 3074
Phone:	+61 3 9469 0642
FAX:	+61 3 9462 2700
Email:	David.Billinghurst@riotinto.com.au




> -----Original Message-----
> From:	Denis Vakatov [SMTP:vakatov@peony.nlm.nih.gov]
> Sent:	Thursday, 25 May 2000 0:52
> To:	gcc@gcc.gnu.org
> Cc:	vakatov@peony.nlm.nih.gov; lavr@peony.nlm.nih.gov
> Subject:	IRIX64 6.5, gcc 2.95.1:  weird inet_ntoa() behaviour
> 
> Hi,
> 
> See the attached code:
> 
> inet_ntoa() produces an invalid result when the following code
> compiled with GCC.
> However, it produces a correct result when compiled with native "cc".
> 
> ?
> Denis Vakatov
> Anton Lavrentiev
> 
> 
> --------------------------------------------------------------------------
> ---
> > uname -a
> IRIX64 muncher 6.5 10181058 IP27
> > gcc --version
> 2.95.1
> 
> > cat - > inet_ntoa.c
> #include <net/if.h>
> #include <arpa/inet.h>
> #include <netinet/in.h>
> #include <stdio.h>
> 
> int main(void)
> {
>   struct sockaddr_in sin;
> 
>   sin.sin_family = AF_INET;
>   sin.sin_port = 0x1234;
>   sin.sin_addr.s_addr = 0x820E1923;
> 
>   printf("%s\n", inet_ntoa(sin.sin_addr));
>   return 0;
> }
> 
> 
> > gcc inet_ntoa.c 
> > a.out
> 255.255.255.255
> 
> 
> > cc inet_ntoa.c 
> > a.out
> 130.14.25.35

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: IRIX64 6.5, gcc 2.95.1:  weird inet_ntoa() behaviour
  2000-05-24  7:51 Denis Vakatov
@ 2000-05-25  0:04 ` Philippe De Muyter
  0 siblings, 0 replies; 3+ messages in thread
From: Philippe De Muyter @ 2000-05-25  0:04 UTC (permalink / raw)
  To: Denis Vakatov; +Cc: gcc, vakatov, lavr

Denis Vakatov wrote :
> Hi,
> 
> See the attached code:
> 
> inet_ntoa() produces an invalid result when the following code
> compiled with GCC.
> However, it produces a correct result when compiled with native "cc".
> 
> ?
> Denis Vakatov
> Anton Lavrentiev
> 
> 
> -----------------------------------------------------------------------------
> > uname -a
> IRIX64 muncher 6.5 10181058 IP27
> > gcc --version
> 2.95.1
> 
> > cat - > inet_ntoa.c
> #include <net/if.h>
> #include <arpa/inet.h>
> #include <netinet/in.h>
> #include <stdio.h>
> 
> int main(void)
> {
>   struct sockaddr_in sin;
> 
>   sin.sin_family = AF_INET;
>   sin.sin_port = 0x1234;
>   sin.sin_addr.s_addr = 0x820E1923;
> 
>   printf("%s\n", inet_ntoa(sin.sin_addr));
>   return 0;
> }
> 
> 
> > gcc inet_ntoa.c 
> > a.out
> 255.255.255.255
> 
> 
> > cc inet_ntoa.c 
> > a.out
> 130.14.25.35
> 
I think you check the way small structs are passed as function arguments
in gcc versus cc. Probably does one compiler pass them in a register an the
other on the stack.

Philippe

^ permalink raw reply	[flat|nested] 3+ messages in thread

* IRIX64 6.5, gcc 2.95.1:  weird inet_ntoa() behaviour
@ 2000-05-24  7:51 Denis Vakatov
  2000-05-25  0:04 ` Philippe De Muyter
  0 siblings, 1 reply; 3+ messages in thread
From: Denis Vakatov @ 2000-05-24  7:51 UTC (permalink / raw)
  To: gcc; +Cc: vakatov, lavr

Hi,

See the attached code:

inet_ntoa() produces an invalid result when the following code
compiled with GCC.
However, it produces a correct result when compiled with native "cc".

?
Denis Vakatov
Anton Lavrentiev


-----------------------------------------------------------------------------
> uname -a
IRIX64 muncher 6.5 10181058 IP27
> gcc --version
2.95.1

> cat - > inet_ntoa.c
#include <net/if.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <stdio.h>

int main(void)
{
  struct sockaddr_in sin;

  sin.sin_family = AF_INET;
  sin.sin_port = 0x1234;
  sin.sin_addr.s_addr = 0x820E1923;

  printf("%s\n", inet_ntoa(sin.sin_addr));
  return 0;
}


> gcc inet_ntoa.c 
> a.out
255.255.255.255


> cc inet_ntoa.c 
> a.out
130.14.25.35

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2000-05-25  0:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-05-24 16:10 IRIX64 6.5, gcc 2.95.1: weird inet_ntoa() behaviour Billinghurst, David (CRTS)
  -- strict thread matches above, loose matches on Subject: below --
2000-05-24  7:51 Denis Vakatov
2000-05-25  0:04 ` Philippe De Muyter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).