📄 util_8h.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>BlueLab: util.h File Reference</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.3.8 --><div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a></div><h1>util.h File Reference</h1>Utility routines. <a href="#_details">More...</a><p><h2>Functions</h2><ul><li>int <a class="el" href="util_8h.html#a0">UtilCompare</a> (const <a class="el" href="csrtypes_8h.html#a4">uint16</a> *a, const <a class="el" href="csrtypes_8h.html#a4">uint16</a> *b, <a class="el" href="csrtypes_8h.html#a2">size_t</a> size)<dl class="el"><dd class="mdescRight">Compare two blocks of memory of extent 'size', as uint16's. <a href="#a0"></a><br></dl><li>const <a class="el" href="csrtypes_8h.html#a4">uint16</a> * <a class="el" href="util_8h.html#a1">UtilFind</a> (<a class="el" href="csrtypes_8h.html#a4">uint16</a> mask, <a class="el" href="csrtypes_8h.html#a4">uint16</a> value, const <a class="el" href="csrtypes_8h.html#a4">uint16</a> *data_start, <a class="el" href="csrtypes_8h.html#a4">uint16</a> offset, <a class="el" href="csrtypes_8h.html#a4">uint16</a> size, <a class="el" href="csrtypes_8h.html#a4">uint16</a> count)<dl class="el"><dd class="mdescRight">Compares two memory blocks. <a href="#a1"></a><br></dl><li>const <a class="el" href="csrtypes_8h.html#a8">uint8</a> * <a class="el" href="util_8h.html#a2">UtilGetNumber</a> (const <a class="el" href="csrtypes_8h.html#a8">uint8</a> *start, const <a class="el" href="csrtypes_8h.html#a8">uint8</a> *end, <a class="el" href="csrtypes_8h.html#a4">uint16</a> *result)<dl class="el"><dd class="mdescRight">Converts a string into a number. <a href="#a2"></a><br></dl><li><a class="el" href="csrtypes_8h.html#a4">uint16</a> <a class="el" href="util_8h.html#a3">UtilHash</a> (const <a class="el" href="csrtypes_8h.html#a4">uint16</a> *data, <a class="el" href="csrtypes_8h.html#a4">uint16</a> size, <a class="el" href="csrtypes_8h.html#a4">uint16</a> seed)<dl class="el"><dd class="mdescRight">Compute a uint16 hash value for the memory at 'data', of extent 'size' uint16's, starting with the given 'seed'. <a href="#a3"></a><br></dl><li><a class="el" href="csrtypes_8h.html#a4">uint16</a> <a class="el" href="util_8h.html#a4">UtilRandom</a> (void)<dl class="el"><dd class="mdescRight">Returns a 16-bit random number. <a href="#a4"></a><br></dl><li>void <a class="el" href="util_8h.html#a5">UtilSwap</a> (<a class="el" href="csrtypes_8h.html#a4">uint16</a> *data, <a class="el" href="csrtypes_8h.html#a4">uint16</a> size)<dl class="el"><dd class="mdescRight">Exchanges the high and low bytes of 'size' words at 'data'. <a href="#a5"></a><br></dl></ul><hr><a name="_details"></a><h2>Detailed Description</h2>Utility routines. <p>These routines perform a number of frequently required tasks. They will execute at a greater speed than similar routines written in VM application code.<hr><h2>Function Documentation</h2><a class="anchor" name="a0" doxytag="util.h::UtilCompare" ></a><p><table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> int UtilCompare </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">const <a class="el" href="csrtypes_8h.html#a4">uint16</a> * </td> <td class="mdname" nowrap> <em>a</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td></td> <td class="md" nowrap>const <a class="el" href="csrtypes_8h.html#a4">uint16</a> * </td> <td class="mdname" nowrap> <em>b</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td></td> <td class="md" nowrap><a class="el" href="csrtypes_8h.html#a2">size_t</a> </td> <td class="mdname" nowrap> <em>size</em></td> </tr> <tr> <td></td> <td class="md">) </td> <td class="md" colspan="2"></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Compare two blocks of memory of extent 'size', as uint16's. <p><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td></td><td valign=top><em>a</em> </td><td>First memory block to compare. </td></tr> <tr><td></td><td valign=top><em>b</em> </td><td>Second memory block to compare. </td></tr> <tr><td></td><td valign=top><em>size</em> </td><td>Size of memory blocks to compare.</td></tr> </table></dl>Return > 0 if 'a' is lexicographically greater than 'b', < 0 if 'a' is lexicographically less than 'b', 0 if 'a' and 'b' have identical contents. </td> </tr></table><a class="anchor" name="a1" doxytag="util.h::UtilFind" ></a><p><table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> const <a class="el" href="csrtypes_8h.html#a4">uint16</a>* UtilFind </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top"><a class="el" href="csrtypes_8h.html#a4">uint16</a> </td> <td class="mdname" nowrap> <em>mask</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td></td> <td class="md" nowrap><a class="el" href="csrtypes_8h.html#a4">uint16</a> </td> <td class="mdname" nowrap> <em>value</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td></td> <td class="md" nowrap>const <a class="el" href="csrtypes_8h.html#a4">uint16</a> * </td> <td class="mdname" nowrap> <em>data_start</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td></td> <td class="md" nowrap><a class="el" href="csrtypes_8h.html#a4">uint16</a> </td> <td class="mdname" nowrap> <em>offset</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td></td> <td class="md" nowrap><a class="el" href="csrtypes_8h.html#a4">uint16</a> </td> <td class="mdname" nowrap> <em>size</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td></td> <td class="md" nowrap><a class="el" href="csrtypes_8h.html#a4">uint16</a> </td> <td class="mdname" nowrap> <em>count</em></td> </tr> <tr> <td></td> <td class="md">) </td> <td class="md" colspan="2"></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Compares two memory blocks. <p><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td></td><td valign=top><em>mask</em> </td><td>The bitmask to use. </td></tr> <tr><td></td><td valign=top><em>value</em> </td><td>The value to look for. </td></tr> <tr><td></td><td valign=top><em>data_start</em> </td><td>The memory location of the start of the table. </td></tr> <tr><td></td><td valign=top><em>offset</em> </td><td>The offset into each table entry that the search will be performed at. </td></tr> <tr><td></td><td valign=top><em>size</em> </td><td>The size of each table entry. </td></tr> <tr><td></td><td valign=top><em>count</em> </td><td>The number of entries in the table.</td></tr> </table></dl>Conceptually we have a table in memory starting at 'data_start', with 'count' entries where each entry is 'size'. UtilFind searches for 'value', at 'offset' from the start of each entry, using bitmask 'mask'. Returns vm address of the table entry containing 'value' if found, else 0. </td> </tr></table><a class="anchor" name="a2" doxytag="util.h::UtilGetNumber" ></a><p><table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> const <a class="el" href="csrtypes_8h.html#a8">uint8</a>* UtilGetNumber </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">const <a class="el" href="csrtypes_8h.html#a8">uint8</a> * </td> <td class="mdname" nowrap> <em>start</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td></td> <td class="md" nowrap>const <a class="el" href="csrtypes_8h.html#a8">uint8</a> * </td> <td class="mdname" nowrap> <em>end</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td></td> <td class="md" nowrap><a class="el" href="csrtypes_8h.html#a4">uint16</a> * </td> <td class="mdname" nowrap> <em>result</em></td> </tr> <tr> <td></td> <td class="md">) </td> <td class="md" colspan="2"></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Converts a string into a number. <p><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td></td><td valign=top><em>start</em> </td><td>The start of the string to convert. </td></tr> <tr><td></td><td valign=top><em>end</em> </td><td>The end of the string to convert. </td></tr> <tr><td></td><td valign=top><em>result</em> </td><td>Will contain the resulting number.</td></tr> </table></dl>The return value is a pointer into the string (the first character after the number) unless no number was found, in which case 0 is returned. The number is expected to be an unsigned decimal in the range 0 to 2^16. </td> </tr></table><a class="anchor" name="a3" doxytag="util.h::UtilHash" ></a><p><table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> <a class="el" href="csrtypes_8h.html#a4">uint16</a> UtilHash </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">const <a class="el" href="csrtypes_8h.html#a4">uint16</a> * </td> <td class="mdname" nowrap> <em>data</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td></td> <td class="md" nowrap><a class="el" href="csrtypes_8h.html#a4">uint16</a> </td> <td class="mdname" nowrap> <em>size</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td></td> <td class="md" nowrap><a class="el" href="csrtypes_8h.html#a4">uint16</a> </td> <td class="mdname" nowrap> <em>seed</em></td> </tr> <tr> <td></td> <td class="md">) </td> <td class="md" colspan="2"></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Compute a uint16 hash value for the memory at 'data', of extent 'size' uint16's, starting with the given 'seed'. <p><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td></td><td valign=top><em>data</em> </td><td>The start of the memory block to hash. </td></tr> <tr><td></td><td valign=top><em>size</em> </td><td>The size of the memory block to hash. </td></tr> <tr><td></td><td valign=top><em>seed</em> </td><td>The seed value to use for the hash. </td></tr> </table></dl> </td> </tr></table><a class="anchor" name="a4" doxytag="util.h::UtilRandom" ></a><p><table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> <a class="el" href="csrtypes_8h.html#a4">uint16</a> UtilRandom </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">void </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Returns a 16-bit random number. <p>Uses a numerical approach, but the state is shared with the BlueCore firmware which also makes calls into this function so predicability will be low. </td> </tr></table><a class="anchor" name="a5" doxytag="util.h::UtilSwap" ></a><p><table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> void UtilSwap </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top"><a class="el" href="csrtypes_8h.html#a4">uint16</a> * </td> <td class="mdname" nowrap> <em>data</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td></td> <td class="md" nowrap><a class="el" href="csrtypes_8h.html#a4">uint16</a> </td> <td class="mdname" nowrap> <em>size</em></td> </tr> <tr> <td></td> <td class="md">) </td> <td class="md" colspan="2"></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Exchanges the high and low bytes of 'size' words at 'data'. <p><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td></td><td valign=top><em>data</em> </td><td>The memory location to begin swapping from. </td></tr> <tr><td></td><td valign=top><em>size</em> </td><td>The number of swaps to perform. </td></tr> </table></dl> </td> </tr></table></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -