]> Cypherpunks.ru repositories - gostls13.git/blob - src/runtime/cgo/asm_s390x.s
runtime/cgo: store M for C-created thread in pthread key
[gostls13.git] / src / runtime / cgo / asm_s390x.s
1 // Copyright 2016 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 #include "textflag.h"
6
7 // Set the x_crosscall2_ptr C function pointer variable point to crosscall2.
8 // It's such a pointer chain: _crosscall2_ptr -> x_crosscall2_ptr -> crosscall2
9 TEXT ·set_crosscall2(SB),NOSPLIT,$0-0
10         MOVD    _crosscall2_ptr(SB), R1
11         MOVD    $crosscall2(SB), R2
12         MOVD    R2, (R1)
13         RET
14
15 // Called by C code generated by cmd/cgo.
16 // func crosscall2(fn, a unsafe.Pointer, n int32, ctxt uintptr)
17 // Saves C callee-saved registers and calls cgocallback with three arguments.
18 // fn is the PC of a func(a unsafe.Pointer) function.
19 TEXT crosscall2(SB),NOSPLIT|NOFRAME,$0
20         // Start with standard C stack frame layout and linkage.
21
22         // Save R6-R15 in the register save area of the calling function.
23         STMG    R6, R15, 48(R15)
24
25         // Allocate 96 bytes on the stack.
26         MOVD    $-96(R15), R15
27
28         // Save F8-F15 in our stack frame.
29         FMOVD   F8, 32(R15)
30         FMOVD   F9, 40(R15)
31         FMOVD   F10, 48(R15)
32         FMOVD   F11, 56(R15)
33         FMOVD   F12, 64(R15)
34         FMOVD   F13, 72(R15)
35         FMOVD   F14, 80(R15)
36         FMOVD   F15, 88(R15)
37
38         // Initialize Go ABI environment.
39         BL      runtime·load_g(SB)
40
41         MOVD    R2, 8(R15)      // fn unsafe.Pointer
42         MOVD    R3, 16(R15)     // a unsafe.Pointer
43         // Skip R4 = n uint32
44         MOVD    R5, 24(R15)     // ctxt uintptr
45         BL      runtime·cgocallback(SB)
46
47         FMOVD   32(R15), F8
48         FMOVD   40(R15), F9
49         FMOVD   48(R15), F10
50         FMOVD   56(R15), F11
51         FMOVD   64(R15), F12
52         FMOVD   72(R15), F13
53         FMOVD   80(R15), F14
54         FMOVD   88(R15), F15
55
56         // De-allocate stack frame.
57         MOVD    $96(R15), R15
58
59         // Restore R6-R15.
60         LMG     48(R15), R6, R15
61
62         RET
63