こんにちは。NoMaYです。別スレッド『Amazon FreeRTOSだそうです。ルネサスさんのRXは参加しないのかな?』でCC-RX用プロジェクトをGNURX用プロジェクトへ移植する作業をぽつりぽつりとやっていて、CC-RXの#pragma pack / #pragma packoption相当のものとしてGNURXで#pragma pack(1) / #pragma pack()が使えることに気付いたのですが、たまたま同じタイミングで更に別スレッドの作業をやっていてGNURXで#pragma address 変数名 アドレスという記述が使えるらしいことに気付き、調べているうちにFITが前提としているC99仕様では_Pragmaプリプロセッサ演算子(関連リンク参照)というものが使えることを知りました。_Pragmaを使うと以下のように#pragmaをプリプロセッサで扱うことが出来るようになり、FITのコンパイラ対応の効率化に役立ちそうかも知れないと思いました。
#define R_PRAGMA(...) _Pragma(#__VA_ARGS__)#if defined(__CCRX__)#define R_PRAGMA_PACK R_PRAGMA(pack)#define R_PRAGMA_PACKOPTION R_PRAGMA(packoption)#elif defined(__GNUC__)#define R_PRAGMA_PACK R_PRAGMA(pack(1))#define R_PRAGMA_PACKOPTION R_PRAGMA(pack())#endif
/* * EDMAC descriptor as defined in the hardware manual. It is * modified to support little endian CPU mode. */ R_PRAGMA_PACKtypedef struct DescriptorS{ __evenaccess uint32_t status; #if __LIT /* Little endian */ __evenaccess uint16_t size; __evenaccess uint16_t bufsize; #else /* Big endian */ __evenaccess uint16_t bufsize; __evenaccess uint16_t size; #endif uint8_t *buf_p; struct DescriptorS *next;} descriptor_t;/* * Ethernet buffer type definition. */typedef struct EtherBufferS{ uint8_t buffer[EMAC_NUM_BUFFERS][ETHER_CFG_BUFSIZE];} etherbuffer_t;略typedef struct pause_resolutionS{ pausemask_t mask; pauseval_t value; uint8_t transmit; uint8_t receive;} pauseresolution_t;typedef struct{ volatile struct st_etherc __evenaccess * petherc; /* ETHERC module */ volatile struct st_edmac __evenaccess * pedmac; /* EDMAC */ volatile uint32_t __evenaccess * preg_pir; uint32_t phy_address; uint8_t port_connect;} ether_control_t;typedef struct{ const ether_control_t * pether_control; uint32_t phy_access;} ether_ch_control_t; R_PRAGMA_PACKOPTION
[関連リンク]クローバーフィールド.jp/_pragma演算子を使ってみた。embedded.cloverfield.jp/2016/04/12/_pragma演算子ではまりました。infocenter.arm.com/help/topic/com.arm.doc.dui0472ij/BABDIJDD.htmlcpprefjp.github.io/lang/cpp11/pragma_operator.htmlGoogle検索: _Pragma[補足]gcc-renesas.comのドキュメントには記載無いがGCC本家のドキュメントの#pragma pack(1) / #pragma pack()が使えました。(実はiodefine.hでも使われていました。)GNURXgcc-renesas.com/migration-guides/rx/index.html#Compiler_directivesGCC本家gcc.gnu.org/onlinedocs/gcc-4.7.1/gcc/Structure_002dPacking-Pragmas.html#Structure_002dPacking-Pragmas
こんにちは。NoMaYです。モタモタしているうちに、こんなことになってしまいました。すべて私の不徳の致すところです。すみません。Release Notes: GCC 8.3.0.202204-GNURXllvm-gcc-renesas.com/release-notes/rx/latest/8.3.0.202204/release_notes.pdf「CHANGES IN THE GCC 8.3.0.202204-GNURXThis section describes the fixes made in the GCC 8.3.0.202204-GNURX release.GCC:1. [Improvement] DCMR register not getting saved/restored on function entry/exitIn the current release, the DCMR register will be saved on function entry and restored on function exit.2. [Improvement] Negated floats getting promoted to doubleIn previous releases, negation of floats resulted in their promotion to double, generating sub-optimal code if doubles were represented on 8 bytes.In the current release of the compiler, promotion will no longer happen when negating floats.3. [Deprecation] Automatic interrupt vector entry generationDeclaring interrupt handlers with a numeric argument resulted in the compiler creating additional symbols, which could be referenced in the linker script to initialize the interrupt vector.This feature is being deprecated and removed in a future release, since the current implementation does not work when paired with the -gc-section command line option.」