Recoverable-Operations.html 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <html lang="en">
  2. <head>
  3. <title>Recoverable Operations - avram - a virtual machine code interpreter</title>
  4. <meta http-equiv="Content-Type" content="text/html">
  5. <meta name="description" content="avram - a virtual machine code interpreter">
  6. <meta name="generator" content="makeinfo 4.13">
  7. <link title="Top" rel="start" href="index.html#Top">
  8. <link rel="up" href="Lists.html#Lists" title="Lists">
  9. <link rel="prev" href="Simple-Operations.html#Simple-Operations" title="Simple Operations">
  10. <link rel="next" href="List-Transformations.html#List-Transformations" title="List Transformations">
  11. <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
  12. <meta http-equiv="Content-Style-Type" content="text/css">
  13. <style type="text/css"><!--
  14. pre.display { font-family:inherit }
  15. pre.format { font-family:inherit }
  16. pre.smalldisplay { font-family:inherit; font-size:smaller }
  17. pre.smallformat { font-family:inherit; font-size:smaller }
  18. pre.smallexample { font-size:smaller }
  19. pre.smalllisp { font-size:smaller }
  20. span.sc { font-variant:small-caps }
  21. span.roman { font-family:serif; font-weight:normal; }
  22. span.sansserif { font-family:sans-serif; font-weight:normal; }
  23. --></style>
  24. </head>
  25. <body>
  26. <div class="node">
  27. <a name="Recoverable-Operations"></a>
  28. <p>
  29. Next:&nbsp;<a rel="next" accesskey="n" href="List-Transformations.html#List-Transformations">List Transformations</a>,
  30. Previous:&nbsp;<a rel="previous" accesskey="p" href="Simple-Operations.html#Simple-Operations">Simple Operations</a>,
  31. Up:&nbsp;<a rel="up" accesskey="u" href="Lists.html#Lists">Lists</a>
  32. <hr>
  33. </div>
  34. <h4 class="subsection">3.1.2 Recoverable Operations</h4>
  35. <p>The functions in this section are similar to the ones in the previous
  36. section except with regard to error handling. Whereas the other ones
  37. cause an error message to be printed and the process to exit in the
  38. event of an overflow, these return to the caller, whose responsibility
  39. it is to take appropriate action. The functions in both sections are
  40. declared in <samp><span class="file">lists.h</span></samp>, and should be preceded by a call to
  41. <code>avm_initialize_lists</code>.
  42. <div class="defun">
  43. &mdash; Function: list <b>avm_recoverable_join</b> (<var>list left, list right</var>)<var><a name="index-avm_005frecoverable_005fjoin-418"></a></var><br>
  44. <blockquote><p>This function is similar to <code>avm_join</code>, but will return a
  45. <code>NULL</code> pointer if memory that was needed can not be allocated. A
  46. <code>NULL</code> pointer would never be the result of a join under normal
  47. circumstances, so the overflow can be detected by the caller. Regardless
  48. of whether overflow occurs, the arguments are deallocated by this function
  49. and should not be referenced thereafter.
  50. </p></blockquote></div>
  51. <div class="defun">
  52. &mdash; Function: void <b>avm_recoverable_enqueue</b> (<var>list *front, list *back, list operand, int *fault</var>)<var><a name="index-avm_005frecoverable_005fenqueue-419"></a></var><br>
  53. <blockquote><p>This version of the enqueue function will dispose of the <var>operand</var> if there
  54. isn't room to append another item and set <code>*</code><var>fault</var> to a non-zero
  55. value. Other than that, it does the same as <code>avm_enqueue</code>.
  56. </p></blockquote></div>
  57. <div class="defun">
  58. &mdash; Function: counter <b>avm_recoverable_length</b> (<var>list operand</var>)<var><a name="index-avm_005frecoverable_005flength-420"></a></var><br>
  59. <blockquote><p>This function checks for arithmetic overflow when calculating the length
  60. of a list, and returns a zero value if overflow occurs. The caller can
  61. detect the error by noting that zero is not the length of any list other
  62. than <code>NULL</code>. This kind of overflow is impossible unless the host
  63. does not have long enough integers for its address space.
  64. </p></blockquote></div>
  65. <div class="defun">
  66. &mdash; Function: counter <b>avm_recoverable_area</b> (<var>list operand, int *fault</var>)<var><a name="index-avm_005frecoverable_005farea-421"></a></var><br>
  67. <blockquote><p>This function is similar to <code>avm_area</code>, except that it reacts
  68. differently to arithmetic overflow. The <code>fault</code> parameter should be
  69. the address of an integer known to the caller, which will be set to a
  70. non-zero value if overflow occurs. In that event, the value of zero will
  71. also be returned for the area. Note that it is possible for non-empty
  72. lists to have an area of zero, so this condition alone is not indicative
  73. of an error.
  74. </p></blockquote></div>
  75. <div class="defun">
  76. &mdash; Function: list <b>avm_recoverable_natural</b> (<var>counter number</var>)<var><a name="index-avm_005frecoverable_005fnatural-422"></a></var><br>
  77. <blockquote><p>This function returns the <code>list</code> representation of a native
  78. unsigned long integer, provided that there is enough memory, similarly to the
  79. <code>avm_natural</code> function. Unlike that function, this one will return
  80. a value of <code>NULL</code> rather than exiting the program in the event of a
  81. memory overflow. The overflow can be detected by the caller insofar as a
  82. <code>NULL</code> <code>list</code> does not represent any number other than zero.
  83. </p></blockquote></div>
  84. </body></html>