inport from local

Dependents:   Hobbyking_Cheetah_0511

Committer:
NYX
Date:
Mon Mar 16 06:35:48 2020 +0000
Revision:
0:85b3fd62ea1a
reinport to mbed;

Who changed what in which revision?

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