44a46,53
> #ifndef __GNUC__
> #define CMP(_a, _op, _b)                                           \
> (memcmp(&(_a), &(_b),                                              \
>   __builtin_choose_expr(sizeof(_a) == sizeof(_b),                  \
>                         sizeof(_a),                                \
>                         0)                                   \
> ) _op 0)
> #else
50a60
> #endif
54a65,72
> #ifndef __GNUC__
> #define CPY(_a, _b)                                           \
> (memcpy(&(_a), &(_b),                                              \
>   __builtin_choose_expr(sizeof(_a) == sizeof(_b),                  \
>                         sizeof(_a),                                \
>                         0)                                   \
> ))
> #else
60a79,80
> #endif
> 
73a94,100
> #ifndef __GNUC__
> struct _dummy_user_ref_struct
> {
>   void *user_ref;
> } _user_ref_var = { NULL },
>   *BRIDGE = &_user_ref_var, *PORT = &_user_ref_var;
> #else
78a106
> #endif
80a109,116
> #ifndef __GNUC__
> #define DEBUG(...) \
>   STP_OUT_logmsg(BRIDGE->user_ref, PORT->user_ref, STP_LOG_LEVEL_DEBUG, __VA_ARGS__)
> #define ERROR(...) \
>   STP_OUT_logmsg(BRIDGE->user_ref, PORT->user_ref, STP_LOG_LEVEL_ERROR, __VA_ARGS__)
> #define ABORT(...) \
>   { ERROR(__VA_ARGS__);}
> #else
86a123
> #endif
104a142,144
> #ifndef __GNUC__
> #define STATES(...) enum _CAT(STM_NAME, states) { STN(BEGIN), __VA_ARGS__ }
> #else
105a146
> #endif
107a149,158
> #ifndef __GNUC__
> #define TR(_cond, _new_state) \
> {                                                                           \
>   if (_cond) {                                                               \
>     new_state = STN(_new_state);                                             \
>     DEBUG("%s: Transition to state %s\n", _STR(STM_NAME), #_new_state);      \
>     goto STM_LABEL(_new_state);                                              \
>   }                                                                          \
> }
> #else
115a167
> #endif
122a175,180
> #ifndef __GNUC__
> #define GC(...)      \
>          global_conditions:      \
>              __VA_ARGS__         \
>              return new_state
> #else
126a185
> #endif
128a188,194
> #ifndef __GNUC__
> #define BG(...)                                              \
>          case STN(BEGIN):                                                \
>              __VA_ARGS__                                                \
>              ABORT("%s: No where to go from BEGIN\n", _STR(STM_NAME));   \
>              return -1
> #else
133a200
> #endif
144a212,215
> #ifndef __GNUC__
> #define STM_FUNC_DECL(_type, ...) \
>   int _type(int state, int single_step, __VA_ARGS__)
> #else
146a218,219
> #endif
> 
150a224,236
> #ifndef __GNUC__
> #define STM(_args, ...)                                 \
> static STM_FUNC_DECL(STM_FUNC(STM_NAME), _args)                  \
> {                                                                \
>   int new_state = 0;                                             \
>   switch (state) {                                               \
>     __VA_ARGS__                                                  \
>       default:                                                   \
>     ABORT("%s: Got unknown state %d\n", __func__, state);        \
>     return -1;                                                   \
>   }                                                              \
> }
> #else
161a248,249
> #endif
> 
164a253,262
> #ifndef __GNUC__
> #define STM_RUN(_state, _transitioned, _func, ...) \
> {                                                               \
>   int new_state = _func(*_state, 0/*no single step*/, __VA_ARGS__);    \
>   if (new_state > 0) {                                           \
>     *_state = new_state;                                         \
>     *_transitioned = TRUE;                                       \
>   }                                                              \
> }
> #else
172a271
> #endif
173a273,278
> #ifndef __GNUC__
> #define STM_BEGIN(_state, _func, ...) \
> {                                                               \
>   *_state = _func(0/*BEGIN*/, 1/*single step*/, __VA_ARGS__);          \
> }
> #else
177a283,284
> #endif
> 
191c298,301
< typedef struct _BridgeId {
---
> #ifdef __ICCARM__
> #pragma pack(1)
> #endif
> typedef COMPILER_INLINE_PACK struct _BridgeId {
195,196c305,312
< 
< typedef struct {
---
> #ifdef __ICCARM__
> #pragma pack()
> #endif
> 
> #ifdef __ICCARM__
> #pragma pack(1)
> #endif
> typedef COMPILER_INLINE_PACK struct _PathCost{
198a315,317
> #ifdef __ICCARM__
> #pragma pack()
> #endif
206a326,337
> #ifndef __GNUC__
> static inline PathCost path_cost_add(PathCost x, uint y)
> {
>   PathCost r;
> 
>   uint z = y +
>     (x.cost[0] << 24) + (x.cost[1] << 16) + (x.cost[2] << 8) + (x.cost[3]);
> 
>   r.cost[0] = (z >> 24);
>   r.cost[1] = (z >> 16) & 0xff;
>   r.cost[2] = (z >> 8) & 0xff;
>   r.cost[3] = z & 0xff;
207a339,341
>   return r;
> }
> #else
222c356,361
< typedef struct _PortId {
---
> #endif
> 
> #ifdef __ICCARM__
> #pragma pack(1)
> #endif
> typedef COMPILER_INLINE_PACK struct _PortId {
224a364,366
> #ifdef __ICCARM__
> #pragma pack()
> #endif
231c373,376
< typedef struct _PriorityVector
---
> #ifdef __ICCARM__
> #pragma pack(1)
> #endif
> typedef COMPILER_INLINE_PACK struct _PriorityVector
239c384,390
< 
---
> #ifdef __ICCARM__
> #pragma pack()
> #endif
> 
> #ifdef __ICCARM__
> #pragma pack(1)
> #endif
241c392
< typedef struct _PriorityVector4
---
> typedef COMPILER_INLINE_PACK struct _PriorityVector4
248c399,401
< 
---
> #ifdef __ICCARM__
> #pragma pack()
> #endif
317c470,473
< typedef struct _RawBPDU
---
> #ifdef __ICCARM__
> #pragma pack(1)
> #endif
> typedef COMPILER_INLINE_PACK struct _RawBPDU
321a478
> #ifdef __GNUC__
323a481
> #endif
341a500
> #ifdef __GNUC__
343c502
< 
---
> #endif
345a505
> #ifdef __GNUC__
347c507
< 
---
> #endif
348a509,511
> #ifdef __ICCARM__
> #pragma pack()
> #endif
350a514,519
> #ifndef __GNU_C
> // Markers not allowed
> #define TCN_END_SIZE_BYTES    4
> #define CONFIG_END_SIZE_BYTES (sizeof(RawBPDU) - sizeof(uchar))
> #define RST_END_SIZE_BYTES    (sizeof(RawBPDU))
> #endif
827a997,1010
> #ifndef __GNUC__
> static bool g_ForAllPortBool;
> #define ForAllPort(result, expr)                                                     \
> {                                                                           \
>   Port *FPORT;                                                               \
>   bool res = TRUE;                                                           \
>   for (FPORT = BRIDGE->port_list; FPORT != NULL; FPORT = FPORT->port_next)   \
>     if (!(expr)) {                                                           \
>       res = FALSE;                                                           \
>       break;                                                                 \
>     }                                                                        \
>   result = res;                                                                       \
> }
> #else
838a1022
> #endif
843a1028,1035
> #ifndef __GNUC__
> #define ForAllPortDo(...)                                          \
> {                                                                           \
>   Port *FPORT;                                                               \
>   for (FPORT = BRIDGE->port_list; FPORT != NULL; FPORT = FPORT->port_next)   \
>     { __VA_ARGS__ }                                                           \
> }
> #else
849a1042
> #endif
860c1053
< #define allSynced ForAllPort(FPORT->_synced || FPORT->_role == RootPort)
---
> #define allSynced(result) ForAllPort(result, FPORT->_synced || FPORT->_role == RootPort)
881c1074
< #define reRooted ForAllPort(FPORT == PORT || FPORT->_rrWhile == 0)
---
> #define reRooted(result) ForAllPort(result, FPORT == PORT || FPORT->_rrWhile == 0)
970a1164,1168
> #ifndef __GNUC__
> #define set_tcWhile(_val) \
> { uint _oldval = tcWhile; tcWhile = _val; \
>    update_tcWhile_count(BRIDGE_ARGS, (tcWhile?1:0) - (_oldval?1:0)); }
> #else
974c1172
< 
---
> #endif
1116c1314,1316
<   if (ForAllPort(FPORT->_reselect == FALSE))
---
>   bool temp;
>   ForAllPort(temp, FPORT->_reselect == FALSE);
>   if (temp)
1169a1370
>   int flags;
1177c1378
<   int flags = 0;
---
>   flags = 0;
1184a1386,1388
> #ifndef __GNUC__
>   STP_OUT_tx_bpdu(PORT->user_ref, &b, CONFIG_END_SIZE_BYTES);
> #else
1185a1390
> #endif
1191a1397,1398
>   int flags;
>   int r;
1199c1406
<   int flags = 0;
---
>   flags = 0;
1201c1408
<   int r = role;
---
>   r = role;
1220a1428,1430
> #ifndef __GNUC__
>   STP_OUT_tx_bpdu(PORT->user_ref, &b, RST_END_SIZE_BYTES);
> #else
1221a1432
> #endif
1233a1445,1447
> #ifndef __GNUC__
>   STP_OUT_tx_bpdu(PORT->user_ref, &b, TCN_END_SIZE_BYTES);
> #else
1234a1449,1450
> #endif
> 
1422c1638
<     GC();
---
>     GC(;);
1505c1721
<     GC();
---
>     GC(;);
1549c1765
<     GC();
---
>     GC(;);
1589c1805
<     GC();
---
>     GC(;);
1775c1991
<     GC();
---
>     GC(;);
1792c2008,2009
<        TR(!ForAllPort(!FPORT->_reselect), ROLE_SELECTION);
---
>        ForAllPort(g_ForAllPortBool,!FPORT->_reselect);
>        TR(!g_ForAllPortBool, ROLE_SELECTION);
1938c2155,2156
<        TR(((allSynced && !agree) || (proposed && agree)) && xc, ROOT_AGREED);
---
>        allSynced(g_ForAllPortBool);
>        TR(((g_ForAllPortBool && !agree) || (proposed && agree)) && xc, ROOT_AGREED);
1941a2160
>        reRooted(g_ForAllPortBool);
1943c2162
<            ((reRooted && (rbWhile == 0)) && (rstpVersion))) && !learn && xc,
---
>            ((g_ForAllPortBool && (rbWhile == 0)) && (rstpVersion))) && !learn && xc,
1945c2164,2165
<        TR((fdWhile == 0 || ((reRooted && (rbWhile == 0)) && (rstpVersion)))
---
>        reRooted(g_ForAllPortBool);
>        TR((fdWhile == 0 || ((g_ForAllPortBool && (rbWhile == 0)) && (rstpVersion)))
2061c2281,2282
<        TR(((allSynced && !agree) || (proposed && agree)) && xc,
---
>        allSynced(g_ForAllPortBool);
>        TR(((g_ForAllPortBool && !agree) || (proposed && agree)) && xc,
2083c2304
<     GC();
---
>     GC(;);
2128c2349
<     GC();
---
>     GC(;);
2250a2472,2474
>   int i;
>   bool transitioned;
> 
2254,2255d2477
<   int i;
<   bool transitioned;
2270a2493
>   int i;
2274d2496
<   int i;
2522a2745,2747
>   Times new_times;
>   bool set_times;
> 
2543,2544c2768,2769
<   Times new_times = BridgeTimes;
<   bool set_times = FALSE;
---
>   new_times = BridgeTimes;
>   set_times = FALSE;
2784a3010,3019
> #ifndef __GNUC__
> #define SET_CFG(_type, _arg, _field, _value, _retval) \
> {                                                           \
>   STP_ ## _type ## Config cfg;                               \
>   ZERO(cfg);                                                 \
>   cfg._type ## _ ## _field = _value;                         \
>   cfg. set_ ## _type ## _ ## _field = 1;                     \
>   _retval = STP_IN_set_ ## _type ## _config(_arg, &cfg);               \
> }
> #else
2792a3028
> #endif
2798c3034,3036
<   return SET_CFG(bridge, BRIDGE, protocol_version, version);
---
>   bool retval;
>   SET_CFG(bridge, BRIDGE, protocol_version, version, retval);
>   return retval;
2803c3041,3043
<   return SET_CFG(bridge, BRIDGE, address, *addr);
---
>   bool retval;
>   SET_CFG(bridge, BRIDGE, address, *addr, retval);
>   return retval;
2808c3048,3050
<   return SET_CFG(bridge, BRIDGE, priority, priority);
---
>   bool retval;
>   SET_CFG(bridge, BRIDGE, priority, priority, retval);
>   return retval;
2813c3055,3057
<   return SET_CFG(bridge, BRIDGE, hello_time, hello_time);
---
>   bool retval;
>   SET_CFG(bridge, BRIDGE, hello_time, hello_time, retval);
>   return retval;
2818c3062,3064
<   return SET_CFG(bridge, BRIDGE, max_age, max_age);
---
>   bool retval;
>   SET_CFG(bridge, BRIDGE, max_age, max_age, retval);
>   return retval;
2824c3070,3072
<   return SET_CFG(bridge, BRIDGE, forward_delay, fwd_delay);
---
>   bool retval;
>   SET_CFG(bridge, BRIDGE, forward_delay, fwd_delay, retval);
>   return retval;
2830c3078,3080
<   return SET_CFG(bridge, BRIDGE, tx_hold_count, count);
---
>   bool retval;
>   SET_CFG(bridge, BRIDGE, tx_hold_count, count, retval);
>   return retval;
2838c3088,3090
<   return SET_CFG(port, PORT, priority, priority);
---
>   bool retval;
>   SET_CFG(port, PORT, priority, priority, retval);
>   return retval;
2843c3095,3097
<   return SET_CFG(port, PORT, pathcost, pcost);
---
>   bool retval;
>   SET_CFG(port, PORT, pathcost, pcost, retval);
>   return retval;
2849c3103,3105
<   return SET_CFG(port, PORT, admin_edge, edge);
---
>   bool retval;
>   SET_CFG(port, PORT, admin_edge, edge, retval);
>   return retval;
2854c3110,3112
<   return SET_CFG(port, PORT, auto_edge, edge);
---
>   bool retval;
>   SET_CFG(port, PORT, auto_edge, edge, retval);
>   return retval;
2859c3117,3119
<   return SET_CFG(port, PORT, admin_p2p, p2p);
---
>   bool retval;
>   SET_CFG(port, PORT, admin_p2p, p2p, retval);
>   return retval;
2959a3220
>   Bridge *BRIDGE;
2969c3230
<   Bridge *BRIDGE = b;
---
>   BRIDGE = b;
3005a3267,3269
>   Port *p;
>   Port *PORT;
> 
3011c3275
<   Port *p = STP_OUT_mem_zalloc(sizeof(Port));
---
>   p = STP_OUT_mem_zalloc(sizeof(Port));
3024c3288
<   Port *PORT = p;
---
>   PORT = p;
3050a3315
>   Port **prev; 
3059c3324
<   Port **prev = &BRIDGE->port_list;
---
>   prev = &BRIDGE->port_list;
