ardupilot/libraries/doc/html/c_09_09_8cpp_source.html

127 lines
9.9 KiB
HTML

<!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: c++.cpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javaScript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body onload='searchBox.OnSelectItem(0);'>
<!-- 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="pages.html"><span>Related&nbsp;Pages</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>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="preprocessor">#ifdef AP_DISPLAYMEM</span>
<a name="l00017"></a>00017 <span class="preprocessor"></span> <a class="code" href="c_09_09_8cpp.html#a588befcce33478fd49d0caf32b362d15">displayMemory</a>();
<a name="l00018"></a>00018 <span class="preprocessor">#endif</span>
<a name="l00019"></a>00019 <span class="preprocessor"></span> <span class="keywordflow">return</span>(calloc(size, 1));
<a name="l00020"></a>00020 }
<a name="l00021"></a>00021
<a name="l00022"></a><a class="code" href="c_09_09_8cpp.html#a86107594327f3a001230df9802cd4422">00022</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="l00023"></a>00023 {
<a name="l00024"></a>00024 <span class="keywordflow">if</span> (p) free(p);
<a name="l00025"></a>00025 }
<a name="l00026"></a>00026
<a name="l00027"></a>00027 <span class="preprocessor">#if 0</span>
<a name="l00028"></a>00028 <span class="preprocessor"></span><span class="comment">// We should never need this, as classes should never be defined</span>
<a name="l00029"></a>00029 <span class="comment">// with pure virtual member functions</span>
<a name="l00030"></a>00030 <span class="keyword">extern</span> <span class="stringliteral">&quot;C&quot;</span> <span class="keywordtype">void</span> __cxa_pure_virtual()
<a name="l00031"></a>00031 {
<a name="l00032"></a>00032 <span class="keywordflow">while</span> (1);
<a name="l00033"></a>00033 }
<a name="l00034"></a>00034 <span class="preprocessor">#endif</span>
<a name="l00035"></a>00035 <span class="preprocessor"></span>
<a name="l00036"></a><a class="code" href="c_09_09_8cpp.html#a63ce4f64887b9307317aee5baae6b18f">00036</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="l00037"></a>00037 {
<a name="l00038"></a>00038 <span class="preprocessor">#ifdef AP_DISPLAYMEM</span>
<a name="l00039"></a>00039 <span class="preprocessor"></span> <a class="code" href="c_09_09_8cpp.html#a588befcce33478fd49d0caf32b362d15">displayMemory</a>();
<a name="l00040"></a>00040 <span class="preprocessor">#endif</span>
<a name="l00041"></a>00041 <span class="preprocessor"></span> <span class="keywordflow">return</span>(calloc(size, 1));
<a name="l00042"></a>00042 }
<a name="l00043"></a>00043
<a name="l00044"></a><a class="code" href="c_09_09_8cpp.html#a1d8b2d6f17242ae0d182b0f7a98ba54f">00044</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="l00045"></a>00045 {
<a name="l00046"></a>00046 <span class="keywordflow">if</span> (ptr) free(ptr);
<a name="l00047"></a>00047 }
<a name="l00048"></a>00048
<a name="l00049"></a>00049 __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="l00050"></a>00050
<a name="l00051"></a><a class="code" href="_a_p_m___perf_mon_8h.html#a239ddd7f6e7ee1b05b59b2e56d8afb40">00051</a> <span class="keywordtype">int</span> <a class="code" href="c_09_09_8cpp.html#ad9a42607fb7932f44ba914ac49972e62">__cxa_guard_acquire</a>(__guard *g)
<a name="l00052"></a>00052 {
<a name="l00053"></a>00053 <span class="keywordflow">return</span> !*(<span class="keywordtype">char</span> *)(g);
<a name="l00054"></a>00054 };
<a name="l00055"></a>00055
<a name="l00056"></a><a class="code" href="_a_p_m___perf_mon_8h.html#aab72c37f0b3e6fc38d293bd4f8dd61ed">00056</a> <span class="keywordtype">void</span> <a class="code" href="c_09_09_8cpp.html#adef76ddddaddf969efa3bfad968fd430">__cxa_guard_release</a> (__guard *g)
<a name="l00057"></a>00057 {
<a name="l00058"></a>00058 *(<span class="keywordtype">char</span> *)g = 1;
<a name="l00059"></a>00059 };
<a name="l00060"></a>00060
<a name="l00061"></a><a class="code" href="_a_p_m___perf_mon_8h.html#a357afb2dc20a652447f3a529dbda60e4">00061</a> <span class="keywordtype">void</span> <a class="code" href="c_09_09_8cpp.html#a357afb2dc20a652447f3a529dbda60e4">__cxa_guard_abort</a> (__guard *) {};
<a name="l00062"></a>00062
<a name="l00063"></a>00063 <span class="comment">// free memory</span>
<a name="l00064"></a>00064 <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="l00065"></a>00065 <span class="keyword">extern</span> <span class="keywordtype">void</span> *<a class="code" href="c_09_09_8cpp.html#a8d18204366e8a385c441663ed41f1ae4">__brkval</a>;
<a name="l00066"></a>00066
<a name="l00067"></a><a class="code" href="c_09_09_8h.html#a588befcce33478fd49d0caf32b362d15">00067</a> <span class="keywordtype">void</span> <a class="code" href="c_09_09_8cpp.html#a588befcce33478fd49d0caf32b362d15">displayMemory</a>()
<a name="l00068"></a>00068 {
<a name="l00069"></a>00069 <span class="keyword">static</span> <span class="keywordtype">int</span> minMemFree=0;
<a name="l00070"></a>00070 <span class="keywordflow">if</span> (minMemFree&lt;=0 || <a class="code" href="c_09_09_8cpp.html#a8d862dc01c44bfabc8d952bb77f8da89">freeMemory</a>()&lt;minMemFree) {
<a name="l00071"></a>00071 minMemFree = <a class="code" href="c_09_09_8cpp.html#a8d862dc01c44bfabc8d952bb77f8da89">freeMemory</a>();
<a name="l00072"></a>00072 <a class="code" href="_fast_serial_8h.html#a8e6f49b84135f0158fe250cb7338ddad">Serial</a>.print(<span class="stringliteral">&quot;bytes free: &quot;</span>);
<a name="l00073"></a>00073 <a class="code" href="_fast_serial_8h.html#a8e6f49b84135f0158fe250cb7338ddad">Serial</a>.println(minMemFree);
<a name="l00074"></a>00074 }
<a name="l00075"></a>00075 }
<a name="l00076"></a>00076
<a name="l00077"></a><a class="code" href="c_09_09_8h.html#a8d862dc01c44bfabc8d952bb77f8da89">00077</a> <span class="keywordtype">int</span> <a class="code" href="c_09_09_8cpp.html#a8d862dc01c44bfabc8d952bb77f8da89">freeMemory</a>()
<a name="l00078"></a>00078 {
<a name="l00079"></a>00079 <span class="keywordtype">int</span> free_memory;
<a name="l00080"></a>00080
<a name="l00081"></a>00081 <span class="keywordflow">if</span> ((<span class="keywordtype">int</span>)__brkval == 0)
<a name="l00082"></a>00082 free_memory = ((int)&amp;free_memory) - ((int)&amp;__bss_end);
<a name="l00083"></a>00083 <span class="keywordflow">else</span>
<a name="l00084"></a>00084 free_memory = ((int)&amp;free_memory) - ((int)__brkval);
<a name="l00085"></a>00085
<a name="l00086"></a>00086 <span class="keywordflow">return</span> free_memory;
<a name="l00087"></a>00087 }
</pre></div></div>
</div>
<hr class="footer"/><address class="footer"><small>
Generated for ArduPilot Libraries by&nbsp;<a href="http://www.doxygen.org/index.html"><img class="footer" src="doxygen.png" alt="doxygen"/></a></small></address>
</body>
</html>