s***@oracle.com
2015-07-30 22:24:40 UTC
Greetings,
I have a number of fixes I need to make to the Solaris port of the sys
package. As part of the changes for Go 1.5, the Solaris port of Go now has
full support for cgo, et al.
I noticed that the internal packages in Go, such as syscall, do something
like this to get access to the function addresses:
//go:cgo_import_dynamic libc_Getpgid getpgid "libc.so"
//go:linkname libc_Getpgid libc_Getpgid
var (
libc_Getpgid
)
...and then something like this to actually call them:
r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&libc_Getpgid)), 1,
uintptr(pid), 0, 0, 0, 0, 0)
I couldn't find any documentation on cgo_import_dynamic or the linkname
directives. Are these only intended for use within the Go "core"
packages? Is "sys" one of those packages?
Of course, searching through the source led me to the relevant lexer code:
https://github.com/golang/go/blob/75d779566b75fc1a09239bfbca40b6dba42000fd/src/cmd/compile/internal/gc/lex.go#L1729
...but that's not particularly enlightening either.
Is cgo_import_dynamic just a historical name for the documented
"-dynlinker" option cgo has?
What exactly is linkname for; just a convenient way to bind the address of
a function to a variable?
Next, when should a package use sysvicall6() or the like instead of just
calling the function?
Finally, why do those packages use that syntax instead of the documented
cgo syntax of:
//#include <someheaderfile.h>
import "C"
C.libc_Getpgid(...)
?
-Shawn
I have a number of fixes I need to make to the Solaris port of the sys
package. As part of the changes for Go 1.5, the Solaris port of Go now has
full support for cgo, et al.
I noticed that the internal packages in Go, such as syscall, do something
like this to get access to the function addresses:
//go:cgo_import_dynamic libc_Getpgid getpgid "libc.so"
//go:linkname libc_Getpgid libc_Getpgid
var (
libc_Getpgid
)
...and then something like this to actually call them:
r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&libc_Getpgid)), 1,
uintptr(pid), 0, 0, 0, 0, 0)
I couldn't find any documentation on cgo_import_dynamic or the linkname
directives. Are these only intended for use within the Go "core"
packages? Is "sys" one of those packages?
Of course, searching through the source led me to the relevant lexer code:
https://github.com/golang/go/blob/75d779566b75fc1a09239bfbca40b6dba42000fd/src/cmd/compile/internal/gc/lex.go#L1729
...but that's not particularly enlightening either.
Is cgo_import_dynamic just a historical name for the documented
"-dynlinker" option cgo has?
What exactly is linkname for; just a convenient way to bind the address of
a function to a variable?
Next, when should a package use sysvicall6() or the like instead of just
calling the function?
Finally, why do those packages use that syntax instead of the documented
cgo syntax of:
//#include <someheaderfile.h>
import "C"
C.libc_Getpgid(...)
?
-Shawn
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.