setjmp man page on Plan9

Man page or keyword search:  
man Server   549 pages
apropos Keyword Search (all sections)
Output format
Plan9 logo
[printable version]

SETJMP(2)							     SETJMP(2)

NAME
       setjmp, longjmp, notejmp - non-local goto

SYNOPSIS
       #include <u.h>
       #include <libc.h>

       int  setjmp(jmp_buf env)

       void longjmp(jmp_buf env, int val)

       void notejmp(void *uregs, jmp_buf env, int val)

DESCRIPTION
       These  routines	are  useful  for  dealing  with	 errors and interrupts
       encountered in a low-level subroutine of a program.

       Setjmp saves its stack environment in env for later use by longjmp.  It
       returns value 0.

       Longjmp	restores the environment saved by the last call of setjmp.  It
       then causes execution to continue as if the call	 of  setjmp  had  just
       returned	 with  value  val.  The invoker of setjmp must not itself have
       returned in the interim.	 All accessible data have  values  as  of  the
       time longjmp was called.

       Notejmp	is  the	 same  as  longjmp except that it is to be called from
       within a note handler (see notify(2)).  The uregs  argument  should  be
       the first argument passed to the note handler.

       Setjmp  and  longjmp can also be used to switch stacks.	Several macros
       are defined in /$objtype/include/u.h that can be used to build jmp_bufs
       by  hand.   The following code establishes a jmp_buf that may be called
       by longjmp to begin execution in a function f with 1024 bytes of stack:

	      #include <u.h>
	      #include <libc.h>

	      jmp_buf label;
	      #define NSTACK 1024
	      char stack[NSTACK];

	      void
	      setlabel(void)
	      {
		   label[JMPBUFPC] = ((ulong)f+JMPBUFDPC);
		   /* -2 leaves room for old pc and new pc in frame */
		   label[JMPBUFSP] =
			   (ulong)(&stack[NSTACK-2*sizeof(ulong*)]);
	      }

SOURCE
       /sys/src/libc/$objtype/setjmp.s
       /sys/src/libc/$objtype/notejmp.c

SEE ALSO
       notify(2)

BUGS
       Notejmp cannot recover from an address trap or bus error	 (page	fault)
       on the 680x0 architectures.

								     SETJMP(2)
[top]
                             _         _         _ 
                            | |       | |       | |     
                            | |       | |       | |     
                         __ | | __ __ | | __ __ | | __  
                         \ \| |/ / \ \| |/ / \ \| |/ /  
                          \ \ / /   \ \ / /   \ \ / /   
                           \   /     \   /     \   /    
                            \_/       \_/       \_/ 
More information is available in HTML format for server Plan9

List of man pages available for Plan9

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net