Opencv 3.1 project on GR-PEACH board
Fork of gr-peach-opencv-project by
platform/mbed_critical.c@167:1657b442184c, 2017-06-29 (annotated)
- Committer:
- thedo
- Date:
- Thu Jun 29 11:01:39 2017 +0000
- Revision:
- 167:1657b442184c
Opencv 3.1 project on GR-PEACH board, 4 apps
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
thedo | 167:1657b442184c | 1 | /* |
thedo | 167:1657b442184c | 2 | * Copyright (c) 2015-2016, ARM Limited, All Rights Reserved |
thedo | 167:1657b442184c | 3 | * SPDX-License-Identifier: Apache-2.0 |
thedo | 167:1657b442184c | 4 | * |
thedo | 167:1657b442184c | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
thedo | 167:1657b442184c | 6 | * not use this file except in compliance with the License. |
thedo | 167:1657b442184c | 7 | * You may obtain a copy of the License at |
thedo | 167:1657b442184c | 8 | * |
thedo | 167:1657b442184c | 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
thedo | 167:1657b442184c | 10 | * |
thedo | 167:1657b442184c | 11 | * Unless required by applicable law or agreed to in writing, software |
thedo | 167:1657b442184c | 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
thedo | 167:1657b442184c | 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
thedo | 167:1657b442184c | 14 | * See the License for the specific language governing permissions and |
thedo | 167:1657b442184c | 15 | * limitations under the License. |
thedo | 167:1657b442184c | 16 | */ |
thedo | 167:1657b442184c | 17 | |
thedo | 167:1657b442184c | 18 | /* Declare __STDC_LIMIT_MACROS so stdint.h defines UINT32_MAX when using C++ */ |
thedo | 167:1657b442184c | 19 | #define __STDC_LIMIT_MACROS |
thedo | 167:1657b442184c | 20 | #include "platform/mbed_critical.h" |
thedo | 167:1657b442184c | 21 | |
thedo | 167:1657b442184c | 22 | #include "cmsis.h" |
thedo | 167:1657b442184c | 23 | #include "platform/mbed_assert.h" |
thedo | 167:1657b442184c | 24 | #include "platform/mbed_toolchain.h" |
thedo | 167:1657b442184c | 25 | |
thedo | 167:1657b442184c | 26 | #define EXCLUSIVE_ACCESS (!defined (__CORTEX_M0) && !defined (__CORTEX_M0PLUS)) |
thedo | 167:1657b442184c | 27 | |
thedo | 167:1657b442184c | 28 | static volatile uint32_t interrupt_enable_counter = 0; |
thedo | 167:1657b442184c | 29 | static volatile bool critical_interrupts_disabled = false; |
thedo | 167:1657b442184c | 30 | |
thedo | 167:1657b442184c | 31 | bool core_util_are_interrupts_enabled(void) |
thedo | 167:1657b442184c | 32 | { |
thedo | 167:1657b442184c | 33 | #if defined(__CORTEX_A9) |
thedo | 167:1657b442184c | 34 | return ((__get_CPSR() & 0x80) == 0); |
thedo | 167:1657b442184c | 35 | #else |
thedo | 167:1657b442184c | 36 | return ((__get_PRIMASK() & 0x1) == 0); |
thedo | 167:1657b442184c | 37 | #endif |
thedo | 167:1657b442184c | 38 | } |
thedo | 167:1657b442184c | 39 | |
thedo | 167:1657b442184c | 40 | bool core_util_is_isr_active(void) |
thedo | 167:1657b442184c | 41 | { |
thedo | 167:1657b442184c | 42 | #if defined(__CORTEX_A9) |
thedo | 167:1657b442184c | 43 | switch(__get_CPSR() & 0x1FU) { |
thedo | 167:1657b442184c | 44 | case MODE_USR: |
thedo | 167:1657b442184c | 45 | case MODE_SYS: |
thedo | 167:1657b442184c | 46 | return false; |
thedo | 167:1657b442184c | 47 | case MODE_SVC: |
thedo | 167:1657b442184c | 48 | default: |
thedo | 167:1657b442184c | 49 | return true; |
thedo | 167:1657b442184c | 50 | } |
thedo | 167:1657b442184c | 51 | #else |
thedo | 167:1657b442184c | 52 | return (__get_IPSR() != 0U); |
thedo | 167:1657b442184c | 53 | #endif |
thedo | 167:1657b442184c | 54 | } |
thedo | 167:1657b442184c | 55 | |
thedo | 167:1657b442184c | 56 | MBED_WEAK void core_util_critical_section_enter(void) |
thedo | 167:1657b442184c | 57 | { |
thedo | 167:1657b442184c | 58 | bool interrupts_disabled = !core_util_are_interrupts_enabled(); |
thedo | 167:1657b442184c | 59 | __disable_irq(); |
thedo | 167:1657b442184c | 60 | |
thedo | 167:1657b442184c | 61 | /* Save the interrupt disabled state as it was prior to any nested critical section lock use */ |
thedo | 167:1657b442184c | 62 | if (!interrupt_enable_counter) { |
thedo | 167:1657b442184c | 63 | critical_interrupts_disabled = interrupts_disabled; |
thedo | 167:1657b442184c | 64 | } |
thedo | 167:1657b442184c | 65 | |
thedo | 167:1657b442184c | 66 | /* If the interrupt_enable_counter overflows or we are in a nested critical section and interrupts |
thedo | 167:1657b442184c | 67 | are enabled, then something has gone badly wrong thus assert an error. |
thedo | 167:1657b442184c | 68 | */ |
thedo | 167:1657b442184c | 69 | MBED_ASSERT(interrupt_enable_counter < UINT32_MAX); |
thedo | 167:1657b442184c | 70 | // FIXME |
thedo | 167:1657b442184c | 71 | #ifndef FEATURE_UVISOR |
thedo | 167:1657b442184c | 72 | if (interrupt_enable_counter > 0) { |
thedo | 167:1657b442184c | 73 | MBED_ASSERT(interrupts_disabled); |
thedo | 167:1657b442184c | 74 | } |
thedo | 167:1657b442184c | 75 | #else |
thedo | 167:1657b442184c | 76 | #warning "core_util_critical_section_enter needs fixing to work from unprivileged code" |
thedo | 167:1657b442184c | 77 | #endif /* FEATURE_UVISOR */ |
thedo | 167:1657b442184c | 78 | interrupt_enable_counter++; |
thedo | 167:1657b442184c | 79 | } |
thedo | 167:1657b442184c | 80 | |
thedo | 167:1657b442184c | 81 | MBED_WEAK void core_util_critical_section_exit(void) |
thedo | 167:1657b442184c | 82 | { |
thedo | 167:1657b442184c | 83 | /* If critical_section_enter has not previously been called, do nothing */ |
thedo | 167:1657b442184c | 84 | if (interrupt_enable_counter) { |
thedo | 167:1657b442184c | 85 | |
thedo | 167:1657b442184c | 86 | // FIXME |
thedo | 167:1657b442184c | 87 | #ifndef FEATURE_UVISOR |
thedo | 167:1657b442184c | 88 | bool interrupts_disabled = !core_util_are_interrupts_enabled(); /* get the current interrupt disabled state */ |
thedo | 167:1657b442184c | 89 | |
thedo | 167:1657b442184c | 90 | MBED_ASSERT(interrupts_disabled); /* Interrupts must be disabled on invoking an exit from a critical section */ |
thedo | 167:1657b442184c | 91 | #else |
thedo | 167:1657b442184c | 92 | #warning "core_util_critical_section_exit needs fixing to work from unprivileged code" |
thedo | 167:1657b442184c | 93 | #endif /* FEATURE_UVISOR */ |
thedo | 167:1657b442184c | 94 | |
thedo | 167:1657b442184c | 95 | interrupt_enable_counter--; |
thedo | 167:1657b442184c | 96 | |
thedo | 167:1657b442184c | 97 | /* Only re-enable interrupts if we are exiting the last of the nested critical sections and |
thedo | 167:1657b442184c | 98 | interrupts were enabled on entry to the first critical section. |
thedo | 167:1657b442184c | 99 | */ |
thedo | 167:1657b442184c | 100 | if (!interrupt_enable_counter && !critical_interrupts_disabled) { |
thedo | 167:1657b442184c | 101 | __enable_irq(); |
thedo | 167:1657b442184c | 102 | } |
thedo | 167:1657b442184c | 103 | } |
thedo | 167:1657b442184c | 104 | } |
thedo | 167:1657b442184c | 105 | |
thedo | 167:1657b442184c | 106 | #if EXCLUSIVE_ACCESS |
thedo | 167:1657b442184c | 107 | |
thedo | 167:1657b442184c | 108 | /* Supress __ldrex and __strex deprecated warnings - "#3731-D: intrinsic is deprecated" */ |
thedo | 167:1657b442184c | 109 | #if defined (__CC_ARM) |
thedo | 167:1657b442184c | 110 | #pragma diag_suppress 3731 |
thedo | 167:1657b442184c | 111 | #endif |
thedo | 167:1657b442184c | 112 | |
thedo | 167:1657b442184c | 113 | bool core_util_atomic_cas_u8(uint8_t *ptr, uint8_t *expectedCurrentValue, uint8_t desiredValue) |
thedo | 167:1657b442184c | 114 | { |
thedo | 167:1657b442184c | 115 | uint8_t currentValue = __LDREXB((volatile uint8_t*)ptr); |
thedo | 167:1657b442184c | 116 | if (currentValue != *expectedCurrentValue) { |
thedo | 167:1657b442184c | 117 | *expectedCurrentValue = currentValue; |
thedo | 167:1657b442184c | 118 | __CLREX(); |
thedo | 167:1657b442184c | 119 | return false; |
thedo | 167:1657b442184c | 120 | } |
thedo | 167:1657b442184c | 121 | |
thedo | 167:1657b442184c | 122 | return !__STREXB(desiredValue, (volatile uint8_t*)ptr); |
thedo | 167:1657b442184c | 123 | } |
thedo | 167:1657b442184c | 124 | |
thedo | 167:1657b442184c | 125 | bool core_util_atomic_cas_u16(uint16_t *ptr, uint16_t *expectedCurrentValue, uint16_t desiredValue) |
thedo | 167:1657b442184c | 126 | { |
thedo | 167:1657b442184c | 127 | uint16_t currentValue = __LDREXH((volatile uint16_t*)ptr); |
thedo | 167:1657b442184c | 128 | if (currentValue != *expectedCurrentValue) { |
thedo | 167:1657b442184c | 129 | *expectedCurrentValue = currentValue; |
thedo | 167:1657b442184c | 130 | __CLREX(); |
thedo | 167:1657b442184c | 131 | return false; |
thedo | 167:1657b442184c | 132 | } |
thedo | 167:1657b442184c | 133 | |
thedo | 167:1657b442184c | 134 | return !__STREXH(desiredValue, (volatile uint16_t*)ptr); |
thedo | 167:1657b442184c | 135 | } |
thedo | 167:1657b442184c | 136 | |
thedo | 167:1657b442184c | 137 | |
thedo | 167:1657b442184c | 138 | bool core_util_atomic_cas_u32(uint32_t *ptr, uint32_t *expectedCurrentValue, uint32_t desiredValue) |
thedo | 167:1657b442184c | 139 | { |
thedo | 167:1657b442184c | 140 | uint32_t currentValue = __LDREXW((volatile uint32_t*)ptr); |
thedo | 167:1657b442184c | 141 | if (currentValue != *expectedCurrentValue) { |
thedo | 167:1657b442184c | 142 | *expectedCurrentValue = currentValue; |
thedo | 167:1657b442184c | 143 | __CLREX(); |
thedo | 167:1657b442184c | 144 | return false; |
thedo | 167:1657b442184c | 145 | } |
thedo | 167:1657b442184c | 146 | |
thedo | 167:1657b442184c | 147 | return !__STREXW(desiredValue, (volatile uint32_t*)ptr); |
thedo | 167:1657b442184c | 148 | } |
thedo | 167:1657b442184c | 149 | |
thedo | 167:1657b442184c | 150 | uint8_t core_util_atomic_incr_u8(uint8_t *valuePtr, uint8_t delta) |
thedo | 167:1657b442184c | 151 | { |
thedo | 167:1657b442184c | 152 | uint8_t newValue; |
thedo | 167:1657b442184c | 153 | do { |
thedo | 167:1657b442184c | 154 | newValue = __LDREXB((volatile uint8_t*)valuePtr) + delta; |
thedo | 167:1657b442184c | 155 | } while (__STREXB(newValue, (volatile uint8_t*)valuePtr)); |
thedo | 167:1657b442184c | 156 | return newValue; |
thedo | 167:1657b442184c | 157 | } |
thedo | 167:1657b442184c | 158 | |
thedo | 167:1657b442184c | 159 | uint16_t core_util_atomic_incr_u16(uint16_t *valuePtr, uint16_t delta) |
thedo | 167:1657b442184c | 160 | { |
thedo | 167:1657b442184c | 161 | uint16_t newValue; |
thedo | 167:1657b442184c | 162 | do { |
thedo | 167:1657b442184c | 163 | newValue = __LDREXH((volatile uint16_t*)valuePtr) + delta; |
thedo | 167:1657b442184c | 164 | } while (__STREXH(newValue, (volatile uint16_t*)valuePtr)); |
thedo | 167:1657b442184c | 165 | return newValue; |
thedo | 167:1657b442184c | 166 | } |
thedo | 167:1657b442184c | 167 | |
thedo | 167:1657b442184c | 168 | uint32_t core_util_atomic_incr_u32(uint32_t *valuePtr, uint32_t delta) |
thedo | 167:1657b442184c | 169 | { |
thedo | 167:1657b442184c | 170 | uint32_t newValue; |
thedo | 167:1657b442184c | 171 | do { |
thedo | 167:1657b442184c | 172 | newValue = __LDREXW((volatile uint32_t*)valuePtr) + delta; |
thedo | 167:1657b442184c | 173 | } while (__STREXW(newValue, (volatile uint32_t*)valuePtr)); |
thedo | 167:1657b442184c | 174 | return newValue; |
thedo | 167:1657b442184c | 175 | } |
thedo | 167:1657b442184c | 176 | |
thedo | 167:1657b442184c | 177 | |
thedo | 167:1657b442184c | 178 | uint8_t core_util_atomic_decr_u8(uint8_t *valuePtr, uint8_t delta) |
thedo | 167:1657b442184c | 179 | { |
thedo | 167:1657b442184c | 180 | uint8_t newValue; |
thedo | 167:1657b442184c | 181 | do { |
thedo | 167:1657b442184c | 182 | newValue = __LDREXB((volatile uint8_t*)valuePtr) - delta; |
thedo | 167:1657b442184c | 183 | } while (__STREXB(newValue, (volatile uint8_t*)valuePtr)); |
thedo | 167:1657b442184c | 184 | return newValue; |
thedo | 167:1657b442184c | 185 | } |
thedo | 167:1657b442184c | 186 | |
thedo | 167:1657b442184c | 187 | uint16_t core_util_atomic_decr_u16(uint16_t *valuePtr, uint16_t delta) |
thedo | 167:1657b442184c | 188 | { |
thedo | 167:1657b442184c | 189 | uint16_t newValue; |
thedo | 167:1657b442184c | 190 | do { |
thedo | 167:1657b442184c | 191 | newValue = __LDREXH((volatile uint16_t*)valuePtr) - delta; |
thedo | 167:1657b442184c | 192 | } while (__STREXH(newValue, (volatile uint16_t*)valuePtr)); |
thedo | 167:1657b442184c | 193 | return newValue; |
thedo | 167:1657b442184c | 194 | } |
thedo | 167:1657b442184c | 195 | |
thedo | 167:1657b442184c | 196 | uint32_t core_util_atomic_decr_u32(uint32_t *valuePtr, uint32_t delta) |
thedo | 167:1657b442184c | 197 | { |
thedo | 167:1657b442184c | 198 | uint32_t newValue; |
thedo | 167:1657b442184c | 199 | do { |
thedo | 167:1657b442184c | 200 | newValue = __LDREXW((volatile uint32_t*)valuePtr) - delta; |
thedo | 167:1657b442184c | 201 | } while (__STREXW(newValue, (volatile uint32_t*)valuePtr)); |
thedo | 167:1657b442184c | 202 | return newValue; |
thedo | 167:1657b442184c | 203 | } |
thedo | 167:1657b442184c | 204 | |
thedo | 167:1657b442184c | 205 | #else |
thedo | 167:1657b442184c | 206 | |
thedo | 167:1657b442184c | 207 | bool core_util_atomic_cas_u8(uint8_t *ptr, uint8_t *expectedCurrentValue, uint8_t desiredValue) |
thedo | 167:1657b442184c | 208 | { |
thedo | 167:1657b442184c | 209 | bool success; |
thedo | 167:1657b442184c | 210 | uint8_t currentValue; |
thedo | 167:1657b442184c | 211 | core_util_critical_section_enter(); |
thedo | 167:1657b442184c | 212 | currentValue = *ptr; |
thedo | 167:1657b442184c | 213 | if (currentValue == *expectedCurrentValue) { |
thedo | 167:1657b442184c | 214 | *ptr = desiredValue; |
thedo | 167:1657b442184c | 215 | success = true; |
thedo | 167:1657b442184c | 216 | } else { |
thedo | 167:1657b442184c | 217 | *expectedCurrentValue = currentValue; |
thedo | 167:1657b442184c | 218 | success = false; |
thedo | 167:1657b442184c | 219 | } |
thedo | 167:1657b442184c | 220 | core_util_critical_section_exit(); |
thedo | 167:1657b442184c | 221 | return success; |
thedo | 167:1657b442184c | 222 | } |
thedo | 167:1657b442184c | 223 | |
thedo | 167:1657b442184c | 224 | bool core_util_atomic_cas_u16(uint16_t *ptr, uint16_t *expectedCurrentValue, uint16_t desiredValue) |
thedo | 167:1657b442184c | 225 | { |
thedo | 167:1657b442184c | 226 | bool success; |
thedo | 167:1657b442184c | 227 | uint16_t currentValue; |
thedo | 167:1657b442184c | 228 | core_util_critical_section_enter(); |
thedo | 167:1657b442184c | 229 | currentValue = *ptr; |
thedo | 167:1657b442184c | 230 | if (currentValue == *expectedCurrentValue) { |
thedo | 167:1657b442184c | 231 | *ptr = desiredValue; |
thedo | 167:1657b442184c | 232 | success = true; |
thedo | 167:1657b442184c | 233 | } else { |
thedo | 167:1657b442184c | 234 | *expectedCurrentValue = currentValue; |
thedo | 167:1657b442184c | 235 | success = false; |
thedo | 167:1657b442184c | 236 | } |
thedo | 167:1657b442184c | 237 | core_util_critical_section_exit(); |
thedo | 167:1657b442184c | 238 | return success; |
thedo | 167:1657b442184c | 239 | } |
thedo | 167:1657b442184c | 240 | |
thedo | 167:1657b442184c | 241 | |
thedo | 167:1657b442184c | 242 | bool core_util_atomic_cas_u32(uint32_t *ptr, uint32_t *expectedCurrentValue, uint32_t desiredValue) |
thedo | 167:1657b442184c | 243 | { |
thedo | 167:1657b442184c | 244 | bool success; |
thedo | 167:1657b442184c | 245 | uint32_t currentValue; |
thedo | 167:1657b442184c | 246 | core_util_critical_section_enter(); |
thedo | 167:1657b442184c | 247 | currentValue = *ptr; |
thedo | 167:1657b442184c | 248 | if (currentValue == *expectedCurrentValue) { |
thedo | 167:1657b442184c | 249 | *ptr = desiredValue; |
thedo | 167:1657b442184c | 250 | success = true; |
thedo | 167:1657b442184c | 251 | } else { |
thedo | 167:1657b442184c | 252 | *expectedCurrentValue = currentValue; |
thedo | 167:1657b442184c | 253 | success = false; |
thedo | 167:1657b442184c | 254 | } |
thedo | 167:1657b442184c | 255 | core_util_critical_section_exit(); |
thedo | 167:1657b442184c | 256 | return success; |
thedo | 167:1657b442184c | 257 | } |
thedo | 167:1657b442184c | 258 | |
thedo | 167:1657b442184c | 259 | |
thedo | 167:1657b442184c | 260 | uint8_t core_util_atomic_incr_u8(uint8_t *valuePtr, uint8_t delta) |
thedo | 167:1657b442184c | 261 | { |
thedo | 167:1657b442184c | 262 | uint8_t newValue; |
thedo | 167:1657b442184c | 263 | core_util_critical_section_enter(); |
thedo | 167:1657b442184c | 264 | newValue = *valuePtr + delta; |
thedo | 167:1657b442184c | 265 | *valuePtr = newValue; |
thedo | 167:1657b442184c | 266 | core_util_critical_section_exit(); |
thedo | 167:1657b442184c | 267 | return newValue; |
thedo | 167:1657b442184c | 268 | } |
thedo | 167:1657b442184c | 269 | |
thedo | 167:1657b442184c | 270 | uint16_t core_util_atomic_incr_u16(uint16_t *valuePtr, uint16_t delta) |
thedo | 167:1657b442184c | 271 | { |
thedo | 167:1657b442184c | 272 | uint16_t newValue; |
thedo | 167:1657b442184c | 273 | core_util_critical_section_enter(); |
thedo | 167:1657b442184c | 274 | newValue = *valuePtr + delta; |
thedo | 167:1657b442184c | 275 | *valuePtr = newValue; |
thedo | 167:1657b442184c | 276 | core_util_critical_section_exit(); |
thedo | 167:1657b442184c | 277 | return newValue; |
thedo | 167:1657b442184c | 278 | } |
thedo | 167:1657b442184c | 279 | |
thedo | 167:1657b442184c | 280 | uint32_t core_util_atomic_incr_u32(uint32_t *valuePtr, uint32_t delta) |
thedo | 167:1657b442184c | 281 | { |
thedo | 167:1657b442184c | 282 | uint32_t newValue; |
thedo | 167:1657b442184c | 283 | core_util_critical_section_enter(); |
thedo | 167:1657b442184c | 284 | newValue = *valuePtr + delta; |
thedo | 167:1657b442184c | 285 | *valuePtr = newValue; |
thedo | 167:1657b442184c | 286 | core_util_critical_section_exit(); |
thedo | 167:1657b442184c | 287 | return newValue; |
thedo | 167:1657b442184c | 288 | } |
thedo | 167:1657b442184c | 289 | |
thedo | 167:1657b442184c | 290 | |
thedo | 167:1657b442184c | 291 | uint8_t core_util_atomic_decr_u8(uint8_t *valuePtr, uint8_t delta) |
thedo | 167:1657b442184c | 292 | { |
thedo | 167:1657b442184c | 293 | uint8_t newValue; |
thedo | 167:1657b442184c | 294 | core_util_critical_section_enter(); |
thedo | 167:1657b442184c | 295 | newValue = *valuePtr - delta; |
thedo | 167:1657b442184c | 296 | *valuePtr = newValue; |
thedo | 167:1657b442184c | 297 | core_util_critical_section_exit(); |
thedo | 167:1657b442184c | 298 | return newValue; |
thedo | 167:1657b442184c | 299 | } |
thedo | 167:1657b442184c | 300 | |
thedo | 167:1657b442184c | 301 | uint16_t core_util_atomic_decr_u16(uint16_t *valuePtr, uint16_t delta) |
thedo | 167:1657b442184c | 302 | { |
thedo | 167:1657b442184c | 303 | uint16_t newValue; |
thedo | 167:1657b442184c | 304 | core_util_critical_section_enter(); |
thedo | 167:1657b442184c | 305 | newValue = *valuePtr - delta; |
thedo | 167:1657b442184c | 306 | *valuePtr = newValue; |
thedo | 167:1657b442184c | 307 | core_util_critical_section_exit(); |
thedo | 167:1657b442184c | 308 | return newValue; |
thedo | 167:1657b442184c | 309 | } |
thedo | 167:1657b442184c | 310 | |
thedo | 167:1657b442184c | 311 | uint32_t core_util_atomic_decr_u32(uint32_t *valuePtr, uint32_t delta) |
thedo | 167:1657b442184c | 312 | { |
thedo | 167:1657b442184c | 313 | uint32_t newValue; |
thedo | 167:1657b442184c | 314 | core_util_critical_section_enter(); |
thedo | 167:1657b442184c | 315 | newValue = *valuePtr - delta; |
thedo | 167:1657b442184c | 316 | *valuePtr = newValue; |
thedo | 167:1657b442184c | 317 | core_util_critical_section_exit(); |
thedo | 167:1657b442184c | 318 | return newValue; |
thedo | 167:1657b442184c | 319 | } |
thedo | 167:1657b442184c | 320 | |
thedo | 167:1657b442184c | 321 | #endif |
thedo | 167:1657b442184c | 322 | |
thedo | 167:1657b442184c | 323 | |
thedo | 167:1657b442184c | 324 | bool core_util_atomic_cas_ptr(void **ptr, void **expectedCurrentValue, void *desiredValue) { |
thedo | 167:1657b442184c | 325 | return core_util_atomic_cas_u32( |
thedo | 167:1657b442184c | 326 | (uint32_t *)ptr, |
thedo | 167:1657b442184c | 327 | (uint32_t *)expectedCurrentValue, |
thedo | 167:1657b442184c | 328 | (uint32_t)desiredValue); |
thedo | 167:1657b442184c | 329 | } |
thedo | 167:1657b442184c | 330 | |
thedo | 167:1657b442184c | 331 | void *core_util_atomic_incr_ptr(void **valuePtr, ptrdiff_t delta) { |
thedo | 167:1657b442184c | 332 | return (void *)core_util_atomic_incr_u32((uint32_t *)valuePtr, (uint32_t)delta); |
thedo | 167:1657b442184c | 333 | } |
thedo | 167:1657b442184c | 334 | |
thedo | 167:1657b442184c | 335 | void *core_util_atomic_decr_ptr(void **valuePtr, ptrdiff_t delta) { |
thedo | 167:1657b442184c | 336 | return (void *)core_util_atomic_decr_u32((uint32_t *)valuePtr, (uint32_t)delta); |
thedo | 167:1657b442184c | 337 | } |
thedo | 167:1657b442184c | 338 | |
thedo | 167:1657b442184c | 339 |