ardupilot/libraries/doc/html/c_09_09_8cpp_source.html

110 lines
8.4 KiB
HTML
Raw Normal View History

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>ArduPilot Libraries: /home/jgoppert/Projects/ap/libraries/AP_Common/c++.cpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.7.1 -->
<div class="navigation" id="top">
<div class="tabs">
<ul class="tablist">
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div class="tabs2">
<ul class="tablist">
<li><a href="files.html"><span>File&nbsp;List</span></a></li>
<li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
</ul>
</div>
<div class="header">
<div class="headertitle">
<h1>/home/jgoppert/Projects/ap/libraries/AP_Common/c++.cpp</h1> </div>
</div>
<div class="contents">
<a href="c_09_09_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: t -*-</span>
<a name="l00002"></a>00002
<a name="l00003"></a>00003 <span class="comment">//</span>
<a name="l00004"></a>00004 <span class="comment">// C++ runtime support not provided by Arduino</span>
<a name="l00005"></a>00005 <span class="comment">//</span>
<a name="l00006"></a>00006 <span class="comment">// Note: use new/delete with caution. The heap is small and</span>
<a name="l00007"></a>00007 <span class="comment">// easily fragmented.</span>
<a name="l00008"></a>00008 <span class="comment">//</span>
<a name="l00009"></a>00009
<a name="l00010"></a>00010 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00011"></a>00011 <span class="preprocessor">#include &quot;<a class="code" href="c_09_09_8h.html">c++.h</a>&quot;</span>
<a name="l00012"></a>00012 <span class="preprocessor">#include &quot;<a class="code" href="_w_program_8h.html">WProgram.h</a>&quot;</span>
<a name="l00013"></a>00013
<a name="l00014"></a><a class="code" href="c_09_09_8cpp.html#a205ed048fdf5259c2e8e0cb60ee8f719">00014</a> <span class="keywordtype">void</span> * <a class="code" href="c_09_09_8cpp.html#a205ed048fdf5259c2e8e0cb60ee8f719">operator new</a>(<span class="keywordtype">size_t</span> size)
<a name="l00015"></a>00015 {
<a name="l00016"></a>00016 <span class="keywordflow">return</span>(calloc(size, 1));
<a name="l00017"></a>00017 }
<a name="l00018"></a>00018
<a name="l00019"></a><a class="code" href="c_09_09_8cpp.html#a86107594327f3a001230df9802cd4422">00019</a> <span class="keywordtype">void</span> <a class="code" href="c_09_09_8cpp.html#a86107594327f3a001230df9802cd4422">operator delete</a>(<span class="keywordtype">void</span> *p)
<a name="l00020"></a>00020 {
<a name="l00021"></a>00021 <span class="keywordflow">if</span> (p) free(p);
<a name="l00022"></a>00022 }
<a name="l00023"></a>00023
<a name="l00024"></a><a class="code" href="c_09_09_8cpp.html#a63ce4f64887b9307317aee5baae6b18f">00024</a> <span class="keywordtype">void</span> * <a class="code" href="c_09_09_8cpp.html#a63ce4f64887b9307317aee5baae6b18f">operator new[]</a>(<span class="keywordtype">size_t</span> size)
<a name="l00025"></a>00025 {
<a name="l00026"></a>00026 <span class="keywordflow">return</span> malloc(size);
<a name="l00027"></a>00027 }
<a name="l00028"></a>00028
<a name="l00029"></a><a class="code" href="c_09_09_8cpp.html#a1d8b2d6f17242ae0d182b0f7a98ba54f">00029</a> <span class="keywordtype">void</span> <a class="code" href="c_09_09_8cpp.html#a1d8b2d6f17242ae0d182b0f7a98ba54f">operator delete[]</a>(<span class="keywordtype">void</span> * ptr)
<a name="l00030"></a>00030 {
<a name="l00031"></a>00031 <span class="keywordflow">if</span> (ptr) free(ptr);
<a name="l00032"></a>00032 }
<a name="l00033"></a>00033
<a name="l00034"></a>00034 __extension__ <span class="keyword">typedef</span> <span class="keywordtype">int</span> __guard <a class="code" href="c_09_09_8cpp.html#aa5aa60072f4063655d5283b6d7b7ab44">__attribute__</a>((mode (__DI__)));
<a name="l00035"></a>00035
<a name="l00036"></a><a class="code" href="_a_p_m___perf_mon_8h.html#a239ddd7f6e7ee1b05b59b2e56d8afb40">00036</a> <span class="keywordtype">int</span> <a class="code" href="c_09_09_8cpp.html#ad9a42607fb7932f44ba914ac49972e62">__cxa_guard_acquire</a>(__guard *g)
<a name="l00037"></a>00037 {
<a name="l00038"></a>00038 <span class="keywordflow">return</span> !*(<span class="keywordtype">char</span> *)(g);
<a name="l00039"></a>00039 };
<a name="l00040"></a>00040
<a name="l00041"></a><a class="code" href="_a_p_m___perf_mon_8h.html#aab72c37f0b3e6fc38d293bd4f8dd61ed">00041</a> <span class="keywordtype">void</span> <a class="code" href="c_09_09_8cpp.html#adef76ddddaddf969efa3bfad968fd430">__cxa_guard_release</a> (__guard *g)
<a name="l00042"></a>00042 {
<a name="l00043"></a>00043 *(<span class="keywordtype">char</span> *)g = 1;
<a name="l00044"></a>00044 };
<a name="l00045"></a>00045
<a name="l00046"></a><a class="code" href="_a_p_m___perf_mon_8h.html#a357afb2dc20a652447f3a529dbda60e4">00046</a> <span class="keywordtype">void</span> <a class="code" href="c_09_09_8cpp.html#a357afb2dc20a652447f3a529dbda60e4">__cxa_guard_abort</a> (__guard *) {};
<a name="l00047"></a>00047
<a name="l00048"></a>00048 <span class="comment">// free memory</span>
<a name="l00049"></a>00049 <span class="keyword">extern</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="c_09_09_8cpp.html#aafe276f41c2f5f7f768823ae763da2cf">__bss_end</a>;
<a name="l00050"></a>00050 <span class="keyword">extern</span> <span class="keywordtype">void</span> *<a class="code" href="c_09_09_8cpp.html#a8d18204366e8a385c441663ed41f1ae4">__brkval</a>;
<a name="l00051"></a>00051
<a name="l00052"></a><a class="code" href="c_09_09_8h.html#a588befcce33478fd49d0caf32b362d15">00052</a> <span class="keywordtype">void</span> <a class="code" href="c_09_09_8cpp.html#a588befcce33478fd49d0caf32b362d15">displayMemory</a>()
<a name="l00053"></a>00053 {
<a name="l00054"></a>00054 <span class="keyword">static</span> <span class="keywordtype">int</span> minMemFree=0;
<a name="l00055"></a>00055 <span class="keywordflow">if</span> (minMemFree&lt;=0 || <a class="code" href="c_09_09_8cpp.html#a8d862dc01c44bfabc8d952bb77f8da89">freeMemory</a>()&lt;minMemFree) {
<a name="l00056"></a>00056 minMemFree = <a class="code" href="c_09_09_8cpp.html#a8d862dc01c44bfabc8d952bb77f8da89">freeMemory</a>();
<a name="l00057"></a>00057 <a class="code" href="_fast_serial_8h.html#a8e6f49b84135f0158fe250cb7338ddad">Serial</a>.print(<span class="stringliteral">&quot;bytes free: &quot;</span>);
<a name="l00058"></a>00058 <a class="code" href="_fast_serial_8h.html#a8e6f49b84135f0158fe250cb7338ddad">Serial</a>.println(minMemFree);
<a name="l00059"></a>00059 }
<a name="l00060"></a>00060 }
<a name="l00061"></a>00061
<a name="l00062"></a><a class="code" href="c_09_09_8h.html#a8d862dc01c44bfabc8d952bb77f8da89">00062</a> <span class="keywordtype">int</span> <a class="code" href="c_09_09_8cpp.html#a8d862dc01c44bfabc8d952bb77f8da89">freeMemory</a>()
<a name="l00063"></a>00063 {
<a name="l00064"></a>00064 <span class="keywordtype">int</span> free_memory;
<a name="l00065"></a>00065
<a name="l00066"></a>00066 <span class="keywordflow">if</span> ((<span class="keywordtype">int</span>)__brkval == 0)
<a name="l00067"></a>00067 free_memory = ((int)&amp;free_memory) - ((int)&amp;__bss_end);
<a name="l00068"></a>00068 <span class="keywordflow">else</span>
<a name="l00069"></a>00069 free_memory = ((int)&amp;free_memory) - ((int)__brkval);
<a name="l00070"></a>00070
<a name="l00071"></a>00071 <span class="keywordflow">return</span> free_memory;
<a name="l00072"></a>00072 }
</pre></div></div>
</div>
<hr class="footer"/><address class="footer"><small>Generated on Sun Dec 26 2010 21:58:34 for ArduPilot Libraries by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.1 </small></address>
</body>
</html>