changeset 568:23db189b6713

Several functions ready.
author roug
date Thu, 31 Oct 2002 22:05:32 +0000
parents b3caab86dff9
children 3cd7606d9c7b
files docs/ccguide/longjmp.refentry
diffstat 1 files changed, 47 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/docs/ccguide/longjmp.refentry	Thu Oct 31 22:05:32 2002 +0000
+++ b/docs/ccguide/longjmp.refentry	Thu Oct 31 22:05:32 2002 +0000
@@ -1,7 +1,8 @@
 <refentry id="longjmp">
 <refnamediv>
-<refname>longjmp</refname>
-<refpurpose>Placeholder</refpurpose>
+<refname>Longjmp</refname>
+<refname>Setjmp</refname>
+<refpurpose>jump to another function</refpurpose>
 </refnamediv>
 
 <refsynopsisdiv>
@@ -10,8 +11,14 @@
 #include &lt;setjmp.h&gt;
 </funcsynopsisinfo>
 <funcprototype>
+  <funcdef><function>setjmp</function></funcdef>
+  <paramdef>jmp_buf <parameter>env</parameter></paramdef>
+</funcprototype>
+
+<funcprototype>
   <funcdef><function>longjmp</function></funcdef>
-  <paramdef>type <parameter>arg1</parameter></paramdef>
+  <paramdef>jmp_buf <parameter>env</parameter></paramdef>
+  <paramdef>int <parameter>val</parameter></paramdef>
 </funcprototype>
 </funcsynopsis>
 
@@ -19,7 +26,43 @@
 
 <refsect1><title>Description</title>
 <para>
-Placeholder
+These functions allow the return of program control directly to
+a higher level function. They are most useful when dealing
+with errors and interrupts encountered in a low level routine.
+</para>
+<para>
+"Goto" in C has scope only in the function in which it is
+used; i.e. the label which is the object of a "goto" may only
+be in the same function. Control can only be transferred
+elsewhere by means of the function call, which, of course
+returns to the caller. In certain abnormal situations a
+programmer would prefer to be able to start some section of
+code again, but this would mean returning up a ladder of
+function calls with error indications all the way.
+</para>
+<para>
+Setjmp is used to "mark" a point in the program where a
+subsequent longjmp can reach. It places in the buffer, defined
+in the header file, enough information for longjmp to restore
+the environment to that existing at the relevant call to
+setjmp.
+</para>
+<para>
+Longjmp is called with the environment buffer as an argument
+and also, a value which can be used by the caller of setjmp as,
+perhaps, an error status.
+</para>
+<para>
+To set the system up, a function will call setjmp to set up the
+buffer, and if the returned value is zero, the program will
+know that the call was the "first time through". If, however,
+the returned value is non-zero, it must be a longjmp returning
+from some deeper level of the program.
+</para>
+<para>
+NOTE that the function calling setjmp must <emphasis>not have returned</emphasis>
+at the time of calling longjmp, and the environment buffer must
+be declared <emphasis>globally</emphasis>.
 </para>
 </refsect1>
 </refentry>