123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
- <html>
- <!-- Created on December 10, 2012 by texi2html 1.82
- texi2html was written by:
- Lionel Cons <[email protected]> (original author)
- Karl Berry <[email protected]>
- Olaf Bachmann <[email protected]>
- and many others.
- Maintained by: Many creative people.
- Send bugs and suggestions to <[email protected]>
- -->
- <head>
- <title>avram - a virtual machine code interpreter: 3.1.2 Recoverable Operations</title>
- <meta name="description" content="avram - a virtual machine code interpreter: 3.1.2 Recoverable Operations">
- <meta name="keywords" content="avram - a virtual machine code interpreter: 3.1.2 Recoverable Operations">
- <meta name="resource-type" content="document">
- <meta name="distribution" content="global">
- <meta name="Generator" content="texi2html 1.82">
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <style type="text/css">
- <!--
- a.summary-letter {text-decoration: none}
- blockquote.smallquotation {font-size: smaller}
- pre.display {font-family: serif}
- pre.format {font-family: serif}
- pre.menu-comment {font-family: serif}
- pre.menu-preformatted {font-family: serif}
- pre.smalldisplay {font-family: serif; font-size: smaller}
- pre.smallexample {font-size: smaller}
- pre.smallformat {font-family: serif; font-size: smaller}
- pre.smalllisp {font-size: smaller}
- span.roman {font-family:serif; font-weight:normal;}
- span.sansserif {font-family:sans-serif; font-weight:normal;}
- ul.toc {list-style: none}
- -->
- </style>
- </head>
- <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
- <a name="Recoverable-Operations"></a>
- <table cellpadding="1" cellspacing="1" border="0">
- <tr><td valign="middle" align="left">[<a href="Simple-Operations.html#Simple-Operations" title="Previous section in reading order"> < </a>]</td>
- <td valign="middle" align="left">[<a href="List-Transformations.html#List-Transformations" title="Next section in reading order"> > </a>]</td>
- <td valign="middle" align="left"> </td>
- <td valign="middle" align="left">[<a href="Library-Reference.html#Library-Reference" title="Beginning of this chapter or previous chapter"> << </a>]</td>
- <td valign="middle" align="left">[<a href="Lists.html#Lists" title="Up section"> Up </a>]</td>
- <td valign="middle" align="left">[<a href="Character-Table.html#Character-Table" title="Next chapter"> >> </a>]</td>
- <td valign="middle" align="left"> </td>
- <td valign="middle" align="left"> </td>
- <td valign="middle" align="left"> </td>
- <td valign="middle" align="left"> </td>
- <td valign="middle" align="left">[<a href="avram.html#Top" title="Cover (top) of document">Top</a>]</td>
- <td valign="middle" align="left">[<a href="avram_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
- <td valign="middle" align="left">[<a href="Function-Index.html#Function-Index" title="Index">Index</a>]</td>
- <td valign="middle" align="left">[<a href="avram_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
- </tr></table>
- <hr size="1">
- <a name="Recoverable-Operations-1"></a>
- <h3 class="subsection">3.1.2 Recoverable Operations</h3>
- <p>The functions in this section are similar to the ones in the previous
- section except with regard to error handling. Whereas the other ones
- cause an error message to be printed and the process to exit in the
- event of an overflow, these return to the caller, whose responsibility
- it is to take appropriate action. The functions in both sections are
- declared in ‘<tt>lists.h</tt>’, and should be preceded by a call to
- <code>avm_initialize_lists</code>.
- </p>
- <dl>
- <dt><a name="index-avm_005frecoverable_005fjoin"></a><u>Function:</u> list <b>avm_recoverable_join</b><i> (list <var>left</var>, list <var>right</var>)</i></dt>
- <dd><p>This function is similar to <code>avm_join</code>, but will return a
- <code>NULL</code> pointer if memory that was needed can not be allocated. A
- <code>NULL</code> pointer would never be the result of a join under normal
- circumstances, so the overflow can be detected by the caller. Regardless
- of whether overflow occurs, the arguments are deallocated by this function
- and should not be referenced thereafter.
- </p></dd></dl>
- <dl>
- <dt><a name="index-avm_005frecoverable_005fenqueue"></a><u>Function:</u> void <b>avm_recoverable_enqueue</b><i> (list *<var>front</var>, list *<var>back</var>, list <var>operand</var>, int *<var>fault</var>)</i></dt>
- <dd><p>This version of the enqueue function will dispose of the <code><var>operand</var></code> if there
- isn’t room to append another item and set <code>*<var>fault</var></code> to a non-zero
- value. Other than that, it does the same as <code>avm_enqueue</code>.
- </p></dd></dl>
- <dl>
- <dt><a name="index-avm_005frecoverable_005flength"></a><u>Function:</u> counter <b>avm_recoverable_length</b><i> (list <var>operand</var>)</i></dt>
- <dd><p>This function checks for arithmetic overflow when calculating the length
- of a list, and returns a zero value if overflow occurs. The caller can
- detect the error by noting that zero is not the length of any list other
- than <code>NULL</code>. This kind of overflow is impossible unless the host
- does not have long enough integers for its address space.
- </p></dd></dl>
- <dl>
- <dt><a name="index-avm_005frecoverable_005farea"></a><u>Function:</u> counter <b>avm_recoverable_area</b><i> (list <var>operand</var>, int *<var>fault</var>)</i></dt>
- <dd><p>This function is similar to <code>avm_area</code>, except that it reacts
- differently to arithmetic overflow. The <code>fault</code> parameter should be
- the address of an integer known to the caller, which will be set to a
- non-zero value if overflow occurs. In that event, the value of zero will
- also be returned for the area. Note that it is possible for non-empty
- lists to have an area of zero, so this condition alone is not indicative
- of an error.
- </p></dd></dl>
- <dl>
- <dt><a name="index-avm_005frecoverable_005fnatural"></a><u>Function:</u> list <b>avm_recoverable_natural</b><i> (counter <var>number</var>)</i></dt>
- <dd><p>This function returns the <code>list</code> representation of a native
- unsigned long integer, provided that there is enough memory, similarly to the
- <code>avm_natural</code> function. Unlike that function, this one will return
- a value of <code>NULL</code> rather than exiting the program in the event of a
- memory overflow. The overflow can be detected by the caller insofar as a
- <code>NULL</code> <code>list</code> does not represent any number other than zero.
- </p></dd></dl>
- <hr size="1">
- <table cellpadding="1" cellspacing="1" border="0">
- <tr><td valign="middle" align="left">[<a href="Simple-Operations.html#Simple-Operations" title="Previous section in reading order"> < </a>]</td>
- <td valign="middle" align="left">[<a href="List-Transformations.html#List-Transformations" title="Next section in reading order"> > </a>]</td>
- <td valign="middle" align="left"> </td>
- <td valign="middle" align="left">[<a href="Library-Reference.html#Library-Reference" title="Beginning of this chapter or previous chapter"> << </a>]</td>
- <td valign="middle" align="left">[<a href="Lists.html#Lists" title="Up section"> Up </a>]</td>
- <td valign="middle" align="left">[<a href="Character-Table.html#Character-Table" title="Next chapter"> >> </a>]</td>
- <td valign="middle" align="left"> </td>
- <td valign="middle" align="left"> </td>
- <td valign="middle" align="left"> </td>
- <td valign="middle" align="left"> </td>
- <td valign="middle" align="left">[<a href="avram.html#Top" title="Cover (top) of document">Top</a>]</td>
- <td valign="middle" align="left">[<a href="avram_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
- <td valign="middle" align="left">[<a href="Function-Index.html#Function-Index" title="Index">Index</a>]</td>
- <td valign="middle" align="left">[<a href="avram_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
- </tr></table>
- <p>
- <font size="-1">
- This document was generated on <i>December 10, 2012</i> using <a href="http://www.nongnu.org/texi2html/"><i>texi2html 1.82</i></a>.
- </font>
- <br>
- </p>
- </body>
- </html>
|