home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 3 / CDPDIII.bin / pd / programming / gnuc / gen_library / rcs / setjmp.s,v < prev    next >
Encoding:
Text File  |  1992-07-04  |  3.8 KB  |  123 lines

  1. head    1.1;
  2. access;
  3. symbols
  4.     version39-41:1.1;
  5. locks;
  6. comment    @# @;
  7.  
  8.  
  9. 1.1
  10. date    92.06.08.18.31.20;    author mwild;    state Exp;
  11. branches;
  12. next    ;
  13.  
  14.  
  15. desc
  16. @initial checkin
  17. @
  18.  
  19.  
  20. 1.1
  21. log
  22. @Initial revision
  23. @
  24. text
  25. @/*-
  26.  * Copyright (c) 1990 The Regents of the University of California.
  27.  * All rights reserved.
  28.  *
  29.  * This code is derived from software contributed to Berkeley by
  30.  * the Systems Programming Group of the University of Utah Computer
  31.  * Science Department.
  32.  *
  33.  * Redistribution and use in source and binary forms, with or without
  34.  * modification, are permitted provided that the following conditions
  35.  * are met:
  36.  * 1. Redistributions of source code must retain the above copyright
  37.  *    notice, this list of conditions and the following disclaimer.
  38.  * 2. Redistributions in binary form must reproduce the above copyright
  39.  *    notice, this list of conditions and the following disclaimer in the
  40.  *    documentation and/or other materials provided with the distribution.
  41.  * 3. All advertising materials mentioning features or use of this software
  42.  *    must display the following acknowledgement:
  43.  *    This product includes software developed by the University of
  44.  *    California, Berkeley and its contributors.
  45.  * 4. Neither the name of the University nor the names of its contributors
  46.  *    may be used to endorse or promote products derived from this software
  47.  *    without specific prior written permission.
  48.  *
  49.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  50.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  51.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  52.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  53.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  54.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  55.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  56.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  57.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  58.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  59.  * SUCH DAMAGE.
  60.  */
  61.  
  62. #if defined(LIBC_SCCS) && !defined(lint)
  63.     .asciz "@@(#)setjmp.s    5.1 (Berkeley) 5/12/90"
  64. #endif /* LIBC_SCCS and not lint */
  65.  
  66. /*
  67.  * C library -- setjmp, longjmp
  68.  *
  69.  *    longjmp(a,v)
  70.  * will generate a "return(v)" from
  71.  * the last call to
  72.  *    setjmp(a)
  73.  * by restoring registers from the stack,
  74.  * and a struct sigcontext, see <signal.h>
  75.  */
  76.  
  77. #include "DEFS.h"
  78.  
  79. ENTRY(setjmp)
  80.     subql    #8,sp        /* space for sigstack args/rvals */
  81.     clrl    sp@@        /* don't change it... */
  82.     movl    sp,sp@@(4)    /* ...but return the current val */
  83.     jsr    _sigstack    /* note: onstack returned in sp@@(4) */
  84.     clrl    sp@@        /* don't change mask, just return */
  85.     jsr    _sigblock    /*   old value */
  86.     movl    sp@@(4),d1    /* old onstack value */
  87.     addql    #8,sp
  88.     movl    sp@@(4),a0    /* save area pointer */
  89.     movl    d1,a0@@+        /* save old onstack value */
  90.     movl    d0,a0@@+        /* save old signal mask */
  91.     lea    sp@@(4),a1    /* adjust saved SP since we won't rts */
  92.     movl    a1,a0@@+        /* save old SP */
  93.     movl    a5,a0@@+        /* save old FP */
  94.  
  95.     movel    4:w,a1
  96.     movew    a1@@(0x126),a0@@(2) /* use TDNestCnt and IDNestCnt from Sysbase !*/
  97.     movel    a1@@(0x114),a1    /* ThisTask */
  98.     movew    a1@@(0x0e),a0@@    /* save task-specific flags (but tdnc and idnc) */
  99.     lea    a0@@(4),a0
  100.  
  101.     movl    sp@@,a0@@+    /* save old PC */
  102.     clrl    a0@@+        /* clean PS */
  103.     moveml    d2-d7/a2-a4/a6,a0@@    /* save remaining non-scratch regs */
  104.     clrl    d0        /* return 0 */
  105.     rts
  106.  
  107. ENTRY(longjmp)
  108.     movl    sp@@(4),a0    /* save area pointer */
  109.     tstl    a0@@(8)        /* ensure non-zero SP */
  110.     jeq    botch        /* oops! */
  111.     movl    sp@@(8),d0    /* grab return value */
  112.     jne    ok        /* non-zero ok */
  113.     moveq    #1,d0        /* else make non-zero */
  114. ok:
  115.     moveml    a0@@(28),d2-d7/a2-a4/a6    /* restore non-scratch regs */
  116.     movl    a0,sp@@-        /* let sigreturn */
  117.     jsr    _sigreturn    /*   finish for us */
  118.  
  119. botch:
  120.     jsr    _longjmperror
  121.     stop    #0
  122. @
  123.