Kasun Hewage | 3 May 2009 21:43
Picon

About macros of protothreads

Hello,

In the header file "pt.h", most of the macros like PT_WAIT_UNTIL,
PT_SPAWN, etc are implemented with a do-while loop. For an example:

#define PT_WAIT_UNTIL(pt, condition)	 \
  do {						         \
    LC_SET((pt)->lc);				         \
    if(!(condition)) {				         \
      return PT_WAITING;			         \
    }						                 \
  } while(0)

As it appears, the do-while loop does do nothing. I may be asking a
simple question. Is there any special reason to use such a do-while
loop here?

Thank you.

..:: කසුන් චන්ද්‍රනාත් ::..
..:: Kasun Chandranath ::..

------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance & Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
_______________________________________________
Contiki-developers mailing list
Contiki-developers <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/contiki-developers

Gmane