Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
1fc67633
Commit
1fc67633
authored
Sep 07, 2011
by
Dmitriy Vyukov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sync/atomic: add Store functions
R=rsc CC=golang-dev
https://golang.org/cl/4950060
parent
299f524d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
75 additions
and
0 deletions
+75
-0
asm_386.s
src/pkg/sync/atomic/asm_386.s
+18
-0
asm_amd64.s
src/pkg/sync/atomic/asm_amd64.s
+21
-0
asm_linux_arm.s
src/pkg/sync/atomic/asm_linux_arm.s
+21
-0
atomic_test.go
src/pkg/sync/atomic/atomic_test.go
+0
-0
doc.go
src/pkg/sync/atomic/doc.go
+15
-0
No files found.
src/pkg/sync/atomic/asm_386.s
View file @
1fc67633
...
...
@@ -18,6 +18,9 @@ TEXT ·CompareAndSwapUint32(SB),7,$0
TEXT ·CompareAndSwapUintptr(SB),7,$0
JMP ·CompareAndSwapUint32(SB)
TEXT ·CompareAndSwapPointer(SB),7,$0
JMP ·CompareAndSwapUint32(SB)
TEXT ·CompareAndSwapInt64(SB),7,$0
JMP ·CompareAndSwapUint64(SB)
...
...
@@ -100,3 +103,18 @@ TEXT ·LoadUintptr(SB),7,$0
TEXT ·LoadPointer(SB),7,$0
JMP ·LoadUint32(SB)
TEXT ·StoreInt32(SB),7,$0
JMP ·StoreUint32(SB)
TEXT ·StoreUint32(SB),7,$0
MOVL addrptr+0(FP), BP
MOVL val+4(FP), AX
XCHGL AX, 0(BP)
RET
TEXT ·StoreUintptr(SB),7,$0
JMP ·StoreUint32(SB)
TEXT ·StorePointer(SB),7,$0
JMP ·StoreUint32(SB)
src/pkg/sync/atomic/asm_amd64.s
View file @
1fc67633
...
...
@@ -17,6 +17,9 @@ TEXT ·CompareAndSwapUint32(SB),7,$0
TEXT ·CompareAndSwapUintptr(SB),7,$0
JMP ·CompareAndSwapUint64(SB)
TEXT ·CompareAndSwapPointer(SB),7,$0
JMP ·CompareAndSwapUint64(SB)
TEXT ·CompareAndSwapInt64(SB),7,$0
JMP ·CompareAndSwapUint64(SB)
...
...
@@ -75,3 +78,21 @@ TEXT ·LoadPointer(SB),7,$0
MOVQ 0(AX), AX
MOVQ AX, ret+8(FP)
RET
TEXT ·StoreInt32(SB),7,$0
JMP ·StoreUint32(SB)
TEXT ·StoreUint32(SB),7,$0
MOVQ addrptr+0(FP), BP
MOVL val+8(FP), AX
XCHGL AX, 0(BP)
RET
TEXT ·StoreUintptr(SB),7,$0
JMP ·StorePointer(SB)
TEXT ·StorePointer(SB),7,$0
MOVQ addrptr+0(FP), BP
MOVQ val+8(FP), AX
XCHGQ AX, 0(BP)
RET
src/pkg/sync/atomic/asm_linux_arm.s
View file @
1fc67633
...
...
@@ -50,6 +50,9 @@ cascheck:
TEXT ·CompareAndSwapUintptr(SB),7,$0
B ·CompareAndSwapUint32(SB)
TEXT ·CompareAndSwapPointer(SB),7,$0
B ·CompareAndSwapUint32(SB)
TEXT ·AddInt32(SB),7,$0
B ·AddUint32(SB)
...
...
@@ -102,3 +105,21 @@ TEXT ·LoadUintptr(SB),7,$0
TEXT ·LoadPointer(SB),7,$0
B ·LoadUint32(SB)
TEXT ·StoreInt32(SB),7,$0
B ·StoreUint32(SB)
TEXT ·StoreUint32(SB),7,$0
MOVW addrptr+0(FP), R2
MOVW val+4(FP), R1
storeloop1:
MOVW 0(R2), R0
BL cas<>(SB)
BCC storeloop1
RET
TEXT ·StoreUintptr(SB),7,$0
B ·StoreUint32(SB)
TEXT ·StorePointer(SB),7,$0
B ·StoreUint32(SB)
src/pkg/sync/atomic/atomic_test.go
View file @
1fc67633
This diff is collapsed.
Click to expand it.
src/pkg/sync/atomic/doc.go
View file @
1fc67633
...
...
@@ -45,6 +45,9 @@ func CompareAndSwapUint64(val *uint64, old, new uint64) (swapped bool)
// CompareAndSwapUintptr executes the compare-and-swap operation for a uintptr value.
func
CompareAndSwapUintptr
(
val
*
uintptr
,
old
,
new
uintptr
)
(
swapped
bool
)
// CompareAndSwapPointer executes the compare-and-swap operation for a unsafe.Pointer value.
func
CompareAndSwapPointer
(
val
*
unsafe
.
Pointer
,
old
,
new
unsafe
.
Pointer
)
(
swapped
bool
)
// AddInt32 atomically adds delta to *val and returns the new value.
func
AddInt32
(
val
*
int32
,
delta
int32
)
(
new
int32
)
...
...
@@ -72,6 +75,18 @@ func LoadUintptr(addr *uintptr) (val uintptr)
// LoadPointer atomically loads *addr.
func
LoadPointer
(
addr
*
unsafe
.
Pointer
)
(
val
unsafe
.
Pointer
)
// StoreInt32 atomically stores val into *addr.
func
StoreInt32
(
addr
*
int32
,
val
int32
)
// StoreUint32 atomically stores val into *addr.
func
StoreUint32
(
addr
*
uint32
,
val
uint32
)
// StoreUintptr atomically stores val into *addr.
func
StoreUintptr
(
addr
*
uintptr
,
val
uintptr
)
// StorePointer atomically stores val into *addr.
func
StorePointer
(
addr
*
unsafe
.
Pointer
,
val
unsafe
.
Pointer
)
// Helper for ARM. Linker will discard on other systems
func
panic64
()
{
panic
(
"sync/atomic: broken 64-bit atomic operations (buggy QEMU)"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment