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
f7f6329e
Commit
f7f6329e
authored
Aug 05, 2008
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kill trailing white space.
(apparently my first attempt didn't work.) R=r OCL=13888 CL=13888
parent
96824000
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
42 additions
and
42 deletions
+42
-42
src/runtime/chan.c
src/runtime/chan.c
+1
-1
src/runtime/proc.c
src/runtime/proc.c
+17
-17
src/runtime/rt0_amd64.s
src/runtime/rt0_amd64.s
+1
-1
src/runtime/rt1_amd64_darwin.c
src/runtime/rt1_amd64_darwin.c
+2
-2
src/runtime/rt1_amd64_linux.c
src/runtime/rt1_amd64_linux.c
+10
-10
src/runtime/rune.c
src/runtime/rune.c
+4
-4
src/runtime/runtime.c
src/runtime/runtime.c
+3
-3
src/runtime/runtime.h
src/runtime/runtime.h
+1
-1
src/runtime/sys_amd64_linux.s
src/runtime/sys_amd64_linux.s
+3
-3
No files found.
src/runtime/chan.c
View file @
f7f6329e
...
@@ -262,7 +262,7 @@ chanrecv(Hchan* c, byte *ep, bool* pres)
...
@@ -262,7 +262,7 @@ chanrecv(Hchan* c, byte *ep, bool* pres)
*
pres
=
false
;
*
pres
=
false
;
return
;
return
;
}
}
sg
=
allocsg
(
c
);
sg
=
allocsg
(
c
);
g
->
param
=
nil
;
g
->
param
=
nil
;
g
->
status
=
Gwaiting
;
g
->
status
=
Gwaiting
;
...
...
src/runtime/proc.c
View file @
f7f6329e
...
@@ -41,17 +41,17 @@ struct Sched {
...
@@ -41,17 +41,17 @@ struct Sched {
Lock
;
Lock
;
G
*
gfree
;
// available gs (status == Gdead)
G
*
gfree
;
// available gs (status == Gdead)
G
*
ghead
;
// gs waiting to run
G
*
ghead
;
// gs waiting to run
G
*
gtail
;
G
*
gtail
;
int32
gwait
;
// number of gs waiting to run
int32
gwait
;
// number of gs waiting to run
int32
gcount
;
// number of gs that are alive
int32
gcount
;
// number of gs that are alive
M
*
mhead
;
// ms waiting for work
M
*
mhead
;
// ms waiting for work
int32
mwait
;
// number of ms waiting for work
int32
mwait
;
// number of ms waiting for work
int32
mcount
;
// number of ms that are alive
int32
mcount
;
// number of ms that are alive
int32
mmax
;
// max number of ms allowed
int32
mmax
;
// max number of ms allowed
int32
predawn
;
// running initialization, don't run new gs.
int32
predawn
;
// running initialization, don't run new gs.
};
};
...
@@ -76,7 +76,7 @@ schedinit(void)
...
@@ -76,7 +76,7 @@ schedinit(void)
{
{
int32
n
;
int32
n
;
byte
*
p
;
byte
*
p
;
sched
.
mmax
=
1
;
sched
.
mmax
=
1
;
p
=
getenv
(
"gomaxprocs"
);
p
=
getenv
(
"gomaxprocs"
);
if
(
p
!=
nil
&&
(
n
=
atoi
(
p
))
!=
0
)
if
(
p
!=
nil
&&
(
n
=
atoi
(
p
))
!=
0
)
...
@@ -90,7 +90,7 @@ void
...
@@ -90,7 +90,7 @@ void
m0init
(
void
)
m0init
(
void
)
{
{
int32
i
;
int32
i
;
// Let's go.
// Let's go.
sched
.
predawn
=
0
;
sched
.
predawn
=
0
;
...
@@ -163,7 +163,7 @@ sys·newproc(int32 siz, byte* fn, byte* arg0)
...
@@ -163,7 +163,7 @@ sys·newproc(int32 siz, byte* fn, byte* arg0)
sched
.
gcount
++
;
sched
.
gcount
++
;
goidgen
++
;
goidgen
++
;
newg
->
goid
=
goidgen
;
newg
->
goid
=
goidgen
;
readylocked
(
newg
);
readylocked
(
newg
);
unlock
(
&
sched
);
unlock
(
&
sched
);
...
@@ -205,7 +205,7 @@ static G*
...
@@ -205,7 +205,7 @@ static G*
gget
(
void
)
gget
(
void
)
{
{
G
*
g
;
G
*
g
;
g
=
sched
.
ghead
;
g
=
sched
.
ghead
;
if
(
g
){
if
(
g
){
sched
.
ghead
=
g
->
schedlink
;
sched
.
ghead
=
g
->
schedlink
;
...
@@ -230,7 +230,7 @@ static M*
...
@@ -230,7 +230,7 @@ static M*
mget
(
void
)
mget
(
void
)
{
{
M
*
m
;
M
*
m
;
m
=
sched
.
mhead
;
m
=
sched
.
mhead
;
if
(
m
){
if
(
m
){
sched
.
mhead
=
m
->
schedlink
;
sched
.
mhead
=
m
->
schedlink
;
...
@@ -252,7 +252,7 @@ static G*
...
@@ -252,7 +252,7 @@ static G*
gfget
(
void
)
gfget
(
void
)
{
{
G
*
g
;
G
*
g
;
g
=
sched
.
gfree
;
g
=
sched
.
gfree
;
if
(
g
)
if
(
g
)
sched
.
gfree
=
g
->
schedlink
;
sched
.
gfree
=
g
->
schedlink
;
...
@@ -267,7 +267,7 @@ ready(G *g)
...
@@ -267,7 +267,7 @@ ready(G *g)
// have queued itself on a channel but not yet gotten
// have queued itself on a channel but not yet gotten
// a chance to call sys·gosched and actually go to sleep).
// a chance to call sys·gosched and actually go to sleep).
notesleep
(
&
g
->
stopped
);
notesleep
(
&
g
->
stopped
);
lock
(
&
sched
);
lock
(
&
sched
);
readylocked
(
g
);
readylocked
(
g
);
unlock
(
&
sched
);
unlock
(
&
sched
);
...
@@ -300,7 +300,7 @@ readylocked(G *g)
...
@@ -300,7 +300,7 @@ readylocked(G *g)
m
->
nextg
=
g
;
m
->
nextg
=
g
;
notewakeup
(
&
m
->
havenextg
);
notewakeup
(
&
m
->
havenextg
);
}
}
// Else put g on queue, kicking off new m if needed.
// Else put g on queue, kicking off new m if needed.
else
{
else
{
gput
(
g
);
gput
(
g
);
...
@@ -327,7 +327,7 @@ nextgandunlock(void)
...
@@ -327,7 +327,7 @@ nextgandunlock(void)
m
->
nextg
=
nil
;
m
->
nextg
=
nil
;
noteclear
(
&
m
->
havenextg
);
noteclear
(
&
m
->
havenextg
);
unlock
(
&
sched
);
unlock
(
&
sched
);
notesleep
(
&
m
->
havenextg
);
notesleep
(
&
m
->
havenextg
);
if
((
gp
=
m
->
nextg
)
==
nil
)
if
((
gp
=
m
->
nextg
)
==
nil
)
throw
(
"bad m->nextg in nextgoroutine"
);
throw
(
"bad m->nextg in nextgoroutine"
);
...
@@ -373,7 +373,7 @@ scheduler(void)
...
@@ -373,7 +373,7 @@ scheduler(void)
// Find (or wait for) g to run. Unlocks sched.
// Find (or wait for) g to run. Unlocks sched.
gp
=
nextgandunlock
();
gp
=
nextgandunlock
();
noteclear
(
&
gp
->
stopped
);
noteclear
(
&
gp
->
stopped
);
gp
->
status
=
Grunning
;
gp
->
status
=
Grunning
;
m
->
curg
=
gp
;
m
->
curg
=
gp
;
...
@@ -406,13 +406,13 @@ mnew(void)
...
@@ -406,13 +406,13 @@ mnew(void)
M
*
m
;
M
*
m
;
G
*
g
;
G
*
g
;
byte
*
stk
,
*
stktop
;
byte
*
stk
,
*
stktop
;
sched
.
mcount
++
;
sched
.
mcount
++
;
if
(
debug
){
if
(
debug
){
sys
·
printint
(
sched
.
mcount
);
sys
·
printint
(
sched
.
mcount
);
prints
(
" threads
\n
"
);
prints
(
" threads
\n
"
);
}
}
// Allocate m, g, stack in one chunk.
// Allocate m, g, stack in one chunk.
// 1024 and 104 are the magic constants
// 1024 and 104 are the magic constants
// use in rt0_amd64.s when setting up g0.
// use in rt0_amd64.s when setting up g0.
...
@@ -420,7 +420,7 @@ mnew(void)
...
@@ -420,7 +420,7 @@ mnew(void)
g
=
(
G
*
)(
m
+
1
);
g
=
(
G
*
)(
m
+
1
);
stk
=
(
byte
*
)
g
+
104
;
stk
=
(
byte
*
)
g
+
104
;
stktop
=
stk
+
1024
;
stktop
=
stk
+
1024
;
m
->
g0
=
g
;
m
->
g0
=
g
;
g
->
stackguard
=
stk
;
g
->
stackguard
=
stk
;
g
->
stackbase
=
stktop
;
g
->
stackbase
=
stktop
;
...
@@ -521,7 +521,7 @@ newstack(void)
...
@@ -521,7 +521,7 @@ newstack(void)
m
->
curg
->
stackguard
=
stk
+
160
;
m
->
curg
->
stackguard
=
stk
+
160
;
sp
=
(
byte
*
)
top
;
sp
=
(
byte
*
)
top
;
if
(
siz2
>
0
)
{
if
(
siz2
>
0
)
{
siz2
=
(
siz2
+
7
)
&
~
7
;
siz2
=
(
siz2
+
7
)
&
~
7
;
sp
-=
siz2
;
sp
-=
siz2
;
...
...
src/runtime/rt0_amd64.s
View file @
f7f6329e
...
@@ -35,7 +35,7 @@ TEXT _rt0_amd64(SB),7,$-8
...
@@ -35,7 +35,7 @@ TEXT _rt0_amd64(SB),7,$-8
CALL
args
(
SB
)
CALL
args
(
SB
)
CALL
schedinit
(
SB
)
CALL
schedinit
(
SB
)
CALL
main
·
init_function
(
SB
)
//
initialization
CALL
main
·
init_function
(
SB
)
//
initialization
//
create
a
new
goroutine
to
start
program
//
create
a
new
goroutine
to
start
program
PUSHQ
$main
·
main
(
SB
)
//
entry
PUSHQ
$main
·
main
(
SB
)
//
entry
...
...
src/runtime/rt1_amd64_darwin.c
View file @
f7f6329e
...
@@ -146,11 +146,11 @@ sighandler(int32 sig, siginfo *info, void *context)
...
@@ -146,11 +146,11 @@ sighandler(int32 sig, siginfo *info, void *context)
prints
(
"
\n
Faulting address: 0x"
);
sys
·
printpointer
(
info
->
si_addr
);
prints
(
"
\n
Faulting address: 0x"
);
sys
·
printpointer
(
info
->
si_addr
);
prints
(
"
\n
pc: 0x"
);
sys
·
printpointer
((
void
*
)
ss
->
__rip
);
prints
(
"
\n
pc: 0x"
);
sys
·
printpointer
((
void
*
)
ss
->
__rip
);
prints
(
"
\n\n
"
);
prints
(
"
\n\n
"
);
traceback
((
void
*
)
ss
->
__rip
,
(
void
*
)
ss
->
__rsp
,
(
void
*
)
ss
->
__r15
);
traceback
((
void
*
)
ss
->
__rip
,
(
void
*
)
ss
->
__rsp
,
(
void
*
)
ss
->
__r15
);
tracebackothers
((
void
*
)
ss
->
__r15
);
tracebackothers
((
void
*
)
ss
->
__r15
);
print_thread_state
(
ss
);
print_thread_state
(
ss
);
sys
·
exit
(
2
);
sys
·
exit
(
2
);
}
}
...
...
src/runtime/rt1_amd64_linux.c
View file @
f7f6329e
...
@@ -187,10 +187,10 @@ initsig(void)
...
@@ -187,10 +187,10 @@ initsig(void)
// Futexsleep is allowed to wake up spuriously.
// Futexsleep is allowed to wake up spuriously.
enum
enum
{
{
FUTEX_WAIT
=
0
,
FUTEX_WAIT
=
0
,
FUTEX_WAKE
=
1
,
FUTEX_WAKE
=
1
,
EINTR
=
4
,
EINTR
=
4
,
EAGAIN
=
11
,
EAGAIN
=
11
,
};
};
...
@@ -213,7 +213,7 @@ static void
...
@@ -213,7 +213,7 @@ static void
futexsleep
(
uint32
*
addr
,
uint32
val
)
futexsleep
(
uint32
*
addr
,
uint32
val
)
{
{
int64
ret
;
int64
ret
;
ret
=
futex
(
addr
,
FUTEX_WAIT
,
val
,
&
longtime
,
nil
,
0
);
ret
=
futex
(
addr
,
FUTEX_WAIT
,
val
,
&
longtime
,
nil
,
0
);
if
(
ret
>=
0
||
ret
==
-
EAGAIN
||
ret
==
-
EINTR
)
if
(
ret
>=
0
||
ret
==
-
EAGAIN
||
ret
==
-
EINTR
)
return
;
return
;
...
@@ -233,14 +233,14 @@ static void
...
@@ -233,14 +233,14 @@ static void
futexwakeup
(
uint32
*
addr
)
futexwakeup
(
uint32
*
addr
)
{
{
int64
ret
;
int64
ret
;
ret
=
futex
(
addr
,
FUTEX_WAKE
,
1
,
nil
,
nil
,
0
);
ret
=
futex
(
addr
,
FUTEX_WAKE
,
1
,
nil
,
nil
,
0
);
if
(
ret
>=
0
)
if
(
ret
>=
0
)
return
;
return
;
// I don't know that futex wakeup can return
// I don't know that futex wakeup can return
// EAGAIN or EINTR, but if it does, it would be
// EAGAIN or EINTR, but if it does, it would be
// safe to loop and call futex again.
// safe to loop and call futex again.
prints
(
"futexwakeup addr="
);
prints
(
"futexwakeup addr="
);
...
@@ -279,11 +279,11 @@ again:
...
@@ -279,11 +279,11 @@ again:
}
}
goto
again
;
goto
again
;
}
}
// Lock was held; try to add ourselves to the waiter count.
// Lock was held; try to add ourselves to the waiter count.
if
(
!
cas
(
&
l
->
key
,
v
,
v
+
2
))
if
(
!
cas
(
&
l
->
key
,
v
,
v
+
2
))
goto
again
;
goto
again
;
// We're accounted for, now sleep in the kernel.
// We're accounted for, now sleep in the kernel.
//
//
// We avoid the obvious lock/unlock race because
// We avoid the obvious lock/unlock race because
...
@@ -294,7 +294,7 @@ again:
...
@@ -294,7 +294,7 @@ again:
// and in fact there is a futex variant that could
// and in fact there is a futex variant that could
// accomodate that check, but let's not get carried away.)
// accomodate that check, but let's not get carried away.)
futexsleep
(
&
l
->
key
,
v
+
2
);
futexsleep
(
&
l
->
key
,
v
+
2
);
// We're awake: remove ourselves from the count.
// We're awake: remove ourselves from the count.
for
(;;){
for
(;;){
v
=
l
->
key
;
v
=
l
->
key
;
...
@@ -303,7 +303,7 @@ again:
...
@@ -303,7 +303,7 @@ again:
if
(
cas
(
&
l
->
key
,
v
,
v
-
2
))
if
(
cas
(
&
l
->
key
,
v
,
v
-
2
))
break
;
break
;
}
}
// Try for the lock again.
// Try for the lock again.
goto
again
;
goto
again
;
}
}
...
@@ -388,7 +388,7 @@ newosproc(M *m, G *g, void *stk, void (*fn)(void))
...
@@ -388,7 +388,7 @@ newosproc(M *m, G *g, void *stk, void (*fn)(void))
{
{
int64
ret
;
int64
ret
;
int32
flags
;
int32
flags
;
flags
=
CLONE_PARENT
/* getppid doesn't change in child */
flags
=
CLONE_PARENT
/* getppid doesn't change in child */
|
CLONE_VM
/* share memory */
|
CLONE_VM
/* share memory */
|
CLONE_FS
/* share cwd, etc */
|
CLONE_FS
/* share cwd, etc */
...
...
src/runtime/rune.c
View file @
f7f6329e
...
@@ -26,7 +26,7 @@ enum
...
@@ -26,7 +26,7 @@ enum
Bit2
=
5
,
Bit2
=
5
,
Bit3
=
4
,
Bit3
=
4
,
Bit4
=
3
,
Bit4
=
3
,
Bit5
=
2
,
Bit5
=
2
,
T1
=
((
1
<<
(
Bit1
+
1
))
-
1
)
^
0xFF
,
/* 0000 0000 */
T1
=
((
1
<<
(
Bit1
+
1
))
-
1
)
^
0xFF
,
/* 0000 0000 */
Tx
=
((
1
<<
(
Bitx
+
1
))
-
1
)
^
0xFF
,
/* 1000 0000 */
Tx
=
((
1
<<
(
Bitx
+
1
))
-
1
)
^
0xFF
,
/* 1000 0000 */
...
@@ -48,15 +48,15 @@ enum
...
@@ -48,15 +48,15 @@ enum
Runeself
=
0x80
,
Runeself
=
0x80
,
Bad
=
Runeerror
,
Bad
=
Runeerror
,
Runemax
=
0x10FFFF
,
/* maximum rune value */
Runemax
=
0x10FFFF
,
/* maximum rune value */
};
};
/*
/*
* Modified by Wei-Hwa Huang, Google Inc., on 2004-09-24
* Modified by Wei-Hwa Huang, Google Inc., on 2004-09-24
* This is a slower but "safe" version of the old chartorune
* This is a slower but "safe" version of the old chartorune
* that works on strings that are not necessarily null-terminated.
* that works on strings that are not necessarily null-terminated.
*
*
* If you know for sure that your string is null-terminated,
* If you know for sure that your string is null-terminated,
* chartorune will be a bit faster.
* chartorune will be a bit faster.
*
*
...
...
src/runtime/runtime.c
View file @
f7f6329e
...
@@ -512,7 +512,7 @@ getenv(int8 *s)
...
@@ -512,7 +512,7 @@ getenv(int8 *s)
{
{
int32
i
,
j
,
len
;
int32
i
,
j
,
len
;
byte
*
v
,
*
bs
;
byte
*
v
,
*
bs
;
bs
=
(
byte
*
)
s
;
bs
=
(
byte
*
)
s
;
len
=
findnull
(
s
);
len
=
findnull
(
s
);
for
(
i
=
0
;
i
<
envc
;
i
++
){
for
(
i
=
0
;
i
<
envc
;
i
++
){
...
@@ -532,7 +532,7 @@ int32
...
@@ -532,7 +532,7 @@ int32
atoi
(
byte
*
p
)
atoi
(
byte
*
p
)
{
{
int32
n
;
int32
n
;
n
=
0
;
n
=
0
;
while
(
'0'
<=
*
p
&&
*
p
<=
'9'
)
while
(
'0'
<=
*
p
&&
*
p
<=
'9'
)
n
=
n
*
10
+
*
p
++
-
'0'
;
n
=
n
*
10
+
*
p
++
-
'0'
;
...
@@ -635,7 +635,7 @@ check(void)
...
@@ -635,7 +635,7 @@ check(void)
throw
(
"cas1"
);
throw
(
"cas1"
);
if
(
z
!=
2
)
if
(
z
!=
2
)
throw
(
"cas2"
);
throw
(
"cas2"
);
z
=
4
;
z
=
4
;
if
(
cas
(
&
z
,
5
,
6
))
if
(
cas
(
&
z
,
5
,
6
))
throw
(
"cas3"
);
throw
(
"cas3"
);
...
...
src/runtime/runtime.h
View file @
f7f6329e
...
@@ -243,7 +243,7 @@ void unlock(Lock*);
...
@@ -243,7 +243,7 @@ void unlock(Lock*);
/*
/*
* sleep and wakeup on one-time events.
* sleep and wakeup on one-time events.
* before any calls to notesleep or notewakeup,
* before any calls to notesleep or notewakeup,
* must call noteclear to initialize the Note.
* must call noteclear to initialize the Note.
* then, any number of threads can call notesleep
* then, any number of threads can call notesleep
* and exactly one thread can call notewakeup (once).
* and exactly one thread can call notewakeup (once).
...
...
src/runtime/sys_amd64_linux.s
View file @
f7f6329e
...
@@ -146,7 +146,7 @@ TEXT futex(SB),7,$0
...
@@ -146,7 +146,7 @@ TEXT futex(SB),7,$0
TEXT
clone
(
SB
),7,$0
TEXT
clone
(
SB
),7,$0
MOVL
flags
+
8
(
SP
),
DI
MOVL
flags
+
8
(
SP
),
DI
MOVQ
stack
+
16
(
SP
),
SI
MOVQ
stack
+
16
(
SP
),
SI
//
Copy
m
,
g
,
fn
off
parent
stack
for
use
by
child
.
//
Copy
m
,
g
,
fn
off
parent
stack
for
use
by
child
.
//
Careful
:
Linux
system
call
clobbers
CX
and
R11
.
//
Careful
:
Linux
system
call
clobbers
CX
and
R11
.
MOVQ
m
+
24
(
SP
),
R8
MOVQ
m
+
24
(
SP
),
R8
...
@@ -160,13 +160,13 @@ TEXT clone(SB),7,$0
...
@@ -160,13 +160,13 @@ TEXT clone(SB),7,$0
CMPQ
AX
,
$
0
CMPQ
AX
,
$
0
JEQ
2
(
PC
)
JEQ
2
(
PC
)
RET
RET
//
In
child
,
call
fn
on
new
stack
//
In
child
,
call
fn
on
new
stack
MOVQ
SI
,
SP
MOVQ
SI
,
SP
MOVQ
R8
,
R14
//
m
MOVQ
R8
,
R14
//
m
MOVQ
R9
,
R15
//
g
MOVQ
R9
,
R15
//
g
CALL
R12
CALL
R12
//
It
shouldn
't return. If it does, exi
//
It
shouldn
't return. If it does, exi
MOVL
$
111
,
DI
MOVL
$
111
,
DI
MOVL
$
60
,
AX
MOVL
$
60
,
AX
...
...
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