<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.0.4417.0">
<TITLE>do ... while(0) in macros</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->
<P><SPAN LANG="zh-cn"><FONT SIZE=2 FACE="Arial">There are many macros in RTEMS written like the following code:</FONT></SPAN>
</P>
<P><SPAN LANG="zh-cn"><FONT SIZE=2 FACE="Arial"> do { \</FONT></SPAN>
<BR><SPAN LANG="zh-cn"><FONT SIZE=2 FACE="Arial"> unsigned32 _stack; \</FONT></SPAN>
<BR><SPAN LANG="zh-cn"><FONT SIZE=2 FACE="Arial"> \</FONT></SPAN>
<BR><SPAN LANG="zh-cn"><FONT SIZE=2 FACE="Arial"> if ( (_isr) ) (_the_context)->eflags = CPU_EFLAGS_INTERRUPTS_OFF; \</FONT></SPAN>
<BR><SPAN LANG="zh-cn"><FONT SIZE=2 FACE="Arial"> else (_the_context)->eflags = CPU_EFLAGS_INTERRUPTS_ON; \</FONT></SPAN>
<BR><SPAN LANG="zh-cn"><FONT SIZE=2 FACE="Arial"> \</FONT></SPAN>
<BR><SPAN LANG="zh-cn"><FONT SIZE=2 FACE="Arial"> _stack = ((unsigned32)(_stack_base)) + (_size) - 4; \</FONT></SPAN>
<BR><SPAN LANG="zh-cn"><FONT SIZE=2 FACE="Arial"> \</FONT></SPAN>
<BR><SPAN LANG="zh-cn"><FONT SIZE=2 FACE="Arial"> *((proc_ptr *)(_stack)) = (_entry_point); \</FONT></SPAN>
<BR><SPAN LANG="zh-cn"><FONT SIZE=2 FACE="Arial"> (_the_context)->ebp = (void *) _stack; \</FONT></SPAN>
<BR><SPAN LANG="zh-cn"><FONT SIZE=2 FACE="Arial"> (_the_context)->esp = (void *) _stack; \</FONT></SPAN>
<BR><SPAN LANG="zh-cn"><FONT SIZE=2 FACE="Arial"> } while (0)</FONT></SPAN>
</P>
<P><SPAN LANG="zh-cn"><FONT SIZE=2 FACE="Arial">Could anybody explain the purpose of the "do ... while(0)" ?</FONT></SPAN>
</P>
<P><SPAN LANG="zh-cn"><FONT SIZE=2 FACE="Arial">Thanks in advance,</FONT></SPAN>
</P>
<P><SPAN LANG="zh-cn"><FONT SIZE=2 FACE="Arial">Guo</FONT></SPAN>
</P>
</BODY>
</HTML>