all: basic support for the os package

The resulting binary is pretty big due to lacking optimizations
(probably because of interfaces), so that should be fixed.
This commit is contained in:
Ayke van Laethem
2018-09-15 18:54:36 +02:00
parent c237633d34
commit 1484bb5c2c
6 changed files with 141 additions and 3 deletions
+24
View File
@@ -0,0 +1,24 @@
package runtime
// This file contains implementations for the sync/atomic package.
// All implementations assume there are no goroutines, threads or interrupts.
//go:linkname loadUint64 sync/atomic.LoadUint64
func loadUint64(addr *uint64) uint64 {
return *addr
}
//go:linkname storeUint32 sync/atomic.StoreUint32
func storeUint32(addr *uint32, val uint32) {
*addr = val
}
//go:linkname compareAndSwapUint64 sync/atomic.CompareAndSwapUint64
func compareAndSwapUint64(addr *uint64, old, new uint64) bool {
if *addr == old {
*addr = new
return true
}
return false
}
+23
View File
@@ -0,0 +1,23 @@
package runtime
// This file implements stub functions for internal/poll.
//go:linkname poll_runtime_pollServerInit internal/poll.runtime_pollServerInit
func poll_runtime_pollServerInit(ctx *uint8) {
panic("todo: runtime_pollServerInit")
}
//go:linkname poll_runtime_pollOpen internal/poll.runtime_pollOpen
func poll_runtime_pollOpen(fd uintptr) (uintptr, int) {
panic("todo: runtime_pollOpen")
}
//go:linkname poll_runtime_pollClose internal/poll.runtime_pollClose
func poll_runtime_pollClose(ctx uintptr) {
panic("todo: runtime_pollClose")
}
//go:linkname poll_runtime_pollUnblock internal/poll.runtime_pollUnblock
func poll_runtime_pollUnblock(ctx uintptr) {
panic("todo: runtime_pollUnblock")
}
+5
View File
@@ -49,6 +49,11 @@ func GOROOT() string {
return "/usr/local/go"
}
//go:linkname os_runtime_args os.runtime_args
func os_runtime_args() []string {
return nil
}
// Copy size bytes from src to dst. The memory areas must not overlap.
func memcpy(dst, src unsafe.Pointer, size uintptr) {
for i := uintptr(0); i < size; i++ {
+12
View File
@@ -1 +1,13 @@
package runtime
// This file contains stub implementations for internal/poll.
//go:linkname semacquire internal/poll.runtime_Semacquire
func semacquire(sema *uint32) {
panic("todo: semacquire")
}
//go:linkname semrelease internal/poll.runtime_Semrelease
func semrelease(sema *uint32) {
panic("todo: semrelease")
}
+13
View File
@@ -0,0 +1,13 @@
package runtime
// This file implements syscall.Syscall and the like.
//go:linkname syscall_Syscall syscall.Syscall
func syscall_Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err uintptr) {
panic("syscall")
}
//go:linkname syscall_Syscall6 syscall.Syscall6
func syscall_Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err uintptr) {
panic("syscall6")
}