This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler: clpru 2.2.1 does not recognize "#pragma pack" ?

Tool/software: TI C/C++ Compiler

Paltform is BeagleBone Black under Debian, I have a ARM/PRU project.

I've a struct in shared memory, to communicate with the ARM under Debian. I must  force the struct to same byte layout under ARM and under PRU, so I used "#pragma pack"

<codesnippet>
/***** start of shared structs *****/
#pragma pack(4)


typedef struct {
    uint32_t    addr ; // register 0..7
    uint32_t    bitmask ; // change only these bits in register
    uint32_t    val ; // value set/get.
} mailbox_buslatch_t;
</codesnippet>

But clpru says

"../common/mailbox.h", line 28: warning #163-D: unrecognized #pragma

According to manual, #pragma pack(4) is supported.

Full call line:

/home/joerg/retrocmp/dec/pdp11/UniBone/91_3rd_party/pru-c-compile/ti-cgt-pru_2.2.1//bin/clpru --include_path=/home/joerg/retrocmp/dec/pdp11/UniBone/91_3rd_party/pru-c-compile/ti-cgt-pru_2.2.1//include --include_path=/home/joerg/retrocmp/dec/pdp11/UniBone/91_3rd_party/pru-c-compile/pru-software-support-package/include --include_path=/home/joerg/retrocmp/dec/pdp11/UniBone/91_3rd_party/pru-c-compile/pru-software-support-package/include/am335x --include_path=../common -v3 -O3 --auto_inline --display_error_number --endian=little --hardware_mac=on --obj_directory=../bin-bbb --pp_directory=../bin-bbb -ppd -ppa --c_src_interlist --optimizer_interlist --absolute_listing -fe ../bin-bbb/pru1_main.object pru1_main.c
"../common/mailbox.h", line 28: warning #163-D: unrecognized #pragma

Thnaks fpr caring

Joerg Hoppe

  • On PRU, all types are byte aligned.  See the section titled Data Types in the PRU compiler manual.  Therefore, all structs are packed, and there is no need for #pragma pack.  

    This is an error in the manual.  To have that addressed, I filed CODEGEN-4832 in the SDOWP system.  You are welcome to follow it with the SDOWP link below in my signature.

    Thanks and regards,

    -George

  • George,

    thanks for the quick answer. Chapter 6.2.1 makes it clear.

    I understand "always byte align" this way : In
    struct {
         uint8_t   a;
         uint32_t b;
    } testvar ;

    an access to testvar.b crosses a 32bit word border. This is a legal situation, but may be an performance issue.

    Can the CPU handle "word crossing" accesses easily, or should I have all struct members as uint32_t to avoid this situation?


    best regards,

    Joerg

  • The information in this post is later found to be incorrect.  It is kept here only for continuity of the original thread.  -George

    Joierg Hoppe said:
    This is a legal situation, but may be an performance issue.

    We are not aware of any performance issues associated with non-aligned memory access.

    Thanks and regards,

    -George

  • Unfortunately, my last post is incorrect.  There is a performance penalty in some cases.

    With regard to accesses of these scalar types ...

    • char - no penalty
    • short, int, long, float, pointers - 1 cycle penalty if it crosses a 4-byte boundary
    • long long, double - 1 cycle penalty if it is not aligned on a 4-byte boundary

    At the present time, none of these data types are aligned.

    Thanks and regards,

    -George