~ubuntu-branches/ubuntu/utopic/golang/utopic

« back to all changes in this revision

Viewing changes to src/pkg/sync/atomic/doc.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-08-20 14:06:23 UTC
  • mfrom: (14.1.23 saucy-proposed)
  • Revision ID: package-import@ubuntu.com-20130820140623-b414jfxi3m0qkmrq
Tags: 2:1.1.2-2ubuntu1
* Merge from Debian unstable (LP: #1211749, #1202027). Remaining changes:
  - 016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.
  - d/control,control.cross: Update Breaks/Replaces for Ubuntu
    versions to ensure smooth upgrades, regenerate control file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
// Use of this source code is governed by a BSD-style
3
3
// license that can be found in the LICENSE file.
4
4
 
 
5
// +build !race
 
6
 
5
7
// Package atomic provides low-level atomic memory primitives
6
8
// useful for implementing synchronization algorithms.
7
9
//
14
16
// The compare-and-swap operation, implemented by the CompareAndSwapT
15
17
// functions, is the atomic equivalent of:
16
18
//
17
 
//      if *val == old {
18
 
//              *val = new
 
19
//      if *addr == old {
 
20
//              *addr = new
19
21
//              return true
20
22
//      }
21
23
//      return false
22
24
//
 
25
// The add operation, implemented by the AddT functions, is the atomic
 
26
// equivalent of:
 
27
//
 
28
//      *addr += delta
 
29
//      return *addr
 
30
//
 
31
// The load and store operations, implemented by the LoadT and StoreT
 
32
// functions, are the atomic equivalents of "return *addr" and
 
33
// "*addr = val".
 
34
//
23
35
package atomic
24
36
 
25
37
import (
26
38
        "unsafe"
27
39
)
28
40
 
29
 
// BUG(rsc): On ARM, the 64-bit functions use instructions unavailable before ARM 11.
 
41
// BUG(rsc): On x86-32, the 64-bit functions use instructions unavailable before the Pentium MMX.
30
42
//
31
 
// On x86-32, the 64-bit functions use instructions unavailable before the Pentium MMX.
 
43
// On both ARM and x86-32, it is the caller's responsibility to arrange for 64-bit
 
44
// alignment of 64-bit words accessed atomically. The first word in a global
 
45
// variable or in an allocated struct or slice can be relied upon to be
 
46
// 64-bit aligned.
32
47
 
33
48
// CompareAndSwapInt32 executes the compare-and-swap operation for an int32 value.
34
 
func CompareAndSwapInt32(val *int32, old, new int32) (swapped bool)
 
49
func CompareAndSwapInt32(addr *int32, old, new int32) (swapped bool)
35
50
 
36
51
// CompareAndSwapInt64 executes the compare-and-swap operation for an int64 value.
37
 
func CompareAndSwapInt64(val *int64, old, new int64) (swapped bool)
 
52
func CompareAndSwapInt64(addr *int64, old, new int64) (swapped bool)
38
53
 
39
54
// CompareAndSwapUint32 executes the compare-and-swap operation for a uint32 value.
40
 
func CompareAndSwapUint32(val *uint32, old, new uint32) (swapped bool)
 
55
func CompareAndSwapUint32(addr *uint32, old, new uint32) (swapped bool)
41
56
 
42
57
// CompareAndSwapUint64 executes the compare-and-swap operation for a uint64 value.
43
 
func CompareAndSwapUint64(val *uint64, old, new uint64) (swapped bool)
 
58
func CompareAndSwapUint64(addr *uint64, old, new uint64) (swapped bool)
44
59
 
45
60
// CompareAndSwapUintptr executes the compare-and-swap operation for a uintptr value.
46
 
func CompareAndSwapUintptr(val *uintptr, old, new uintptr) (swapped bool)
 
61
func CompareAndSwapUintptr(addr *uintptr, old, new uintptr) (swapped bool)
47
62
 
48
63
// CompareAndSwapPointer executes the compare-and-swap operation for a unsafe.Pointer value.
49
 
func CompareAndSwapPointer(val *unsafe.Pointer, old, new unsafe.Pointer) (swapped bool)
50
 
 
51
 
// AddInt32 atomically adds delta to *val and returns the new value.
52
 
func AddInt32(val *int32, delta int32) (new int32)
53
 
 
54
 
// AddUint32 atomically adds delta to *val and returns the new value.
55
 
func AddUint32(val *uint32, delta uint32) (new uint32)
56
 
 
57
 
// AddInt64 atomically adds delta to *val and returns the new value.
58
 
func AddInt64(val *int64, delta int64) (new int64)
59
 
 
60
 
// AddUint64 atomically adds delta to *val and returns the new value.
61
 
func AddUint64(val *uint64, delta uint64) (new uint64)
62
 
 
63
 
// AddUintptr atomically adds delta to *val and returns the new value.
64
 
func AddUintptr(val *uintptr, delta uintptr) (new uintptr)
 
64
func CompareAndSwapPointer(addr *unsafe.Pointer, old, new unsafe.Pointer) (swapped bool)
 
65
 
 
66
// AddInt32 atomically adds delta to *addr and returns the new value.
 
67
func AddInt32(addr *int32, delta int32) (new int32)
 
68
 
 
69
// AddUint32 atomically adds delta to *addr and returns the new value.
 
70
func AddUint32(addr *uint32, delta uint32) (new uint32)
 
71
 
 
72
// AddInt64 atomically adds delta to *addr and returns the new value.
 
73
func AddInt64(addr *int64, delta int64) (new int64)
 
74
 
 
75
// AddUint64 atomically adds delta to *addr and returns the new value.
 
76
func AddUint64(addr *uint64, delta uint64) (new uint64)
 
77
 
 
78
// AddUintptr atomically adds delta to *addr and returns the new value.
 
79
func AddUintptr(addr *uintptr, delta uintptr) (new uintptr)
65
80
 
66
81
// LoadInt32 atomically loads *addr.
67
82
func LoadInt32(addr *int32) (val int32)