home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / sys / amiga / programm / 17744 < prev    next >
Encoding:
Text File  |  1992-12-23  |  1.5 KB  |  39 lines

  1. Newsgroups: comp.sys.amiga.programmer
  2. 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
  3. From: smb@pern.cc.purdue.edu (Scott M. Ballew)
  4. Subject: Re: What is htonl() ?
  5. Message-ID: <BzpxE3.95B@mentor.cc.purdue.edu>
  6. Sender: news@mentor.cc.purdue.edu (USENET News)
  7. Organization: Purdue University
  8. References: <72250@cup.portal.com> <TOO.92Dec23154643@cardhu.cs.hut.fi>
  9. Date: Wed, 23 Dec 1992 15:22:50 GMT
  10. Lines: 27
  11.  
  12. In article <72250@cup.portal.com> Counsellor@cup.portal.com (Benjamin Counsellor Reich) writes:
  13.  
  14. >   I am stumped by one line of code:
  15.  
  16. >    *lmark = htonl(*lmark);
  17.  
  18.  
  19. To which too@cardhu.cs.hut.fi (Tomi Ollila) replies:
  20.  
  21. >that function (Macro) return 32 bit value of its host byte order value in
  22. >network byte order. because 680x0 processor uses network byte order in 16
  23. >and 32 bit values (LITTLE ENDIAN) , that function is implemented as macro
  24. >whis does no conversion:
  25.  
  26. >#define htonl(x)    (x).
  27.  
  28. >.. in that case you couild just remove the line and reduce a few cycles
  29. >from execution time, but it would cause combabitily problems.
  30.  
  31. Any reasonable compiler/assembler will optimize these "few cycles" out
  32. of the finished binary.  Please _leave_ those htonl() lines (and any
  33. ntohl(), htons(), ntohs() lines) in the source code!  The only cost
  34. of leaving them will be during compilation.  The cost of taking them
  35. out will be pain and suffering when the code is moved to a
  36. little-endian machine (the 680x0 family is big-endian, by the way).
  37.  
  38. Scott
  39.