1: /*
   2:  * Copyright (c) 1983 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  */
   6: 
   7: #ifdef LIBC_SCCS
   8:         .asciz  "@(#)setjmp.s	5.5 (Berkeley) 3/9/86"
   9: #endif LIBC_SCCS
  10: 
  11: /*
  12:  * C library -- setjmp, longjmp
  13:  *
  14:  *	longjmp(a,v)
  15:  * will generate a "return(v)" from
  16:  * the last call to
  17:  *	setjmp(a)
  18:  * by restoring registers from the stack,
  19:  * and a struct sigcontext, see <signal.h>
  20:  */
  21: 
  22: #include "DEFS.h"
  23: 
  24: ENTRY(setjmp, R6)
  25:         movl    4(ap),r6                # construct sigcontext
  26:         subl2   $8,sp                   # space for current struct sigstack
  27:         pushl   sp                      # get current values
  28:         pushl   $0                      # no new values
  29:         calls   $3,_sigstack            # pop args plus signal stack value
  30:         movl    (sp)+,(r6)+             # save onsigstack status of caller
  31:         pushl   $0
  32:         calls   $1,_sigblock            # get signal mask
  33:         movl    r0,(r6)+                # save signal mask of caller
  34:         movl    (ap),r0
  35:         moval   4(ap)[r0],(r6)+         # save sp of caller
  36:         movl    12(fp),(r6)+            # save frame pointer of caller
  37:         movl    8(fp),(r6)+             # save argument pointer of caller
  38:         movl    16(fp),(r6)+            # save pc of caller
  39:         movpsl  (r6)                    # save psl of caller
  40:         movw    4(fp),(r6)
  41:         clrl    r0
  42:         ret
  43: 
  44: ENTRY(longjmp, 0)
  45:         movl    8(ap),r0                # return(v)
  46:         movl    4(ap),r1                # fetch buffer
  47:         tstl    12(r1)
  48:         beql    botch
  49: loop:
  50:         cmpl    12(r1),fp               # are we there yet?
  51:         beql    done
  52:         blssu   botch
  53:         moval   20(fp),r2
  54:         blbc    6(fp),1f                # was r0 saved?
  55:         movl    r0,(r2)+
  56: 1:
  57:         bbc     $1,6(fp),2f             # was r1 saved?
  58:         movl    r1,(r2)
  59: 2:
  60:         movl    $loop,16(fp)
  61:         ret                             # pop another frame
  62: 
  63: done:
  64: 
  65: #ifndef NOCOMPAT
  66: /*
  67:  * This code checks to see if it can use the new sigreturn.
  68:  * If it finds that sigtramp is using the new system call,
  69:  * it will also use it. Otherwise it uses the old system call
  70:  * to preserve compatibility.
  71:  */
  72: #include <vax/machparam.h>
  73: #define U (0x80000000-UPAGES*NBPG)
  74: #define PCB_SIGC 0x6c
  75: #define CHMKINS 7
  76:         cmpl    3f,U+PCB_SIGC+CHMKINS   # check to see how sigtramp returns
  77:         beql    4f                      # sigtramp uses the new system call
  78:         pushl   r1                      # must use the old signal return
  79:         chmk    $139                    # restore previous context
  80:         jmp     *20(r1)                 # done, return
  81: 3:
  82:         chmk    $103                    # the new system call for sigreturn
  83: 4:
  84: #endif NOCOMPAT
  85: 
  86:         pushl   r1                      # pointer to sigcontext
  87:         calls   $1,_sigreturn           # restore previous context
  88:                                         # we should never return
  89: botch:
  90:         calls   $0,_longjmperror
  91:         halt

Defined functions

_longjmp defined in line 44; used 202 times
_setjmp defined in line 24; used 242 times
botch defined in line 89; used 2 times
done defined in line 63; used 1 times
  • in line 51
loop defined in line 49; used 1 times
  • in line 60

Defined macros

CHMKINS defined in line 75; used 1 times
  • in line 76
PCB_SIGC defined in line 74; used 1 times
  • in line 76
U defined in line 73; used 1 times
  • in line 76
Last modified: 1986-03-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 750
Valid CSS Valid XHTML 1.0 Strict