4 ms·
There arent any restricting semantics in Go that makes a pure go implementation of the runtime impossible. go's void* http://golang.org/pkg/unsafe/#Pointer htt
by mortdeus 13y ago
There arent any restricting semantics in Go that makes a pure go implementation of the runtime impossible.
go's void*
http://golang.org/pkg/unsafe/#Pointer http://golang.org/pkg/unsafe/#Pointer
go's syscall mmap function. (Pure Go)
https://code.google.com/p/go/source/browse/src/pkg/syscall/zsyscall_linux_386.go#1658 https://code.google.com/p/go/source/browse/src/pkg/syscall/z...
pure go pkg with more mmap functionality.
http://godoc.org/launchpad.net/gommap http://godoc.org/launchpad.net/gommap
Go's runtime mmap function. (C)
https://code.google.com/p/go/source/browse/src/pkg/runtime/sys_linux_amd64.s#220 https://code.google.com/p/go/source/browse/src/pkg/runtime/s...
Go's base memory allocation function.
https://code.google.com/p/go/source/browse/src/pkg/runtime/mem_linux.c#52 https://code.google.com/p/go/source/browse/src/pkg/runtime/m...
Go functions body may be implemented as asm. The standard math pkg is a great example of this feature.
http://golang.org/src/pkg/math/ http://golang.org/src/pkg/math/
Considering all of these features there isnt really a whole lot about Go's semantics that prohibit it from being used in many of the low level projects that are typically written in C/C++.
- pcwalton 13y agoThe point isn't that you can't do unsafe pointer fiddling in Go—of course you can. The issue is that you don't have direct control over heap allocation. The language will heap allocate for you in ways that are not obvious.