home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.amiga.programmer
- Path: sparky!uunet!gatech!paladin.american.edu!howland.reston.ans.net!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!ames!purdue!mentor.cc.purdue.edu!pern.cc.purdue.edu!smb
- From: smb@pern.cc.purdue.edu (Scott M. Ballew)
- Subject: Re: What is htonl() ?
- Message-ID: <BzpxE3.95B@mentor.cc.purdue.edu>
- Sender: news@mentor.cc.purdue.edu (USENET News)
- Organization: Purdue University
- References: <72250@cup.portal.com> <TOO.92Dec23154643@cardhu.cs.hut.fi>
- Date: Wed, 23 Dec 1992 15:22:50 GMT
- Lines: 27
-
- In article <72250@cup.portal.com> Counsellor@cup.portal.com (Benjamin Counsellor Reich) writes:
-
- > I am stumped by one line of code:
-
- > *lmark = htonl(*lmark);
-
-
- To which too@cardhu.cs.hut.fi (Tomi Ollila) replies:
-
- >that function (Macro) return 32 bit value of its host byte order value in
- >network byte order. because 680x0 processor uses network byte order in 16
- >and 32 bit values (LITTLE ENDIAN) , that function is implemented as macro
- >whis does no conversion:
-
- >#define htonl(x) (x).
-
- >.. in that case you couild just remove the line and reduce a few cycles
- >from execution time, but it would cause combabitily problems.
-
- Any reasonable compiler/assembler will optimize these "few cycles" out
- of the finished binary. Please _leave_ those htonl() lines (and any
- ntohl(), htons(), ntohs() lines) in the source code! The only cost
- of leaving them will be during compilation. The cost of taking them
- out will be pain and suffering when the code is moved to a
- little-endian machine (the 680x0 family is big-endian, by the way).
-
- Scott
-