check that link() doesn't cause statinfo to be corrupted/reverted for
[arla.git] / lwp / process.aix22.S
blob05d7725d6f702f69484c2ac720fa65a555c5a8ad
1 /* $Id$ */
3 /*
4 ****************************************************************************
5 *        Copyright IBM Corporation 1988, 1989 - All Rights Reserved        *
6 *                                                                          *
7 * Permission to use, copy, modify, and distribute this software and its    *
8 * documentation for any purpose and without fee is hereby granted,         *
9 * provided that the above copyright notice appear in all copies and        *
10 * that both that copyright notice and this permission notice appear in     *
11 * supporting documentation, and that the name of IBM not be used in        *
12 * advertising or publicity pertaining to distribution of the software      *
13 * without specific, written prior permission.                              *
14 *                                                                          *
15 * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL *
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL IBM *
17 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY      *
18 * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER  *
19 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING   *
20 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.    *
21 ****************************************************************************
24 #include <config.h>
26 #undef RCSID
30 #       Information Technology Center
31 #       Carnegie-Mellon University
36 #       Process assembly language assist for Sailboats.
40         .text
41         .globl  .savecontext
42         .align 1
46 # struct savearea {
47 #       char    *topstack;
48 # }
53 /*# Offsets of fields*/
54 .set topstack,0
56 /*# Stuff to allow saving/restoring registers*/
57 .set regspace,64
58 .set freg,0
62 # savecontext(f, area1, newsp)
63 #    int (*f)(); struct savearea *area1; char *newsp;
67 .savecontext:
68         ai      1,1,-regspace           # Save frame pointer & ...
70 /*# Save registers*/
71         stm     0,0(1)                  # Change this if save fewer regs.
72         lr      14,0
73 /*# Set preemption semaphore*/
74         lis     6,1
75         l       7,4(14)
76         sts     6,0(7)
77 /*# r3 = base of savearea*/
78         st      1,topstack(3)           # area1->topstack = sp
79 /*# New sp is in r4.*/
80         ci      4,0
81         beq     L1                      # If newsp == 0, no stack switch
82         cas     1,4,0                   # Switch to new stack
83 L1:
84         l       6,0(2)                  # r2 = _f
85         balrx   15,6                    # f()
86         cas     0,2,0
87         .data   3
88         .globl  _savecontext
89 _savecontext:
90         .long   .savecontext
91         .long   _PRE_Block
94 # returnto(area2)
95 #     struct savearea *area2;
99         .text
100         .globl  .returnto
101         .align 1
102 .returnto:
103         l       1,topstack(2)
105 # Now in the context of the savecontext stack to be restored.
106 # Start with the registers...
107 # Clear preemption semaphore
109         lr      14,0
110         lis     6,0
111         l       7,4(14)
112         sts     6,0(7)
113         lm      0,0(1)          # Change if saving fewer regs.
114         brx     15              # Return to previous process
115         ai      1,1,regspace
116         .data   3
117         .globl  _returnto
118 _returnto:
119         .long   .returnto
120         .long   _PRE_Block