Skip to content

Commit 690337e

Browse files
committed
internal/runtime/atomic: add Xchg8 for 386
1 parent ef3e1da commit 690337e

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

src/internal/runtime/atomic/atomic_386.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ func Xchg64(ptr *uint64, new uint64) uint64
5353
//go:noescape
5454
func Xchg(ptr *uint32, new uint32) uint32
5555

56+
//go:noescape
57+
func Xchg8(ptr *uint8, new uint8) uint8
58+
5659
//go:noescape
5760
func Xchguintptr(ptr *uintptr, new uintptr) uintptr
5861

src/internal/runtime/atomic/atomic_386.s

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,14 @@ addloop:
153153
MOVL CX, ret_hi+16(FP)
154154
RET
155155

156+
// uint8 Xchg8(uint8 *ptr, uint8 new)
157+
TEXT ·Xchg8(SB), NOSPLIT, $0-9
158+
MOVL ptr+0(FP), BX
159+
MOVB new+4(FP), AX
160+
XCHGB AX, 0(BX)
161+
MOVB AX, ret+8(FP)
162+
RET
163+
156164
TEXT ·Xchg(SB), NOSPLIT, $0-12
157165
MOVL ptr+0(FP), BX
158166
MOVL new+4(FP), AX

src/internal/runtime/atomic/xchg8_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
//go:build amd64 || arm64 || ppc64 || ppc64le
5+
//go:build 386 || amd64 || arm64 || ppc64 || ppc64le
66

77
package atomic_test
88

0 commit comments

Comments
 (0)