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
}