Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
239ef63b
Commit
239ef63b
authored
Feb 10, 2011
by
Hector Chu
Committed by
Alex Brainman
Feb 10, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
runtime: take the callback return value from the stack
R=brainman, lxn, rsc CC=golang-dev
https://golang.org/cl/4126056
parent
34fc17a8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
9 deletions
+12
-9
src/pkg/runtime/cgocall.c
src/pkg/runtime/cgocall.c
+3
-6
src/pkg/runtime/cgocall.h
src/pkg/runtime/cgocall.h
+1
-1
src/pkg/runtime/runtime.h
src/pkg/runtime/runtime.h
+1
-1
src/pkg/runtime/windows/386/sys.s
src/pkg/runtime/windows/386/sys.s
+7
-1
No files found.
src/pkg/runtime/cgocall.c
View file @
239ef63b
...
...
@@ -53,13 +53,12 @@ runtime·cgocall(void (*fn)(void*), void *arg)
// (arg/argsize) on to the stack, calls the function, copies the
// arguments back where they came from, and finally returns to the old
// stack.
uintptr
void
runtime
·
cgocallback
(
void
(
*
fn
)(
void
),
void
*
arg
,
int32
argsize
)
{
Gobuf
oldsched
,
oldg1sched
;
G
*
g1
;
void
*
sp
;
uintptr
ret
;
if
(
g
!=
m
->
g0
)
runtime
·
throw
(
"bad g in cgocallback"
);
...
...
@@ -71,11 +70,11 @@ runtime·cgocallback(void (*fn)(void), void *arg, int32 argsize)
runtime
·
startcgocallback
(
g1
);
sp
=
g1
->
sched
.
sp
-
argsize
;
if
(
sp
<
g1
->
stackguard
-
StackGuard
+
4
)
// +4
for return address
if
(
sp
<
g1
->
stackguard
-
StackGuard
+
8
)
// +8
for return address
runtime
·
throw
(
"g stack overflow in cgocallback"
);
runtime
·
mcpy
(
sp
,
arg
,
argsize
);
r
et
=
r
untime
·
runcgocallback
(
g1
,
sp
,
fn
);
runtime
·
runcgocallback
(
g1
,
sp
,
fn
);
runtime
·
mcpy
(
arg
,
sp
,
argsize
);
...
...
@@ -83,8 +82,6 @@ runtime·cgocallback(void (*fn)(void), void *arg, int32 argsize)
m
->
sched
=
oldsched
;
g1
->
sched
=
oldg1sched
;
return
ret
;
}
void
...
...
src/pkg/runtime/cgocall.h
View file @
239ef63b
...
...
@@ -7,6 +7,6 @@
*/
void
runtime
·
cgocall
(
void
(
*
fn
)(
void
*
),
void
*
);
uintptr
runtime
·
cgocallback
(
void
(
*
fn
)(
void
),
void
*
,
int32
);
void
runtime
·
cgocallback
(
void
(
*
fn
)(
void
),
void
*
,
int32
);
void
*
runtime
·
cmalloc
(
uintptr
);
void
runtime
·
cfree
(
void
*
);
src/pkg/runtime/runtime.h
View file @
239ef63b
...
...
@@ -443,7 +443,7 @@ void runtime·breakpoint(void);
void
runtime
·
gosched
(
void
);
void
runtime
·
goexit
(
void
);
void
runtime
·
runcgo
(
void
(
*
fn
)(
void
*
),
void
*
);
uintptr
runtime
·
runcgocallback
(
G
*
,
void
*
,
void
(
*
fn
)());
void
runtime
·
runcgocallback
(
G
*
,
void
*
,
void
(
*
fn
)());
void
runtime
·
entersyscall
(
void
);
void
runtime
·
exitsyscall
(
void
);
void
runtime
·
startcgocallback
(
G
*
);
...
...
src/pkg/runtime/windows/386/sys.s
View file @
239ef63b
...
...
@@ -107,7 +107,11 @@ sigdone:
//
DX
=
total
size
of
arguments
//
TEXT
runtime
·
callbackasm
+0(
SB
),7,$0
//
preserve
whatever
's at the memory location that
//
the
callback
will
use
to
store
the
return
value
LEAL
8
(
SP
),
CX
PUSHL
0
(
CX
)(
DX
*
1
)
ADDL
$
4
,
DX
//
extend
argsize
by
size
of
return
value
//
save
registers
as
required
for
windows
callback
PUSHL
0
(
FS
)
...
...
@@ -129,7 +133,7 @@ TEXT runtime·callbackasm+0(SB),7,$0
CALL
runtime
·
cgocallback
(
SB
)
//
restore
registers
as
required
for
windows
callback
POPL
C
X
POPL
A
X
POPL
CX
POPL
DX
POPL
BX
...
...
@@ -139,6 +143,8 @@ TEXT runtime·callbackasm+0(SB),7,$0
POPL
0
(
FS
)
CLD
MOVL
-
4
(
CX
)(
DX
*
1
),
AX
POPL
-
4
(
CX
)(
DX
*
1
)
RET
//
void
tstart
(
M
*
newm
)
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment