<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <!--Converted with LaTeX2HTML 2008 (1.71) original version by: Nikos Drakos, CBLU, University of Leeds * revised and updated by: Marcus Hennecke, Ross Moore, Herb Swan * with significant contributions from: Jens Lippmann, Marek Rouchal, Martin Wilck and others --> <HTML> <HEAD> <TITLE>3.10.1 Critical Functions and Critical Statements</TITLE> <META NAME="description" CONTENT="3.10.1 Critical Functions and Critical Statements"> <META NAME="keywords" CONTENT="sdccman"> <META NAME="resource-type" CONTENT="document"> <META NAME="distribution" CONTENT="global"> <META NAME="Generator" CONTENT="LaTeX2HTML v2008"> <META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css"> <LINK REL="STYLESHEET" HREF="sdccman.css"> <LINK REL="next" HREF="node74.html"> <LINK REL="previous" HREF="node72.html"> <LINK REL="up" HREF="node72.html"> <LINK REL="next" HREF="node74.html"> </HEAD> <BODY > <!--Navigation Panel--> <A NAME="tex2html1779" HREF="node74.html"> <IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> <A NAME="tex2html1773" HREF="node72.html"> <IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> <A NAME="tex2html1767" HREF="node72.html"> <IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> <A NAME="tex2html1775" HREF="node1.html"> <IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A> <A NAME="tex2html1777" HREF="node191.html"> <IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A> <BR> <B> Next:</B> <A NAME="tex2html1780" HREF="node74.html">3.10.2 Enabling and Disabling</A> <B> Up:</B> <A NAME="tex2html1774" HREF="node72.html">3.10 Enabling and Disabling</A> <B> Previous:</B> <A NAME="tex2html1768" HREF="node72.html">3.10 Enabling and Disabling</A> <B> <A NAME="tex2html1776" HREF="node1.html">Contents</A></B> <B> <A NAME="tex2html1778" HREF="node191.html">Index</A></B> <BR> <BR> <!--End of Navigation Panel--> <H2><A NAME="SECTION004101000000000000000"> 3.10.1 Critical Functions and Critical Statements</A> </H2> <P> A special keyword may be associated with a block or a function declaring it as <I>critical</I>. SDCC will generate code to disable all interrupts<A NAME="1765"></A> upon entry to a critical function and restore the interrupt enable to the previous state before returning. Nesting critical functions will need one additional byte on the stack<A NAME="1766"></A> for each call. <BLOCKQUOTE> <TT>int foo () __critical<A NAME="1768"></A><A NAME="1769"></A> </TT> <BR><TT>{ </TT> <BR><TT> ... </TT> <BR><TT> ... </TT> <BR><TT>}</TT> </BLOCKQUOTE> The critical attribute maybe used with other attributes like <I>reentrant.</I> <BR> The keyword <I>critical</I> may also be used to disable interrupts more locally: <BLOCKQUOTE> <TT>__critical{ i++; }</TT> </BLOCKQUOTE> More than one statement could have been included in the block. <P> <BR><HR> <ADDRESS> 2011-03-20 </ADDRESS> </BODY> </HTML>