Hello. With gcc 2.2.2d, htonl, htons, ntohl, or ntohs,
everything works fine except when you #include <netinet/in.h>
and compile with -O. In this case, bytes/words are not swapped.
This can be demonstrated with the following program:
#include <netinet/in.h>
int main(void)
{
printf("%08x, %08x, %04x, %04x\n",
htonl(0x01020304), ntohl(0x01020304),
htons(0x0102), ntohs(0x0102));
return 0;
}
The output of this program should be
04030201, 04030201, 0201, 0201
If you compile this with gcc -O, you will get
01020304, 01020304, 0102, 0102
Although it seems that this should be an error with the inline
assembly routines defined in netinet/in.h, I'm not sure whether
that is really the problem or not. Either not including
<netinet/in.h> or not using -O produces correct results.
--
Jay Berkenbilt (ejb@ERA.COM)
Engineering Research Associates
| Linus Torvalds | Re: [PATCH 00/23] per device dirty throttling -v8 |
| Andi Kleen | [PATCH x86] [0/16] Various i386/x86-64 changes |
| serge | Re: 2.6.25-rc5-mm1 |
| Kamalesh Babulal | [BUG] Linux 2.6.25-rc2 - Kernel Ooops while running dbench |
git: | |
| Francis Moreau | Track /etc directory using Git |
| Abdelrazak Younes | Git-windows and git-svn? |
| Johan Herland | Re: People unaware of the importance of "git gc"? |
| Scott Chacon | git-scm.com |
| GVG GVG | ssh_exchange_identification: Connection closed by remote host |
| Richard Stallman | Real men don't attack straw men |
| Florin Andrei | firewall is very slow, something's wrong |
| qw er | OpenBSD sucks |
| David Miller | xfrm_state locking regression... |
| David Miller | [GIT]: Networking |
| Thomas Jarosch | Re: TCP connection stalls under 2.6.24.7 |
| Dave Jones | Re: odd RTL8139 quirk. |
