[En-Nut-Discussion] Replacing compiler.h
harald.kipp at egnite.de
Fri Oct 5 17:36:10 CEST 2012
On 04.10.2012 19:11, Nathan Moore wrote:
>> What's your proposal to split this into different headers? Where to put
> Ignoring (for now) all of your other points, then something along the lines of:
> #if defined(__arm__)
> #include <arch/arm/intrinsics.h>
> #elif defined(__AVR__)
> #include <arch/avr/intrinsics.h>
> #elif defined(__AVR32__)
> #include <arch/avr32/intrinsics.h>
> #endif // arch intrinsics
> Just a thought.
Unfortunately it is not that simple. _NOP depends on the target and the
toolchain. So in arch/avr/intrinsics.h we still have
#define _NOP ...
#define _NOP ...
but when implementing more complicated features, we additionally get
library dependencies and more related #ifdefs.
Furthermore, intrinsics.h will be used by all toolchains and all runtime
libs and additional care is required not to spoil any of them.
This is often beyond the capabilities of a single developer, who is
familiar with one platform only.
Beside that, developers tend to blindly create copies of existing
implementations and add any required modification, but rarely remove
items, which are not required for their platform. That doesn't ease
maintenance. In the current trunk you'll find
Although this had been implemented for the H8/300, it is included by
every new platform, including the latest Cortex-m. Most of these
function are not used or even not available.
#define _NOP() __asm__ __volatile__("mov r0, r0 @ _NOP")
#elif defined(__AVR__) || defined(__AVR32__)
#define _NOP() __asm__ __volatile__("nop")
may look ugly, but I assume, that it is easier to extend by someone, who
is familiar with GCC and a single target. May be I should insert
error You must implement _NOP for your target.
More information about the En-Nut-Discussion