root / branches / wireless / docs / libdragonfly / html / atomic_8h-source.html @ 1578
History | View | Annotate | Download (12.8 KB)
1 | 1578 | dsschult | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
---|---|---|---|
2 | <html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> |
||
3 | <title>Colony: atomic.h Source File</title> |
||
4 | <link href="tabs.css" rel="stylesheet" type="text/css"> |
||
5 | <link href="doxygen.css" rel="stylesheet" type="text/css"> |
||
6 | </head><body> |
||
7 | <!-- Generated by Doxygen 1.5.8 -->
|
||
8 | <div class="navigation" id="top"> |
||
9 | <div class="tabs"> |
||
10 | <ul>
|
||
11 | <li><a href="index.html"><span>Main Page</span></a></li> |
||
12 | <li><a href="pages.html"><span>Related Pages</span></a></li> |
||
13 | <li><a href="modules.html"><span>Modules</span></a></li> |
||
14 | <li><a href="annotated.html"><span>Data Structures</span></a></li> |
||
15 | <li class="current"><a href="files.html"><span>Files</span></a></li> |
||
16 | </ul>
|
||
17 | </div>
|
||
18 | <div class="tabs"> |
||
19 | <ul>
|
||
20 | <li><a href="files.html"><span>File List</span></a></li> |
||
21 | <li><a href="globals.html"><span>Globals</span></a></li> |
||
22 | </ul>
|
||
23 | </div>
|
||
24 | <h1>atomic.h</h1><a href="atomic_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* This file is in the dragonfly library directory because it seems to be</span> |
||
25 | <a name="l00002"></a>00002 <span class="comment"> missing from the AVR libc distribution */</span> |
||
26 | <a name="l00003"></a>00003 |
||
27 | <a name="l00004"></a>00004 <span class="comment">/* Copyright (c) 2007 Dean Camera</span> |
||
28 | <a name="l00005"></a>00005 <span class="comment"> All rights reserved.</span> |
||
29 | <a name="l00006"></a>00006 <span class="comment"></span> |
||
30 | <a name="l00007"></a>00007 <span class="comment"> Redistribution and use in source and binary forms, with or without</span> |
||
31 | <a name="l00008"></a>00008 <span class="comment"> modification, are permitted provided that the following conditions are met:</span> |
||
32 | <a name="l00009"></a>00009 <span class="comment"></span> |
||
33 | <a name="l00010"></a>00010 <span class="comment"> * Redistributions of source code must retain the above copyright</span> |
||
34 | <a name="l00011"></a>00011 <span class="comment"> notice, this list of conditions and the following disclaimer.</span> |
||
35 | <a name="l00012"></a>00012 <span class="comment"></span> |
||
36 | <a name="l00013"></a>00013 <span class="comment"> * Redistributions in binary form must reproduce the above copyright</span> |
||
37 | <a name="l00014"></a>00014 <span class="comment"> notice, this list of conditions and the following disclaimer in</span> |
||
38 | <a name="l00015"></a>00015 <span class="comment"> the documentation and/or other materials provided with the</span> |
||
39 | <a name="l00016"></a>00016 <span class="comment"> distribution.</span> |
||
40 | <a name="l00017"></a>00017 <span class="comment"></span> |
||
41 | <a name="l00018"></a>00018 <span class="comment"> * Neither the name of the copyright holders nor the names of</span> |
||
42 | <a name="l00019"></a>00019 <span class="comment"> contributors may be used to endorse or promote products derived</span> |
||
43 | <a name="l00020"></a>00020 <span class="comment"> from this software without specific prior written permission.</span> |
||
44 | <a name="l00021"></a>00021 <span class="comment"></span> |
||
45 | <a name="l00022"></a>00022 <span class="comment"> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"</span> |
||
46 | <a name="l00023"></a>00023 <span class="comment"> AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE</span> |
||
47 | <a name="l00024"></a>00024 <span class="comment"> IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE</span> |
||
48 | <a name="l00025"></a>00025 <span class="comment"> ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE</span> |
||
49 | <a name="l00026"></a>00026 <span class="comment"> LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR</span> |
||
50 | <a name="l00027"></a>00027 <span class="comment"> CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF</span> |
||
51 | <a name="l00028"></a>00028 <span class="comment"> SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS</span> |
||
52 | <a name="l00029"></a>00029 <span class="comment"> INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN</span> |
||
53 | <a name="l00030"></a>00030 <span class="comment"> CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)</span> |
||
54 | <a name="l00031"></a>00031 <span class="comment"> ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE</span> |
||
55 | <a name="l00032"></a>00032 <span class="comment"> POSSIBILITY OF SUCH DAMAGE.</span> |
||
56 | <a name="l00033"></a>00033 <span class="comment">*/</span> |
||
57 | <a name="l00034"></a>00034 |
||
58 | <a name="l00035"></a>00035 <span class="comment">/* $Id: atomic.h,v 1.3 2007/12/20 14:17:56 joerg_wunsch Exp $ */</span> |
||
59 | <a name="l00036"></a>00036 |
||
60 | <a name="l00037"></a>00037 <span class="preprocessor">#ifndef _UTIL_ATOMIC_H_</span> |
||
61 | <a name="l00038"></a>00038 <span class="preprocessor"></span><span class="preprocessor">#define _UTIL_ATOMIC_H_ 1</span> |
||
62 | <a name="l00039"></a>00039 <span class="preprocessor"></span> |
||
63 | <a name="l00040"></a>00040 <span class="preprocessor">#include <avr/io.h></span> |
||
64 | <a name="l00041"></a>00041 <span class="preprocessor">#include <avr/interrupt.h></span> |
||
65 | <a name="l00042"></a>00042 |
||
66 | <a name="l00043"></a>00043 <span class="preprocessor">#if !defined(__DOXYGEN__)</span> |
||
67 | <a name="l00044"></a>00044 <span class="preprocessor"></span><span class="comment">/* Internal helper functions. */</span> |
||
68 | <a name="l00045"></a>00045 <span class="keyword">static</span> __inline__ uint8_t __iSeiRetVal(<span class="keywordtype">void</span>) |
||
69 | <a name="l00046"></a>00046 { |
||
70 | <a name="l00047"></a>00047 sei(); |
||
71 | <a name="l00048"></a>00048 <span class="keywordflow">return</span> 1; |
||
72 | <a name="l00049"></a>00049 } |
||
73 | <a name="l00050"></a>00050 |
||
74 | <a name="l00051"></a>00051 <span class="keyword">static</span> __inline__ uint8_t __iCliRetVal(<span class="keywordtype">void</span>) |
||
75 | <a name="l00052"></a>00052 { |
||
76 | <a name="l00053"></a>00053 cli(); |
||
77 | <a name="l00054"></a>00054 <span class="keywordflow">return</span> 1; |
||
78 | <a name="l00055"></a>00055 } |
||
79 | <a name="l00056"></a>00056 |
||
80 | <a name="l00057"></a>00057 <span class="keyword">static</span> __inline__ <span class="keywordtype">void</span> __iSeiParam(<span class="keyword">const</span> uint8_t *__s) |
||
81 | <a name="l00058"></a>00058 { |
||
82 | <a name="l00059"></a>00059 sei(); |
||
83 | <a name="l00060"></a>00060 __asm__ <span class="keyword">volatile</span> (<span class="stringliteral">""</span> ::: <span class="stringliteral">"memory"</span>); |
||
84 | <a name="l00061"></a>00061 (void)__s; |
||
85 | <a name="l00062"></a>00062 } |
||
86 | <a name="l00063"></a>00063 |
||
87 | <a name="l00064"></a>00064 <span class="keyword">static</span> __inline__ <span class="keywordtype">void</span> __iCliParam(<span class="keyword">const</span> uint8_t *__s) |
||
88 | <a name="l00065"></a>00065 { |
||
89 | <a name="l00066"></a>00066 cli(); |
||
90 | <a name="l00067"></a>00067 __asm__ <span class="keyword">volatile</span> (<span class="stringliteral">""</span> ::: <span class="stringliteral">"memory"</span>); |
||
91 | <a name="l00068"></a>00068 (void)__s; |
||
92 | <a name="l00069"></a>00069 } |
||
93 | <a name="l00070"></a>00070 |
||
94 | <a name="l00071"></a>00071 <span class="keyword">static</span> __inline__ <span class="keywordtype">void</span> __iRestore(<span class="keyword">const</span> uint8_t *__s) |
||
95 | <a name="l00072"></a>00072 { |
||
96 | <a name="l00073"></a>00073 SREG = *__s; |
||
97 | <a name="l00074"></a>00074 __asm__ <span class="keyword">volatile</span> (<span class="stringliteral">""</span> ::: <span class="stringliteral">"memory"</span>); |
||
98 | <a name="l00075"></a>00075 } |
||
99 | <a name="l00076"></a>00076 <span class="preprocessor">#endif </span><span class="comment">/* !__DOXYGEN__ */</span> |
||
100 | <a name="l00077"></a>00077 |
||
101 | <a name="l00203"></a>00203 <span class="preprocessor">#if defined(__DOXYGEN__)</span> |
||
102 | <a name="l00204"></a>00204 <span class="preprocessor"></span><span class="preprocessor">#define ATOMIC_BLOCK(type)</span> |
||
103 | <a name="l00205"></a>00205 <span class="preprocessor"></span><span class="preprocessor">#else</span> |
||
104 | <a name="l00206"></a><a class="code" href="group__util__atomic.html#gaaea265b31dabcfb3098bec7685c39e4">00206</a> <span class="preprocessor"></span><span class="preprocessor">#define ATOMIC_BLOCK(type) for ( type, __ToDo = __iCliRetVal(); \</span> |
||
105 | <a name="l00207"></a>00207 <span class="preprocessor"> __ToDo ; __ToDo = 0 )</span> |
||
106 | <a name="l00208"></a>00208 <span class="preprocessor"></span><span class="preprocessor">#endif </span><span class="comment">/* __DOXYGEN__ */</span> |
||
107 | <a name="l00209"></a>00209 |
||
108 | <a name="l00224"></a>00224 <span class="preprocessor">#if defined(__DOXYGEN__)</span> |
||
109 | <a name="l00225"></a>00225 <span class="preprocessor"></span><span class="preprocessor">#define NONATOMIC_BLOCK(type)</span> |
||
110 | <a name="l00226"></a>00226 <span class="preprocessor"></span><span class="preprocessor">#else</span> |
||
111 | <a name="l00227"></a><a class="code" href="group__util__atomic.html#g6e195ee2117559a25f77fbba9054674a">00227</a> <span class="preprocessor"></span><span class="preprocessor">#define NONATOMIC_BLOCK(type) for ( type, __ToDo = __iSeiRetVal(); \</span> |
||
112 | <a name="l00228"></a>00228 <span class="preprocessor"> __ToDo ; __ToDo = 0 )</span> |
||
113 | <a name="l00229"></a>00229 <span class="preprocessor"></span><span class="preprocessor">#endif </span><span class="comment">/* __DOXYGEN__ */</span> |
||
114 | <a name="l00230"></a>00230 |
||
115 | <a name="l00242"></a>00242 <span class="preprocessor">#if defined(__DOXYGEN__)</span> |
||
116 | <a name="l00243"></a>00243 <span class="preprocessor"></span><span class="preprocessor">#define ATOMIC_RESTORESTATE</span> |
||
117 | <a name="l00244"></a>00244 <span class="preprocessor"></span><span class="preprocessor">#else</span> |
||
118 | <a name="l00245"></a><a class="code" href="group__util__atomic.html#g362c18b15a09703e42e1c246c47420ef">00245</a> <span class="preprocessor"></span><span class="preprocessor">#define ATOMIC_RESTORESTATE uint8_t sreg_save \</span> |
||
119 | <a name="l00246"></a>00246 <span class="preprocessor"> __attribute__((__cleanup__(__iRestore))) = SREG</span> |
||
120 | <a name="l00247"></a>00247 <span class="preprocessor"></span><span class="preprocessor">#endif </span><span class="comment">/* __DOXYGEN__ */</span> |
||
121 | <a name="l00248"></a>00248 |
||
122 | <a name="l00263"></a>00263 <span class="preprocessor">#if defined(__DOXYGEN__)</span> |
||
123 | <a name="l00264"></a>00264 <span class="preprocessor"></span><span class="preprocessor">#define ATOMIC_FORCEON</span> |
||
124 | <a name="l00265"></a>00265 <span class="preprocessor"></span><span class="preprocessor">#else</span> |
||
125 | <a name="l00266"></a><a class="code" href="group__util__atomic.html#g92b11103b4b3b000a3190f0d26ba7062">00266</a> <span class="preprocessor"></span><span class="preprocessor">#define ATOMIC_FORCEON uint8_t sreg_save \</span> |
||
126 | <a name="l00267"></a>00267 <span class="preprocessor"> __attribute__((__cleanup__(__iSeiParam))) = 0</span> |
||
127 | <a name="l00268"></a>00268 <span class="preprocessor"></span><span class="preprocessor">#endif </span><span class="comment">/* __DOXYGEN__ */</span> |
||
128 | <a name="l00269"></a>00269 |
||
129 | <a name="l00281"></a>00281 <span class="preprocessor">#if defined(__DOXYGEN__)</span> |
||
130 | <a name="l00282"></a>00282 <span class="preprocessor"></span><span class="preprocessor">#define NONATOMIC_RESTORESTATE</span> |
||
131 | <a name="l00283"></a>00283 <span class="preprocessor"></span><span class="preprocessor">#else</span> |
||
132 | <a name="l00284"></a><a class="code" href="group__util__atomic.html#gb075653bf638fae9db049575741d3152">00284</a> <span class="preprocessor"></span><span class="preprocessor">#define NONATOMIC_RESTORESTATE uint8_t sreg_save \</span> |
||
133 | <a name="l00285"></a>00285 <span class="preprocessor"> __attribute__((__cleanup__(__iRestore))) = SREG</span> |
||
134 | <a name="l00286"></a>00286 <span class="preprocessor"></span><span class="preprocessor">#endif </span><span class="comment">/* __DOXYGEN__ */</span> |
||
135 | <a name="l00287"></a>00287 |
||
136 | <a name="l00302"></a>00302 <span class="preprocessor">#if defined(__DOXYGEN__)</span> |
||
137 | <a name="l00303"></a>00303 <span class="preprocessor"></span><span class="preprocessor">#define NONATOMIC_FORCEOFF</span> |
||
138 | <a name="l00304"></a>00304 <span class="preprocessor"></span><span class="preprocessor">#else</span> |
||
139 | <a name="l00305"></a><a class="code" href="group__util__atomic.html#gfb959d7d00d2d790b58d0e9880ea255a">00305</a> <span class="preprocessor"></span><span class="preprocessor">#define NONATOMIC_FORCEOFF uint8_t sreg_save \</span> |
||
140 | <a name="l00306"></a>00306 <span class="preprocessor"> __attribute__((__cleanup__(__iCliParam))) = 0</span> |
||
141 | <a name="l00307"></a>00307 <span class="preprocessor"></span><span class="preprocessor">#endif </span><span class="comment">/* __DOXYGEN__ */</span> |
||
142 | <a name="l00308"></a>00308 |
||
143 | <a name="l00309"></a>00309 <span class="preprocessor">#endif</span> |
||
144 | </pre></div></div> |
||
145 | <hr size="1"><address style="text-align: right;"><small>Generated on Fri Nov 20 21:51:59 2009 for Colony by |
||
146 | <a href="http://www.doxygen.org/index.html"> |
||
147 | <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address> |
||
148 | </body>
|
||
149 | </html> |