Article View: comp.protocols.tcp-ip
Article #8036Help about this code?
From: Seda Oezses
Date: Tue, 26 Dec 1995 22:06
Date: Tue, 26 Dec 1995 22:06
48 lines
1599 bytes
1599 bytes
------------
#include ......
unsigned char *buff;
#define MAXBUFF 128
#define LDSHORT(addr) (ntohs (*( (unsigned short *) (addr) )))
#define STSHORT(sval, addr) (*( (unsigned short *)(addr)) = htons(sval))
void main(void)
{
unsigned short i;
buff = (unsigned char *) calloc(MAXBUFF, sizeof(unsigned char));
STSHORT(10, buff + 1);
i = LDSHORT(buff + 1);
printf("%d\n", i);
}
-----------
Executing the above program gave three different results on three different
processors and operating systems;
- On a SUN SPARCclasic (Solaris 2.4) the result was a Bus error.
- On a DECStation 5500 (ULTRIX 4.4) program run and printed 10 but with a
message "Fixed up unaligned data access for pid 25977 (a.out) at pc 0x400678".
- On a RISC/6000 (AIX ??) program run without an error or warning.
Do you have any idea about why this little code produce such different results on
different processors?
--
("\''/").___..--'''"-._
`9_ 9 ) `-. ( ).`-.__.`) S E D A O Z S E S
(_Y_.)' ._ ) `._ `. ``-..-'
_..`--'_..-_/ /--'_.' .' e8927426@fbma.tuwien.ac.at
(il).-'' ((i).' ((i.-'
Technical Details
Message-ID:
<4bprle$n2k@news.tuwien.ac.at>Path:
arc1-ca.pugleaf.net!fbma.tuwien.ac.at!e8927426Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!fbma.tuwien.ac.at!e8927426 From: e8927426@fbma.tuwien.ac.at (Seda Oezses) Newsgroups: comp.protocols.tcp-ip,comp.lang.c Subject: Help about this code? Date: 26 Dec 1995 22:06:38 GMT Organization: Vienna University of Technology, Austria Message-ID: <4bprle$n2k@news.tuwien.ac.at> NNTP-Posting-Host: fbma.tuwien.ac.at X-Newsreader: TIN [version 1.2 PL2]