Annotation of 43BSD/lib/libc/vax/gen/setjmp.s, revision 1.1.1.1

1.1       root        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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.