make runtime compatible with wasm
This commit is contained in:
@@ -101,3 +101,37 @@ func OrInt64(addr *int64, mask int64) (old int64) {
|
||||
func OrUint64(addr *uint64, mask uint64) (old uint64) {
|
||||
panic("implement by llgo instruction")
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// llgo:link AndInt32 llgo.atomicAnd
|
||||
func AndInt32(addr *int32, mask int32) (old int32) {
|
||||
panic("implement by llgo instruction")
|
||||
}
|
||||
|
||||
// llgo:link AndUint32 llgo.atomicAnd
|
||||
func AndUint32(addr *uint32, mask uint32) (old uint32) {
|
||||
panic("implement by llgo instruction")
|
||||
}
|
||||
|
||||
// llgo:link OrInt32 llgo.atomicOr
|
||||
func OrInt32(addr *int32, mask int32) (old int32) {
|
||||
panic("implement by llgo instruction")
|
||||
}
|
||||
|
||||
// llgo:link OrUint32 llgo.atomicOr
|
||||
func OrUint32(addr *uint32, mask uint32) (old uint32) {
|
||||
panic("implement by llgo instruction")
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// llgo:link AndUintptr llgo.atomicAnd
|
||||
func AndUintptr(addr *uintptr, mask uintptr) (old uintptr) {
|
||||
panic("implement by llgo instruction")
|
||||
}
|
||||
|
||||
// llgo:link OrUintptr llgo.atomicOr
|
||||
func OrUintptr(addr *uintptr, mask uintptr) (old uintptr) {
|
||||
panic("implement by llgo instruction")
|
||||
}
|
||||
|
||||
@@ -19,7 +19,9 @@ package sync
|
||||
import (
|
||||
"runtime"
|
||||
gosync "sync"
|
||||
_ "unsafe"
|
||||
|
||||
c "github.com/goplus/llgo/runtime/internal/clite"
|
||||
"github.com/goplus/llgo/runtime/internal/clite/pthread/sync"
|
||||
"github.com/goplus/llgo/runtime/internal/lib/sync/atomic"
|
||||
)
|
||||
@@ -62,8 +64,12 @@ func (m *Mutex) TryLock() bool {
|
||||
return (*sync.Mutex)(&m.Mutex).TryLock() == 0
|
||||
}
|
||||
|
||||
// llgo:link (*Mutex).Unlock C.pthread_mutex_unlock
|
||||
func (m *Mutex) Unlock() {}
|
||||
//go:linkname c_pthread_mutex_unlock C.pthread_mutex_unlock
|
||||
func c_pthread_mutex_unlock(m *Mutex) c.Int
|
||||
|
||||
func (m *Mutex) Unlock() {
|
||||
c_pthread_mutex_unlock(m)
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
@@ -94,8 +100,12 @@ func (rw *RWMutex) TryRLock() bool {
|
||||
return (*sync.RWLock)(&rw.RWLock).TryRLock() == 0
|
||||
}
|
||||
|
||||
// llgo:link (*RWMutex).RUnlock C.pthread_rwlock_unlock
|
||||
func (rw *RWMutex) RUnlock() {}
|
||||
//go:linkname c_pthread_rwlock_unlock C.pthread_rwlock_unlock
|
||||
func c_pthread_rwlock_unlock(rw *RWMutex) c.Int
|
||||
|
||||
func (rw *RWMutex) RUnlock() {
|
||||
c_pthread_rwlock_unlock(rw)
|
||||
}
|
||||
|
||||
func (rw *RWMutex) Lock() {
|
||||
rw.ensureInit()
|
||||
@@ -107,8 +117,9 @@ func (rw *RWMutex) TryLock() bool {
|
||||
return (*sync.RWLock)(&rw.RWLock).TryLock() == 0
|
||||
}
|
||||
|
||||
// llgo:link (*RWMutex).Unlock C.pthread_rwlock_unlock
|
||||
func (rw *RWMutex) Unlock() {}
|
||||
func (rw *RWMutex) Unlock() {
|
||||
c_pthread_rwlock_unlock(rw)
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
@@ -144,11 +155,19 @@ func NewCond(l gosync.Locker) *Cond {
|
||||
return ret
|
||||
}
|
||||
|
||||
// llgo:link (*Cond).Signal C.pthread_cond_signal
|
||||
func (c *Cond) Signal() {}
|
||||
//go:linkname c_pthread_cond_signal C.pthread_cond_signal
|
||||
func c_pthread_cond_signal(c *Cond) c.Int
|
||||
|
||||
// llgo:link (*Cond).Broadcast C.pthread_cond_broadcast
|
||||
func (c *Cond) Broadcast() {}
|
||||
//go:linkname c_pthread_cond_broadcast C.pthread_cond_broadcast
|
||||
func c_pthread_cond_broadcast(c *Cond) c.Int
|
||||
|
||||
func (c *Cond) Signal() {
|
||||
c_pthread_cond_signal(c)
|
||||
}
|
||||
|
||||
func (c *Cond) Broadcast() {
|
||||
c_pthread_cond_broadcast(c)
|
||||
}
|
||||
|
||||
func (c *Cond) Wait() {
|
||||
c.cond.Wait(c.m)
|
||||
|
||||
Reference in New Issue
Block a user