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
12bf0005
Commit
12bf0005
authored
Jan 10, 2012
by
Devon H. O'Dell
Committed by
Andrew Gerrand
Jan 10, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
runtime: enable runtime.ncpu on FreeBSD
R=adg, mikioh.mikioh CC=golang-dev
https://golang.org/cl/5528062
parent
8cad9251
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
5 deletions
+66
-5
src/pkg/runtime/os_freebsd.h
src/pkg/runtime/os_freebsd.h
+6
-5
src/pkg/runtime/sys_freebsd_386.s
src/pkg/runtime/sys_freebsd_386.s
+19
-0
src/pkg/runtime/sys_freebsd_amd64.s
src/pkg/runtime/sys_freebsd_amd64.s
+16
-0
src/pkg/runtime/thread_freebsd.c
src/pkg/runtime/thread_freebsd.c
+25
-0
No files found.
src/pkg/runtime/os_freebsd.h
View file @
12bf0005
#define SIG_DFL ((void*)0)
#define SIG_IGN ((void*)1)
int32
runtime
·
thr_new
(
ThrParam
*
,
int32
);
void
runtime
·
sigpanic
(
void
);
void
runtime
·
sigaltstack
(
Sigaltstack
*
,
Sigaltstack
*
);
struct
sigaction
;
void
runtime
·
sigaction
(
int32
,
struct
sigaction
*
,
struct
sigaction
*
);
int32
runtime
·
thr_new
(
ThrParam
*
,
int32
);
void
runtime
·
sigpanic
(
void
);
void
runtime
·
sigaltstack
(
Sigaltstack
*
,
Sigaltstack
*
);
struct
sigaction
;
void
runtime
·
sigaction
(
int32
,
struct
sigaction
*
,
struct
sigaction
*
);
void
runtiem
·
setitimerval
(
int32
,
Itimerval
*
,
Itimerval
*
);
void
runtime
·
setitimer
(
int32
,
Itimerval
*
,
Itimerval
*
);
int32
runtime
·
sysctl
(
uint32
*
,
uint32
,
byte
*
,
uintptr
*
,
byte
*
,
uintptr
);
void
runtime
·
raisesigpipe
(
void
);
src/pkg/runtime/sys_freebsd_386.s
View file @
12bf0005
...
...
@@ -265,4 +265,23 @@ TEXT runtime·i386_set_ldt(SB),7,$16
INT
$
3
RET
TEXT
runtime
·
sysctl
(
SB
),7,$28
LEAL
arg0
+
0
(
FP
),
SI
LEAL
4
(
SP
),
DI
CLD
MOVSL
//
arg
1
-
name
MOVSL
//
arg
2
-
namelen
MOVSL
//
arg
3
-
oldp
MOVSL
//
arg
4
-
oldlenp
MOVSL
//
arg
5
-
newp
MOVSL
//
arg
6
-
newlen
MOVL
$
202
,
AX
//
sys___sysctl
INT
$
0x80
JCC
3
(
PC
)
NEGL
AX
RET
MOVL
$
0
,
AX
RET
GLOBL
runtime
·
tlsoffset
(
SB
),$4
src/pkg/runtime/sys_freebsd_amd64.s
View file @
12bf0005
...
...
@@ -199,3 +199,19 @@ TEXT runtime·settls(SB),7,$8
JCC
2
(
PC
)
CALL
runtime
·
notok
(
SB
)
RET
TEXT
runtime
·
sysctl
(
SB
),7,$0
MOVQ
8
(
SP
),
DI
//
arg
1
-
name
MOVL
16
(
SP
),
SI
//
arg
2
-
namelen
MOVQ
24
(
SP
),
DX
//
arg
3
-
oldp
MOVQ
32
(
SP
),
R10
//
arg
4
-
oldlenp
MOVQ
40
(
SP
),
R8
//
arg
5
-
newp
MOVQ
48
(
SP
),
R9
//
arg
6
-
newlen
MOVQ
$
202
,
AX
//
sys___sysctl
SYSCALL
JCC
3
(
PC
)
NEGL
AX
RET
MOVL
$
0
,
AX
RET
src/pkg/runtime/thread_freebsd.c
View file @
12bf0005
...
...
@@ -9,6 +9,30 @@
extern
SigTab
runtime
·
sigtab
[];
extern
int32
runtime
·
sys_umtx_op
(
uint32
*
,
int32
,
uint32
,
void
*
,
void
*
);
// From FreeBSD's <sys/sysctl.h>
#define CTL_HW 6
#define HW_NCPU 3
static
int32
getncpu
(
void
)
{
uint32
mib
[
2
];
uint32
out
;
int32
ret
;
uintptr
nout
;
// Fetch hw.ncpu via sysctl.
mib
[
0
]
=
CTL_HW
;
mib
[
1
]
=
HW_NCPU
;
nout
=
sizeof
out
;
out
=
0
;
ret
=
runtime
·
sysctl
(
mib
,
2
,
(
byte
*
)
&
out
,
&
nout
,
nil
,
0
);
if
(
ret
>=
0
)
return
out
;
else
return
1
;
}
// FreeBSD's umtx_op syscall is effectively the same as Linux's futex, and
// thus the code is largely similar. See linux/thread.c and lock_futex.c for comments.
...
...
@@ -81,6 +105,7 @@ runtime·newosproc(M *m, G *g, void *stk, void (*fn)(void))
void
runtime
·
osinit
(
void
)
{
runtime
·
ncpu
=
getncpu
();
}
void
...
...
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