----- Ursprüngliche Nachricht -----
Von: Peter Bigot
Gesendet am: 17.April.2012 13:44:39

>> That should work. =A0Like many people (and all serious coding standards),
>> I don't like putting brackets in macros - but that's your choice.

>Nothing wrong with brackets in macros.  Mismatched brackets that
>require macro pairs, now---that's a Bad Thing(tm).

Mismatching can be eliminated if a macro with funciton parameter is used.
like

#define ATOMIC(x) {backup=SR; {x}; SR=backup; NOP;}
(just a quick draft for concept)
used as 
ATOMIC(
  code
)

Yes, there are round brackets to be used, and not curled ones, but well... at 
least they are matched. ;)
My actual ATOMIC macro works a bit different: it increases acounter and clears 
GIE, and at the end it decrements the counter and 
sets GIE if it is zero. This way, the macros can be nested without overwriting 
the old storage.


>> In particular, you don't need them within interrupt functions (or other
>> places with interrupts disabled), and you don't need them to access data
>> that the cpu can access atomically (like 8-bit and 16-bit data).

>One clarification: you don't need a critical section around a data
>access that the mcu *does* atomically.  That it could (even should)
>have been atomic, and the compiler didn't make it so, should always be
>taken into account.  Trust, but verify.

Access to word members inside a packed struct is NOT done as a word read/write, 
but through a rather complex chainof operation, 
because the alignment of the struct and therefore of the member is unknown.
Well, better than a 16 bit access with the LSB of the address ignored :)

JMGross


------------------------------------------------------------------------------
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
_______________________________________________
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mspgcc-users

Reply via email to