[En-Nut-Discussion] NutEnterCritical vs NutEnterCriticalAccess()

Nathan Moore nategoose at gmail.com
Tue Nov 17 15:33:27 CET 2015


How about something like the following for each target cpu?

#define NutCriticalUpdate( VARIABLE, VALUE)              \
     do {
         \
              size_t sz_ = sizeof(typeof(VARIABLE));            \
              size_t sza_ = sizeof(sig_atomic_t);                    \
              typeof(VARIABLE) * VP_ = &(VARIABLE);        \
              typeof(VALUE) VAL_ = (VALUE);                     \
              if (sz_ == sza_ && is_alligned(VP_)  {               \
                     *VP_ = VAL_;
 \
              } else if (sz_ < sza) {
  \
                   /* special consideration for cpu */               \
              } else {
       \
                   NutEnterCritical();
 \
                   *VP_ = VAL_;                                            \
                   NutExitCritical();
  \
              }
        \
       } while (0)


More information about the En-Nut-Discussion mailing list