diff options
author | Carl Shapiro | 2010-09-28 15:47:03 -0500 |
---|---|---|
committer | Carl Shapiro | 2010-09-28 16:06:00 -0500 |
commit | d55f0adfb5ec4202ad5bd5d188e66c0f6a27b0aa (patch) | |
tree | 409d6c3ac1cb97d41a9422f8e740134d7847bdfd | |
parent | f62b23f2c1540221621024c850fdf615dda0c903 (diff) | |
download | platform-system-core-d55f0adfb5ec4202ad5bd5d188e66c0f6a27b0aa.tar.gz platform-system-core-d55f0adfb5ec4202ad5bd5d188e66c0f6a27b0aa.tar.xz platform-system-core-d55f0adfb5ec4202ad5bd5d188e66c0f6a27b0aa.zip |
Qualify the source argument of atomic loads as a const pointer.
Also normalizes the opening brace placment in a few locations.
Change-Id: I8f518e933094337d5d3371321326ffc03b3a5f5a
-rw-r--r-- | include/cutils/atomic-arm.h | 10 | ||||
-rw-r--r-- | include/cutils/atomic-x86.h | 18 | ||||
-rw-r--r-- | include/cutils/atomic.h | 4 | ||||
-rw-r--r-- | libcutils/atomic-android-sh.c | 4 |
4 files changed, 22 insertions, 14 deletions
diff --git a/include/cutils/atomic-arm.h b/include/cutils/atomic-arm.h index 0dd629d86..93633c435 100644 --- a/include/cutils/atomic-arm.h +++ b/include/cutils/atomic-arm.h | |||
@@ -49,14 +49,14 @@ extern inline void android_memory_barrier(void) | |||
49 | } | 49 | } |
50 | #endif | 50 | #endif |
51 | 51 | ||
52 | extern inline int32_t android_atomic_acquire_load(volatile int32_t *ptr) | 52 | extern inline int32_t android_atomic_acquire_load(volatile const int32_t *ptr) |
53 | { | 53 | { |
54 | int32_t value = *ptr; | 54 | int32_t value = *ptr; |
55 | android_memory_barrier(); | 55 | android_memory_barrier(); |
56 | return value; | 56 | return value; |
57 | } | 57 | } |
58 | 58 | ||
59 | extern inline int32_t android_atomic_release_load(volatile int32_t *ptr) | 59 | extern inline int32_t android_atomic_release_load(volatile const int32_t *ptr) |
60 | { | 60 | { |
61 | android_memory_barrier(); | 61 | android_memory_barrier(); |
62 | return *ptr; | 62 | return *ptr; |
@@ -196,11 +196,13 @@ extern inline int32_t android_atomic_add(int32_t increment, | |||
196 | } | 196 | } |
197 | #endif | 197 | #endif |
198 | 198 | ||
199 | extern inline int32_t android_atomic_inc(volatile int32_t *addr) { | 199 | extern inline int32_t android_atomic_inc(volatile int32_t *addr) |
200 | { | ||
200 | return android_atomic_add(1, addr); | 201 | return android_atomic_add(1, addr); |
201 | } | 202 | } |
202 | 203 | ||
203 | extern inline int32_t android_atomic_dec(volatile int32_t *addr) { | 204 | extern inline int32_t android_atomic_dec(volatile int32_t *addr) |
205 | { | ||
204 | return android_atomic_add(-1, addr); | 206 | return android_atomic_add(-1, addr); |
205 | } | 207 | } |
206 | 208 | ||
diff --git a/include/cutils/atomic-x86.h b/include/cutils/atomic-x86.h index 06b643fbe..12a19859a 100644 --- a/include/cutils/atomic-x86.h +++ b/include/cutils/atomic-x86.h | |||
@@ -36,25 +36,29 @@ extern inline void android_memory_barrier(void) | |||
36 | } | 36 | } |
37 | #endif | 37 | #endif |
38 | 38 | ||
39 | extern inline int32_t android_atomic_acquire_load(volatile int32_t *ptr) { | 39 | extern inline int32_t android_atomic_acquire_load(volatile const int32_t *ptr) |
40 | { | ||
40 | int32_t value = *ptr; | 41 | int32_t value = *ptr; |
41 | android_compiler_barrier(); | 42 | android_compiler_barrier(); |
42 | return value; | 43 | return value; |
43 | } | 44 | } |
44 | 45 | ||
45 | extern inline int32_t android_atomic_release_load(volatile int32_t *ptr) { | 46 | extern inline int32_t android_atomic_release_load(volatile const int32_t *ptr) |
47 | { | ||
46 | android_memory_barrier(); | 48 | android_memory_barrier(); |
47 | return *ptr; | 49 | return *ptr; |
48 | } | 50 | } |
49 | 51 | ||
50 | extern inline void android_atomic_acquire_store(int32_t value, | 52 | extern inline void android_atomic_acquire_store(int32_t value, |
51 | volatile int32_t *ptr) { | 53 | volatile int32_t *ptr) |
54 | { | ||
52 | *ptr = value; | 55 | *ptr = value; |
53 | android_memory_barrier(); | 56 | android_memory_barrier(); |
54 | } | 57 | } |
55 | 58 | ||
56 | extern inline void android_atomic_release_store(int32_t value, | 59 | extern inline void android_atomic_release_store(int32_t value, |
57 | volatile int32_t *ptr) { | 60 | volatile int32_t *ptr) |
61 | { | ||
58 | android_compiler_barrier(); | 62 | android_compiler_barrier(); |
59 | *ptr = value; | 63 | *ptr = value; |
60 | } | 64 | } |
@@ -107,11 +111,13 @@ extern inline int32_t android_atomic_add(int32_t increment, | |||
107 | return increment; | 111 | return increment; |
108 | } | 112 | } |
109 | 113 | ||
110 | extern inline int32_t android_atomic_inc(volatile int32_t *addr) { | 114 | extern inline int32_t android_atomic_inc(volatile int32_t *addr) |
115 | { | ||
111 | return android_atomic_add(1, addr); | 116 | return android_atomic_add(1, addr); |
112 | } | 117 | } |
113 | 118 | ||
114 | extern inline int32_t android_atomic_dec(volatile int32_t *addr) { | 119 | extern inline int32_t android_atomic_dec(volatile int32_t *addr) |
120 | { | ||
115 | return android_atomic_add(-1, addr); | 121 | return android_atomic_add(-1, addr); |
116 | } | 122 | } |
117 | 123 | ||
diff --git a/include/cutils/atomic.h b/include/cutils/atomic.h index 38668486e..a50bf0fe5 100644 --- a/include/cutils/atomic.h +++ b/include/cutils/atomic.h | |||
@@ -77,8 +77,8 @@ int32_t android_atomic_or(int32_t value, volatile int32_t* addr); | |||
77 | * This is only necessary if you need the memory barrier. A 32-bit read | 77 | * This is only necessary if you need the memory barrier. A 32-bit read |
78 | * from a 32-bit aligned address is atomic on all supported platforms. | 78 | * from a 32-bit aligned address is atomic on all supported platforms. |
79 | */ | 79 | */ |
80 | int32_t android_atomic_acquire_load(volatile int32_t* addr); | 80 | int32_t android_atomic_acquire_load(volatile const int32_t* addr); |
81 | int32_t android_atomic_release_load(volatile int32_t* addr); | 81 | int32_t android_atomic_release_load(volatile const int32_t* addr); |
82 | 82 | ||
83 | /* | 83 | /* |
84 | * Perform an atomic store with "acquire" or "release" ordering. | 84 | * Perform an atomic store with "acquire" or "release" ordering. |
diff --git a/libcutils/atomic-android-sh.c b/libcutils/atomic-android-sh.c index abe7d25fb..f8f1f57bd 100644 --- a/libcutils/atomic-android-sh.c +++ b/libcutils/atomic-android-sh.c | |||
@@ -49,12 +49,12 @@ static pthread_mutex_t _swap_locks[SWAP_LOCK_COUNT]; | |||
49 | &_swap_locks[((unsigned)(void*)(addr) >> 3U) % SWAP_LOCK_COUNT] | 49 | &_swap_locks[((unsigned)(void*)(addr) >> 3U) % SWAP_LOCK_COUNT] |
50 | 50 | ||
51 | 51 | ||
52 | int32_t android_atomic_acquire_load(volatile int32_t* addr) | 52 | int32_t android_atomic_acquire_load(volatile const int32_t* addr) |
53 | { | 53 | { |
54 | return *addr; | 54 | return *addr; |
55 | } | 55 | } |
56 | 56 | ||
57 | int32_t android_atomic_release_load(volatile int32_t* addr) | 57 | int32_t android_atomic_release_load(volatile const int32_t* addr) |
58 | { | 58 | { |
59 | return *addr; | 59 | return *addr; |
60 | } | 60 | } |