[En-Nut-Discussion] Replacing compiler.h

Harald Kipp harald.kipp at egnite.de
Thu Oct 4 18:14:27 CEST 2012


Hi Nathan,

On 04.10.2012 16:29, Nathan Moore wrote:
>>  #ifndef _NOP
>>  #if defined(__arm__)
>>  #define _NOP() __asm__ __volatile__("mov r0, r0  @ _NOP")
>>  #elif defined(__AVR__) || defined(__AVR32__)
>>  #define _NOP() __asm__ __volatile__("nop")
>>  #endif
>>  #endif
>>
> 
> If other operational macros were added this code could get ugly.
> I think it may be cleaner if the actual code were place in different
> headers that were #included here.

I see this problem. The intention was to get it documented at one place.
Right now almost none of these target related items contain any
description. But OK, that could be solved in some other way.

In the meantime I recognized, that my initial assumption about two
dependencies was incomplete. As the example above shows, the CPU must be
taken into account as well. While avr-libc includes CPU support, other
runtime libs do not.

Some functions like _NOP(), where assembly code cannot be avoided,
depend on the toolchain and the CPU. They may even depend on the runtime
library. _NOP is a bad example, because it's too simple. Instead,
consider NutDelay(). It may be provided by the runtime lib. If not, our
own implementation depends on the toolchain and the CPU.

What's your proposal to split this into different headers? Where to put
_NOP?

Regards,

Harald






More information about the En-Nut-Discussion mailing list