6c92f85d10
Bring the Nexus/Praxis/Hexis integration in line with MAVEN_ECOSYSTEM_ARCHITECTURE.md: - Praxis over HTTP: drop the in-process praxis.db open (praxisstore/ praxistools) and call praxisd's /api/v1/tools/* API via a new praxisClient. Honors the "no component reads another's DB" invariant (AC#12). PraxisConfig.DBPath -> URL. - Hexis confirmation gate: mutating capabilities (ReadOnly=false) now park a bound pendingHexis confirmation and require a spoken "да" before executing; read-only run immediately (AC#7, no auto attention->action). - Capability safety: >1 verb match is ambiguous -> ask instead of firing the first; ambiguous Nexus resolution asks for clarification (AC#2). - Correlation IDs on Hexis execute, recorded in the cross-service trace. - Bug: importance arrives as JSON float64 over HTTP, not int. - Tests: confirm-gate, decline, read-only, and ambiguity paths. Build: vendor/ bakes in the hexis client (replace-directed at a sibling repo outside the Docker context); Dockerfile builds from vendor and no longer `go mod download`s the unreachable replace paths. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
118 lines
3.5 KiB
Go
118 lines
3.5 KiB
Go
// Copyright 2024 The Libc Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
//go:build linux && (amd64 || arm64 || loong64 || ppc64le || s390x || riscv64 || 386 || arm)
|
|
|
|
package libc // import "modernc.org/libc"
|
|
|
|
import (
|
|
"math"
|
|
mbits "math/bits"
|
|
"sync/atomic"
|
|
"unsafe"
|
|
)
|
|
|
|
func a_store_8(addr uintptr, val int8) int8 {
|
|
*(*int8)(unsafe.Pointer(addr)) = val
|
|
return val
|
|
}
|
|
|
|
func a_load_8(addr uintptr) (val int8) {
|
|
return *(*int8)(unsafe.Pointer(addr))
|
|
}
|
|
|
|
func a_load_16(addr uintptr) (val int16) {
|
|
if addr&1 != 0 {
|
|
panic("unaligned atomic access")
|
|
}
|
|
|
|
return *(*int16)(unsafe.Pointer(addr))
|
|
}
|
|
|
|
func a_store_16(addr uintptr, val uint16) {
|
|
if addr&1 != 0 {
|
|
panic("unaligned atomic access")
|
|
}
|
|
|
|
*(*uint16)(unsafe.Pointer(addr)) = val
|
|
}
|
|
|
|
// static inline int a_ctz_64(uint64_t x)
|
|
func _a_ctz_64(tls *TLS, x uint64) int32 {
|
|
return int32(mbits.TrailingZeros64(x))
|
|
}
|
|
|
|
func AtomicAddFloat32(addr *float32, delta float32) (new float32) {
|
|
for {
|
|
oldBits := atomic.LoadUint32((*uint32)(unsafe.Pointer(addr)))
|
|
oldVal := math.Float32frombits(oldBits)
|
|
newVal := oldVal + delta
|
|
newBits := math.Float32bits(newVal)
|
|
if atomic.CompareAndSwapUint32((*uint32)(unsafe.Pointer(addr)), oldBits, newBits) {
|
|
return newVal
|
|
}
|
|
}
|
|
}
|
|
|
|
func AtomicLoadFloat32(addr *float32) (val float32) {
|
|
return math.Float32frombits(atomic.LoadUint32((*uint32)(unsafe.Pointer(addr))))
|
|
}
|
|
|
|
func AtomicStoreFloat32(addr *float32, val float32) {
|
|
atomic.StoreUint32((*uint32)(unsafe.Pointer(addr)), math.Float32bits(val))
|
|
}
|
|
|
|
func AtomicAddFloat64(addr *float64, delta float64) (new float64) {
|
|
for {
|
|
oldBits := atomic.LoadUint64((*uint64)(unsafe.Pointer(addr)))
|
|
oldVal := math.Float64frombits(oldBits)
|
|
newVal := oldVal + delta
|
|
newBits := math.Float64bits(newVal)
|
|
if atomic.CompareAndSwapUint64((*uint64)(unsafe.Pointer(addr)), oldBits, newBits) {
|
|
return newVal
|
|
}
|
|
}
|
|
}
|
|
|
|
func AtomicLoadFloat64(addr *float64) (val float64) {
|
|
return math.Float64frombits(atomic.LoadUint64((*uint64)(unsafe.Pointer(addr))))
|
|
}
|
|
|
|
func AtomicStoreFloat64(addr *float64, val float64) {
|
|
atomic.StoreUint64((*uint64)(unsafe.Pointer(addr)), math.Float64bits(val))
|
|
}
|
|
|
|
func AtomicAddInt32(addr *int32, delta int32) (new int32) { return atomic.AddInt32(addr, delta) }
|
|
|
|
func AtomicAddInt64(addr *int64, delta int64) (new int64) { return atomic.AddInt64(addr, delta) }
|
|
|
|
func AtomicAddUint32(addr *uint32, delta uint32) (new uint32) { return atomic.AddUint32(addr, delta) }
|
|
|
|
func AtomicAddUint64(addr *uint64, delta uint64) (new uint64) { return atomic.AddUint64(addr, delta) }
|
|
|
|
func AtomicAddUintptr(addr *uintptr, delta uintptr) (new uintptr) {
|
|
return atomic.AddUintptr(addr, delta)
|
|
|
|
}
|
|
|
|
func AtomicLoadInt32(addr *int32) (val int32) { return atomic.LoadInt32(addr) }
|
|
|
|
func AtomicLoadInt64(addr *int64) (val int64) { return atomic.LoadInt64(addr) }
|
|
|
|
func AtomicLoadUint32(addr *uint32) (val uint32) { return atomic.LoadUint32(addr) }
|
|
|
|
func AtomicLoadUint64(addr *uint64) (val uint64) { return atomic.LoadUint64(addr) }
|
|
|
|
func AtomicLoadUintptr(addr *uintptr) (val uintptr) { return atomic.LoadUintptr(addr) }
|
|
|
|
func AtomicStoreInt32(addr *int32, val int32) { atomic.StoreInt32(addr, val) }
|
|
|
|
func AtomicStoreUint32(addr *uint32, val uint32) { atomic.StoreUint32(addr, val) }
|
|
|
|
func AtomicStoreUint64(addr *uint64, val uint64) { atomic.StoreUint64(addr, val) }
|
|
|
|
func AtomicStoreUintptr(addr *uintptr, val uintptr) { atomic.StoreUintptr(addr, val) }
|
|
|
|
func AtomicStoreInt64(addr *int64, val int64) { atomic.StoreInt64(addr, val) }
|