<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Compiler Issue on PA-RISC when Accessing Unaligned Packed Structures in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/compiler-issue-on-pa-risc-when-accessing-unaligned-packed/m-p/5043978#M95941</link>
    <description>Performance of this application is very important. I know the solution I got will have performance penalty. Any other suggestions?&lt;BR /&gt;&lt;BR /&gt;Thanks.&lt;BR /&gt;</description>
    <pubDate>Thu, 03 May 2007 09:52:02 GMT</pubDate>
    <dc:creator>Dekun Cao</dc:creator>
    <dc:date>2007-05-03T09:52:02Z</dc:date>
    <item>
      <title>Compiler Issue on PA-RISC when Accessing Unaligned Packed Structures</title>
      <link>https://community.hpe.com/t5/operating-system-linux/compiler-issue-on-pa-risc-when-accessing-unaligned-packed/m-p/5043973#M95936</link>
      <description>Compiler Issue on PA-RISC when Accessing Unaligned Packed Structures&lt;BR /&gt;&lt;BR /&gt;Background: we are attempting to minimize memory usage in areas where 10s of millions of items may exist. Using #pragma pack(1) to pack structures as much as possible and then these structures are being packed (along with other data) into large blocks of malloc'ed memory. Due to the variable nature of the other data, the structures may be aligned on any byte boundary, which should be ok as the pragma implies alignment of 1 as well.&lt;BR /&gt;&lt;BR /&gt;On PA-RISC machines, we have been seeing "Bus error (core dumped)" messages and have narrowed it down to alignment when doubly de-referencing pointers to that memory. i.e. if we align the structures it works, or if we copy the pointer and then de-reference it works too!&lt;BR /&gt;&lt;BR /&gt;Output of "uname -a" is: HP-UX dh-holly B.11.11 U 9000/800 3314646695 unlimited-user license&lt;BR /&gt;Compiler version     is: HP ANSI C++ B3910B A.03.65&lt;BR /&gt;&lt;BR /&gt;The same source code works OK on HP Itanium machine with&lt;BR /&gt;Output of "uname -a" is: HP-UX dh-ida B.11.23 U ia64 2988385317 unlimited-user license&lt;BR /&gt;Compiler version     is: HP aC++/ANSI C B3910B A.06.05 [Jul 25 2005]&lt;BR /&gt;&lt;BR /&gt;Build and Run Instruction: Build it with aCC and run it.&lt;BR /&gt;&lt;BR /&gt;/********** Source code *************/&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;#include &lt;STDLIB.H&gt;&lt;BR /&gt;&lt;BR /&gt;typedef struct&lt;BR /&gt;{&lt;BR /&gt;    int i;&lt;BR /&gt;} REF_LEVEL_T;&lt;BR /&gt;&lt;BR /&gt;#pragma pack 1&lt;BR /&gt;typedef struct&lt;BR /&gt;{&lt;BR /&gt;    REF_LEVEL_T *pRefLevel;&lt;BR /&gt;    char c;        // doesn't core if this is moved above pRefLevel&lt;BR /&gt;} REF_MEMBER_T;&lt;BR /&gt;#pragma pack 0&lt;BR /&gt;&lt;BR /&gt;typedef struct&lt;BR /&gt;{&lt;BR /&gt;    REF_MEMBER_T *pRefMember;&lt;BR /&gt;} MEMBER_T;&lt;BR /&gt;&lt;BR /&gt;int main()&lt;BR /&gt;{&lt;BR /&gt;    REF_LEVEL_T RefLevel;&lt;BR /&gt;    MEMBER_T Member;&lt;BR /&gt;&lt;BR /&gt;    RefLevel.i = 0;&lt;BR /&gt;&lt;BR /&gt;    char *p = (char *)malloc( 1000 );&lt;BR /&gt;&lt;BR /&gt;    for (int unalignBytes = 0; unalignBytes &amp;lt; 4; unalignBytes++)&lt;BR /&gt;    {&lt;BR /&gt;        fprintf( stderr, "trying unalignBytes %d\n", unalignBytes );&lt;BR /&gt;&lt;BR /&gt;        REF_MEMBER_T *pRefMember = (REF_MEMBER_T *)(p+unalignBytes);&lt;BR /&gt;&lt;BR /&gt;        pRefMember-&amp;gt;pRefLevel = &amp;amp;RefLevel;&lt;BR /&gt;&lt;BR /&gt;        Member.pRefMember = pRefMember;&lt;BR /&gt;&lt;BR /&gt;        REF_MEMBER_T *pTestRefMember = Member.pRefMember;&lt;BR /&gt;&lt;BR /&gt;        int x = pTestRefMember-&amp;gt;pRefLevel-&amp;gt;i;&lt;BR /&gt;&lt;BR /&gt;        fprintf( stderr, "passed first test\n" );&lt;BR /&gt;&lt;BR /&gt;        int y = (Member.pRefMember)-&amp;gt;pRefLevel-&amp;gt;i;&lt;BR /&gt;&lt;BR /&gt;        fprintf( stderr, "passed second test\n" );&lt;BR /&gt;    }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/STDLIB.H&gt;&lt;/STDIO.H&gt;</description>
      <pubDate>Wed, 02 May 2007 10:39:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/compiler-issue-on-pa-risc-when-accessing-unaligned-packed/m-p/5043973#M95936</guid>
      <dc:creator>Dekun Cao</dc:creator>
      <dc:date>2007-05-02T10:39:26Z</dc:date>
    </item>
    <item>
      <title>Re: Compiler Issue on PA-RISC when Accessing Unaligned Packed Structures</title>
      <link>https://community.hpe.com/t5/operating-system-linux/compiler-issue-on-pa-risc-when-accessing-unaligned-packed/m-p/5043974#M95937</link>
      <description>Shalom,&lt;BR /&gt;&lt;BR /&gt;You've followed the guidelines for making code work on Itanium and PA-RISC.&lt;BR /&gt;&lt;BR /&gt;Oracle couldn't do it, they maintain different code bases for Itanium versus PA-RISC&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Wed, 02 May 2007 13:00:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/compiler-issue-on-pa-risc-when-accessing-unaligned-packed/m-p/5043974#M95937</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2007-05-02T13:00:53Z</dc:date>
    </item>
    <item>
      <title>Re: Compiler Issue on PA-RISC when Accessing Unaligned Packed Structures</title>
      <link>https://community.hpe.com/t5/operating-system-linux/compiler-issue-on-pa-risc-when-accessing-unaligned-packed/m-p/5043975#M95938</link>
      <description>Certainly looks more like a compiler issue. The code compiles fine with the ANSI C compiler but core dumps using the aC++ compiler.</description>
      <pubDate>Wed, 02 May 2007 14:32:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/compiler-issue-on-pa-risc-when-accessing-unaligned-packed/m-p/5043975#M95938</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2007-05-02T14:32:34Z</dc:date>
    </item>
    <item>
      <title>Re: Compiler Issue on PA-RISC when Accessing Unaligned Packed Structures</title>
      <link>https://community.hpe.com/t5/operating-system-linux/compiler-issue-on-pa-risc-when-accessing-unaligned-packed/m-p/5043976#M95939</link>
      <description>Correction to my earlier post. When using aC++ supply the "+u1" switch on the command line for pointers to access non-natively aligned data.&lt;BR /&gt;&lt;BR /&gt;# aCC +u1 your_prog.c&lt;BR /&gt;&lt;BR /&gt;# ./a.out&lt;BR /&gt;trying unalignBytes 0&lt;BR /&gt;passed first test&lt;BR /&gt;passed second test&lt;BR /&gt;trying unalignBytes 1&lt;BR /&gt;passed first test&lt;BR /&gt;passed second test&lt;BR /&gt;trying unalignBytes 2&lt;BR /&gt;passed first test&lt;BR /&gt;passed second test&lt;BR /&gt;trying unalignBytes 3&lt;BR /&gt;passed first test&lt;BR /&gt;passed second test&lt;BR /&gt;&lt;BR /&gt;~cheers</description>
      <pubDate>Wed, 02 May 2007 14:50:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/compiler-issue-on-pa-risc-when-accessing-unaligned-packed/m-p/5043976#M95939</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2007-05-02T14:50:19Z</dc:date>
    </item>
    <item>
      <title>Re: Compiler Issue on PA-RISC when Accessing Unaligned Packed Structures</title>
      <link>https://community.hpe.com/t5/operating-system-linux/compiler-issue-on-pa-risc-when-accessing-unaligned-packed/m-p/5043977#M95940</link>
      <description>Is it a safe assumption that the performance of this application isn't terribly important?</description>
      <pubDate>Wed, 02 May 2007 19:37:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/compiler-issue-on-pa-risc-when-accessing-unaligned-packed/m-p/5043977#M95940</guid>
      <dc:creator>rick jones</dc:creator>
      <dc:date>2007-05-02T19:37:47Z</dc:date>
    </item>
    <item>
      <title>Re: Compiler Issue on PA-RISC when Accessing Unaligned Packed Structures</title>
      <link>https://community.hpe.com/t5/operating-system-linux/compiler-issue-on-pa-risc-when-accessing-unaligned-packed/m-p/5043978#M95941</link>
      <description>Performance of this application is very important. I know the solution I got will have performance penalty. Any other suggestions?&lt;BR /&gt;&lt;BR /&gt;Thanks.&lt;BR /&gt;</description>
      <pubDate>Thu, 03 May 2007 09:52:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/compiler-issue-on-pa-risc-when-accessing-unaligned-packed/m-p/5043978#M95941</guid>
      <dc:creator>Dekun Cao</dc:creator>
      <dc:date>2007-05-03T09:52:02Z</dc:date>
    </item>
    <item>
      <title>Re: Compiler Issue on PA-RISC when Accessing Unaligned Packed Structures</title>
      <link>https://community.hpe.com/t5/operating-system-linux/compiler-issue-on-pa-risc-when-accessing-unaligned-packed/m-p/5043979#M95942</link>
      <description>If the performance of this application is so very important then it makes no sense to go against the grain as the machine architecture is optimized for doing loads and stores on a word boundary. Better to waste memory than consume CPU cycles.</description>
      <pubDate>Thu, 03 May 2007 10:11:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/compiler-issue-on-pa-risc-when-accessing-unaligned-packed/m-p/5043979#M95942</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2007-05-03T10:11:08Z</dc:date>
    </item>
    <item>
      <title>Re: Compiler Issue on PA-RISC when Accessing Unaligned Packed Structures</title>
      <link>https://community.hpe.com/t5/operating-system-linux/compiler-issue-on-pa-risc-when-accessing-unaligned-packed/m-p/5043980#M95943</link>
      <description>I think I got all the information I need.&lt;BR /&gt;&lt;BR /&gt;Thank you all very much for the help.&lt;BR /&gt;&lt;BR /&gt;Dekun</description>
      <pubDate>Thu, 03 May 2007 10:13:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/compiler-issue-on-pa-risc-when-accessing-unaligned-packed/m-p/5043980#M95943</guid>
      <dc:creator>Dekun Cao</dc:creator>
      <dc:date>2007-05-03T10:13:55Z</dc:date>
    </item>
    <item>
      <title>Re: Compiler Issue on PA-RISC when Accessing Unaligned Packed Structures</title>
      <link>https://community.hpe.com/t5/operating-system-linux/compiler-issue-on-pa-risc-when-accessing-unaligned-packed/m-p/5043981#M95944</link>
      <description>I have got the solution.&lt;BR /&gt;&lt;BR /&gt;Thanks for the help</description>
      <pubDate>Thu, 03 May 2007 10:15:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/compiler-issue-on-pa-risc-when-accessing-unaligned-packed/m-p/5043981#M95944</guid>
      <dc:creator>Dekun Cao</dc:creator>
      <dc:date>2007-05-03T10:15:54Z</dc:date>
    </item>
  </channel>
</rss>

