]> Cypherpunks.ru repositories - gostls13.git/blob - src/runtime/cgo/asm_386.s
runtime/cgo: store M for C-created thread in pthread key
[gostls13.git] / src / runtime / cgo / asm_386.s
1 // Copyright 2009 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         MOVL    _crosscall2_ptr(SB), AX
11         MOVL    $crosscall2(SB), BX
12         MOVL    BX, (AX)
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,$28-16
20         MOVL BP, 24(SP)
21         MOVL BX, 20(SP)
22         MOVL SI, 16(SP)
23         MOVL DI, 12(SP)
24
25         MOVL    ctxt+12(FP), AX
26         MOVL    AX, 8(SP)
27         MOVL    a+4(FP), AX
28         MOVL    AX, 4(SP)
29         MOVL    fn+0(FP), AX
30         MOVL    AX, 0(SP)
31         CALL    runtime·cgocallback(SB)
32
33         MOVL 12(SP), DI
34         MOVL 16(SP), SI
35         MOVL 20(SP), BX
36         MOVL 24(SP), BP
37         RET