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.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4ac6504560f5ef27 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2004-02-26 07:43:24 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: jamesamor@hotmail.com (James Amor) Newsgroups: comp.lang.ada Subject: Re: Little Endian -> Big Endian (Ada95 / GNAT) Date: 26 Feb 2004 07:43:24 -0800 Organization: http://groups.google.com Message-ID: References: NNTP-Posting-Host: 20.138.254.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1077810204 8424 127.0.0.1 (26 Feb 2004 15:43:24 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 26 Feb 2004 15:43:24 +0000 (UTC) Xref: archiver1.google.com comp.lang.ada:5859 Date: 2004-02-26T07:43:24-08:00 List-Id: Thanks for that, I'll have a look into that at some point. In the meantime I have implemented (some might say hacked) a conversion utility to rearrange the layout of the output, it seems to work ok! James "David C. Hoos" wrote in message news:... > "James Amor" wrote in message > news:bac31daa.0402250138.fc4ed92@posting.google.com... > > Hi, > > > > At present I am writing a tool to create a file which contains various > > extracted ELF symbols. The output data structure, a list of unsigned > > 32's, is to be used as part of an image on a PowerPC target. > > > > Problem: As it is compiled on Wintel the tool is producing an output > > in little endian and PowerPC is big endian! > > > > Question: How do I modify my code to write the output in big endian > > format? > > If you use Stream IO to write the data, then you can take advantage of > the solution the GNAT folks created for Distributed Systems (Annex E > of the Ada Lanuage Reference Manual). > > This solution is embodied in the glade supplement to gant. > > For example, if you're using gant-3.15p, the corresponding glade can > be found at ftp://ftp.cs.nyu.edu/pub/gnat/3.15p/glade > > Then, replace the file s-stratt.adb in your standard gnat distribution > with the one from the same version of glade, and re-compile and > rebuild the library files (.a), and you have what you want. Now, as > long as your types are declared the same on both platforms (with no > representation clauses) you will have platform-independence. > > I'm not sure why GNAT didn't do this from the beginning -- perhaps because > they didn't provide an implementation of the Distributed Systems Annex at > the beginning. Also, there is a small performance penalty paid for > shuffling bits around to achieve platform independence. > > Hope this helps.