From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,FREEMAIL_FROM, PP_MIME_FAKE_ASCII_TEXT autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,64599bfe530783cd X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-10-15 18:01:16 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!arclight.uoregon.edu!wn13feed!worldnet.att.net!bgtnsc05-news.ops.worldnet.att.net.POSTED!not-for-mail Newsgroups: comp.lang.ada Subject: Re: Any examples of Byte Ordering Functions From: James Rogers References: <1066243458.911546@master.nyc.kbcfp.com> Message-ID: User-Agent: Xnews/5.04.25 Date: Thu, 16 Oct 2003 01:01:16 GMT NNTP-Posting-Host: 12.86.34.240 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc05-news.ops.worldnet.att.net 1066266076 12.86.34.240 (Thu, 16 Oct 2003 01:01:16 GMT) NNTP-Posting-Date: Thu, 16 Oct 2003 01:01:16 GMT Organization: AT&T Worldnet Xref: archiver1.google.com comp.lang.ada:931 Date: 2003-10-16T01:01:16+00:00 List-Id: Hyman Rosen wrote in news:1066243458.911546@master.nyc.kbcfp.com: > Larry Kilgallen wrote: >>>Do Byte ordering functions (htonl, htons, ntohl, ntohs) exist in Ada? >> Your question seems to me to indicate you are trying to program in C >> using an Ada compiler. > > So what's the Ada way of writing portable code that > writes out and reads in 16-bit and 32-bit integers > for an external data source that has a defined byte > ordering? > To quote from the Ada Language Reference Manual section 13.5: For every specific record subtype S, the following attribute is defined: S�Bit_Order Denotes the bit ordering for the type of S. The value of this attribute is of type System.Bit_Order. Bit_Order may be specified for specific record types via an attribute_definition_clause; the expression of such a clause shall be static. A bit ordering is a method of interpreting the meaning of the storage place attributes. High_Order_First (known in the vernacular as big endian) means that the first bit of a storage element (bit 0) is the most significant bit (interpreting the sequence of bits that represent a component as an unsigned integer value). Low_Order_First (known in the vernacular as little endian) means the opposite: the first bit is the least significant. Jim Rogers