From Ben Katz mbed-dev library. Removed unnecessary target files to reduce the overall size by a factor of 10 to make it easier to import into the online IDE.

Dependents:   motor_driver motor_driver_screaming_fix

Committer:
saloutos
Date:
Thu Nov 26 04:08:56 2020 +0000
Revision:
0:083111ae2a11
first commit of leaned mbed dev lib

Who changed what in which revision?

UserRevisionLine numberNew contents of line
saloutos 0:083111ae2a11 1
saloutos 0:083111ae2a11 2 /** \addtogroup platform */
saloutos 0:083111ae2a11 3 /** @{*/
saloutos 0:083111ae2a11 4 /*
saloutos 0:083111ae2a11 5 * Copyright (c) 2015-2016, ARM Limited, All Rights Reserved
saloutos 0:083111ae2a11 6 * SPDX-License-Identifier: Apache-2.0
saloutos 0:083111ae2a11 7 *
saloutos 0:083111ae2a11 8 * Licensed under the Apache License, Version 2.0 (the "License"); you may
saloutos 0:083111ae2a11 9 * not use this file except in compliance with the License.
saloutos 0:083111ae2a11 10 * You may obtain a copy of the License at
saloutos 0:083111ae2a11 11 *
saloutos 0:083111ae2a11 12 * http://www.apache.org/licenses/LICENSE-2.0
saloutos 0:083111ae2a11 13 *
saloutos 0:083111ae2a11 14 * Unless required by applicable law or agreed to in writing, software
saloutos 0:083111ae2a11 15 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
saloutos 0:083111ae2a11 16 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
saloutos 0:083111ae2a11 17 * See the License for the specific language governing permissions and
saloutos 0:083111ae2a11 18 * limitations under the License.
saloutos 0:083111ae2a11 19 */
saloutos 0:083111ae2a11 20
saloutos 0:083111ae2a11 21 #ifndef __MBED_UTIL_CRITICAL_H__
saloutos 0:083111ae2a11 22 #define __MBED_UTIL_CRITICAL_H__
saloutos 0:083111ae2a11 23
saloutos 0:083111ae2a11 24 #include <stdbool.h>
saloutos 0:083111ae2a11 25 #include <stdint.h>
saloutos 0:083111ae2a11 26 #include <stddef.h>
saloutos 0:083111ae2a11 27
saloutos 0:083111ae2a11 28 #ifdef __cplusplus
saloutos 0:083111ae2a11 29 extern "C" {
saloutos 0:083111ae2a11 30 #endif
saloutos 0:083111ae2a11 31
saloutos 0:083111ae2a11 32
saloutos 0:083111ae2a11 33 /** Determine the current interrupts enabled state
saloutos 0:083111ae2a11 34 *
saloutos 0:083111ae2a11 35 * This function can be called to determine whether or not interrupts are currently enabled.
saloutos 0:083111ae2a11 36 * @note
saloutos 0:083111ae2a11 37 * NOTE:
saloutos 0:083111ae2a11 38 * This function works for both cortex-A and cortex-M, although the underlyng implementation
saloutos 0:083111ae2a11 39 * differs.
saloutos 0:083111ae2a11 40 * @return true if interrupts are enabled, false otherwise
saloutos 0:083111ae2a11 41 */
saloutos 0:083111ae2a11 42 bool core_util_are_interrupts_enabled(void);
saloutos 0:083111ae2a11 43
saloutos 0:083111ae2a11 44 /** Determine if this code is executing from an interrupt
saloutos 0:083111ae2a11 45 *
saloutos 0:083111ae2a11 46 * This function can be called to determine if the code is running on interrupt context.
saloutos 0:083111ae2a11 47 * @note
saloutos 0:083111ae2a11 48 * NOTE:
saloutos 0:083111ae2a11 49 * This function works for both cortex-A and cortex-M, although the underlyng implementation
saloutos 0:083111ae2a11 50 * differs.
saloutos 0:083111ae2a11 51 * @return true if in an isr, false otherwise
saloutos 0:083111ae2a11 52 */
saloutos 0:083111ae2a11 53 bool core_util_is_isr_active(void);
saloutos 0:083111ae2a11 54
saloutos 0:083111ae2a11 55 /** Mark the start of a critical section
saloutos 0:083111ae2a11 56 *
saloutos 0:083111ae2a11 57 * This function should be called to mark the start of a critical section of code.
saloutos 0:083111ae2a11 58 * @note
saloutos 0:083111ae2a11 59 * NOTES:
saloutos 0:083111ae2a11 60 * 1) The use of this style of critical section is targetted at C based implementations.
saloutos 0:083111ae2a11 61 * 2) These critical sections can be nested.
saloutos 0:083111ae2a11 62 * 3) The interrupt enable state on entry to the first critical section (of a nested set, or single
saloutos 0:083111ae2a11 63 * section) will be preserved on exit from the section.
saloutos 0:083111ae2a11 64 * 4) This implementation will currently only work on code running in privileged mode.
saloutos 0:083111ae2a11 65 */
saloutos 0:083111ae2a11 66 void core_util_critical_section_enter(void);
saloutos 0:083111ae2a11 67
saloutos 0:083111ae2a11 68 /** Mark the end of a critical section
saloutos 0:083111ae2a11 69 *
saloutos 0:083111ae2a11 70 * This function should be called to mark the end of a critical section of code.
saloutos 0:083111ae2a11 71 * @note
saloutos 0:083111ae2a11 72 * NOTES:
saloutos 0:083111ae2a11 73 * 1) The use of this style of critical section is targetted at C based implementations.
saloutos 0:083111ae2a11 74 * 2) These critical sections can be nested.
saloutos 0:083111ae2a11 75 * 3) The interrupt enable state on entry to the first critical section (of a nested set, or single
saloutos 0:083111ae2a11 76 * section) will be preserved on exit from the section.
saloutos 0:083111ae2a11 77 * 4) This implementation will currently only work on code running in privileged mode.
saloutos 0:083111ae2a11 78 */
saloutos 0:083111ae2a11 79 void core_util_critical_section_exit(void);
saloutos 0:083111ae2a11 80
saloutos 0:083111ae2a11 81 /**
saloutos 0:083111ae2a11 82 * Atomic compare and set. It compares the contents of a memory location to a
saloutos 0:083111ae2a11 83 * given value and, only if they are the same, modifies the contents of that
saloutos 0:083111ae2a11 84 * memory location to a given new value. This is done as a single atomic
saloutos 0:083111ae2a11 85 * operation. The atomicity guarantees that the new value is calculated based on
saloutos 0:083111ae2a11 86 * up-to-date information; if the value had been updated by another thread in
saloutos 0:083111ae2a11 87 * the meantime, the write would fail due to a mismatched expectedCurrentValue.
saloutos 0:083111ae2a11 88 *
saloutos 0:083111ae2a11 89 * Refer to https://en.wikipedia.org/wiki/Compare-and-set [which may redirect
saloutos 0:083111ae2a11 90 * you to the article on compare-and swap].
saloutos 0:083111ae2a11 91 *
saloutos 0:083111ae2a11 92 * @param ptr The target memory location.
saloutos 0:083111ae2a11 93 * @param[in,out] expectedCurrentValue A pointer to some location holding the
saloutos 0:083111ae2a11 94 * expected current value of the data being set atomically.
saloutos 0:083111ae2a11 95 * The computed 'desiredValue' should be a function of this current value.
saloutos 0:083111ae2a11 96 * @note: This is an in-out parameter. In the
saloutos 0:083111ae2a11 97 * failure case of atomic_cas (where the
saloutos 0:083111ae2a11 98 * destination isn't set), the pointee of expectedCurrentValue is
saloutos 0:083111ae2a11 99 * updated with the current value.
saloutos 0:083111ae2a11 100 * @param[in] desiredValue The new value computed based on '*expectedCurrentValue'.
saloutos 0:083111ae2a11 101 *
saloutos 0:083111ae2a11 102 * @return true if the memory location was atomically
saloutos 0:083111ae2a11 103 * updated with the desired value (after verifying
saloutos 0:083111ae2a11 104 * that it contained the expectedCurrentValue),
saloutos 0:083111ae2a11 105 * false otherwise. In the failure case,
saloutos 0:083111ae2a11 106 * exepctedCurrentValue is updated with the new
saloutos 0:083111ae2a11 107 * value of the target memory location.
saloutos 0:083111ae2a11 108 *
saloutos 0:083111ae2a11 109 * pseudocode:
saloutos 0:083111ae2a11 110 * function cas(p : pointer to int, old : pointer to int, new : int) returns bool {
saloutos 0:083111ae2a11 111 * if *p != *old {
saloutos 0:083111ae2a11 112 * *old = *p
saloutos 0:083111ae2a11 113 * return false
saloutos 0:083111ae2a11 114 * }
saloutos 0:083111ae2a11 115 * *p = new
saloutos 0:083111ae2a11 116 * return true
saloutos 0:083111ae2a11 117 * }
saloutos 0:083111ae2a11 118 *
saloutos 0:083111ae2a11 119 * @note: In the failure case (where the destination isn't set), the value
saloutos 0:083111ae2a11 120 * pointed to by expectedCurrentValue is still updated with the current value.
saloutos 0:083111ae2a11 121 * This property helps writing concise code for the following incr:
saloutos 0:083111ae2a11 122 *
saloutos 0:083111ae2a11 123 * function incr(p : pointer to int, a : int) returns int {
saloutos 0:083111ae2a11 124 * done = false
saloutos 0:083111ae2a11 125 * value = *p // This fetch operation need not be atomic.
saloutos 0:083111ae2a11 126 * while not done {
saloutos 0:083111ae2a11 127 * done = atomic_cas(p, &value, value + a) // *value gets updated automatically until success
saloutos 0:083111ae2a11 128 * }
saloutos 0:083111ae2a11 129 * return value + a
saloutos 0:083111ae2a11 130 * }
saloutos 0:083111ae2a11 131 */
saloutos 0:083111ae2a11 132 bool core_util_atomic_cas_u8(uint8_t *ptr, uint8_t *expectedCurrentValue, uint8_t desiredValue);
saloutos 0:083111ae2a11 133
saloutos 0:083111ae2a11 134 /**
saloutos 0:083111ae2a11 135 * Atomic compare and set. It compares the contents of a memory location to a
saloutos 0:083111ae2a11 136 * given value and, only if they are the same, modifies the contents of that
saloutos 0:083111ae2a11 137 * memory location to a given new value. This is done as a single atomic
saloutos 0:083111ae2a11 138 * operation. The atomicity guarantees that the new value is calculated based on
saloutos 0:083111ae2a11 139 * up-to-date information; if the value had been updated by another thread in
saloutos 0:083111ae2a11 140 * the meantime, the write would fail due to a mismatched expectedCurrentValue.
saloutos 0:083111ae2a11 141 *
saloutos 0:083111ae2a11 142 * Refer to https://en.wikipedia.org/wiki/Compare-and-set [which may redirect
saloutos 0:083111ae2a11 143 * you to the article on compare-and swap].
saloutos 0:083111ae2a11 144 *
saloutos 0:083111ae2a11 145 * @param ptr The target memory location.
saloutos 0:083111ae2a11 146 * @param[in,out] expectedCurrentValue A pointer to some location holding the
saloutos 0:083111ae2a11 147 * expected current value of the data being set atomically.
saloutos 0:083111ae2a11 148 * The computed 'desiredValue' should be a function of this current value.
saloutos 0:083111ae2a11 149 * @note: This is an in-out parameter. In the
saloutos 0:083111ae2a11 150 * failure case of atomic_cas (where the
saloutos 0:083111ae2a11 151 * destination isn't set), the pointee of expectedCurrentValue is
saloutos 0:083111ae2a11 152 * updated with the current value.
saloutos 0:083111ae2a11 153 * @param[in] desiredValue The new value computed based on '*expectedCurrentValue'.
saloutos 0:083111ae2a11 154 *
saloutos 0:083111ae2a11 155 * @return true if the memory location was atomically
saloutos 0:083111ae2a11 156 * updated with the desired value (after verifying
saloutos 0:083111ae2a11 157 * that it contained the expectedCurrentValue),
saloutos 0:083111ae2a11 158 * false otherwise. In the failure case,
saloutos 0:083111ae2a11 159 * exepctedCurrentValue is updated with the new
saloutos 0:083111ae2a11 160 * value of the target memory location.
saloutos 0:083111ae2a11 161 *
saloutos 0:083111ae2a11 162 * pseudocode:
saloutos 0:083111ae2a11 163 * function cas(p : pointer to int, old : pointer to int, new : int) returns bool {
saloutos 0:083111ae2a11 164 * if *p != *old {
saloutos 0:083111ae2a11 165 * *old = *p
saloutos 0:083111ae2a11 166 * return false
saloutos 0:083111ae2a11 167 * }
saloutos 0:083111ae2a11 168 * *p = new
saloutos 0:083111ae2a11 169 * return true
saloutos 0:083111ae2a11 170 * }
saloutos 0:083111ae2a11 171 *
saloutos 0:083111ae2a11 172 * @note: In the failure case (where the destination isn't set), the value
saloutos 0:083111ae2a11 173 * pointed to by expectedCurrentValue is still updated with the current value.
saloutos 0:083111ae2a11 174 * This property helps writing concise code for the following incr:
saloutos 0:083111ae2a11 175 *
saloutos 0:083111ae2a11 176 * function incr(p : pointer to int, a : int) returns int {
saloutos 0:083111ae2a11 177 * done = false
saloutos 0:083111ae2a11 178 * value = *p // This fetch operation need not be atomic.
saloutos 0:083111ae2a11 179 * while not done {
saloutos 0:083111ae2a11 180 * done = atomic_cas(p, &value, value + a) // *value gets updated automatically until success
saloutos 0:083111ae2a11 181 * }
saloutos 0:083111ae2a11 182 * return value + a
saloutos 0:083111ae2a11 183 * }
saloutos 0:083111ae2a11 184 */
saloutos 0:083111ae2a11 185 bool core_util_atomic_cas_u16(uint16_t *ptr, uint16_t *expectedCurrentValue, uint16_t desiredValue);
saloutos 0:083111ae2a11 186
saloutos 0:083111ae2a11 187 /**
saloutos 0:083111ae2a11 188 * Atomic compare and set. It compares the contents of a memory location to a
saloutos 0:083111ae2a11 189 * given value and, only if they are the same, modifies the contents of that
saloutos 0:083111ae2a11 190 * memory location to a given new value. This is done as a single atomic
saloutos 0:083111ae2a11 191 * operation. The atomicity guarantees that the new value is calculated based on
saloutos 0:083111ae2a11 192 * up-to-date information; if the value had been updated by another thread in
saloutos 0:083111ae2a11 193 * the meantime, the write would fail due to a mismatched expectedCurrentValue.
saloutos 0:083111ae2a11 194 *
saloutos 0:083111ae2a11 195 * Refer to https://en.wikipedia.org/wiki/Compare-and-set [which may redirect
saloutos 0:083111ae2a11 196 * you to the article on compare-and swap].
saloutos 0:083111ae2a11 197 *
saloutos 0:083111ae2a11 198 * @param ptr The target memory location.
saloutos 0:083111ae2a11 199 * @param[in,out] expectedCurrentValue A pointer to some location holding the
saloutos 0:083111ae2a11 200 * expected current value of the data being set atomically.
saloutos 0:083111ae2a11 201 * The computed 'desiredValue' should be a function of this current value.
saloutos 0:083111ae2a11 202 * @note: This is an in-out parameter. In the
saloutos 0:083111ae2a11 203 * failure case of atomic_cas (where the
saloutos 0:083111ae2a11 204 * destination isn't set), the pointee of expectedCurrentValue is
saloutos 0:083111ae2a11 205 * updated with the current value.
saloutos 0:083111ae2a11 206 * @param[in] desiredValue The new value computed based on '*expectedCurrentValue'.
saloutos 0:083111ae2a11 207 *
saloutos 0:083111ae2a11 208 * @return true if the memory location was atomically
saloutos 0:083111ae2a11 209 * updated with the desired value (after verifying
saloutos 0:083111ae2a11 210 * that it contained the expectedCurrentValue),
saloutos 0:083111ae2a11 211 * false otherwise. In the failure case,
saloutos 0:083111ae2a11 212 * exepctedCurrentValue is updated with the new
saloutos 0:083111ae2a11 213 * value of the target memory location.
saloutos 0:083111ae2a11 214 *
saloutos 0:083111ae2a11 215 * pseudocode:
saloutos 0:083111ae2a11 216 * function cas(p : pointer to int, old : pointer to int, new : int) returns bool {
saloutos 0:083111ae2a11 217 * if *p != *old {
saloutos 0:083111ae2a11 218 * *old = *p
saloutos 0:083111ae2a11 219 * return false
saloutos 0:083111ae2a11 220 * }
saloutos 0:083111ae2a11 221 * *p = new
saloutos 0:083111ae2a11 222 * return true
saloutos 0:083111ae2a11 223 * }
saloutos 0:083111ae2a11 224 *
saloutos 0:083111ae2a11 225 * @note: In the failure case (where the destination isn't set), the value
saloutos 0:083111ae2a11 226 * pointed to by expectedCurrentValue is still updated with the current value.
saloutos 0:083111ae2a11 227 * This property helps writing concise code for the following incr:
saloutos 0:083111ae2a11 228 *
saloutos 0:083111ae2a11 229 * function incr(p : pointer to int, a : int) returns int {
saloutos 0:083111ae2a11 230 * done = false
saloutos 0:083111ae2a11 231 * value = *p // This fetch operation need not be atomic.
saloutos 0:083111ae2a11 232 * while not done {
saloutos 0:083111ae2a11 233 * done = atomic_cas(p, &value, value + a) // *value gets updated automatically until success
saloutos 0:083111ae2a11 234 * }
saloutos 0:083111ae2a11 235 * return value + a
saloutos 0:083111ae2a11 236 * }
saloutos 0:083111ae2a11 237 */
saloutos 0:083111ae2a11 238 bool core_util_atomic_cas_u32(uint32_t *ptr, uint32_t *expectedCurrentValue, uint32_t desiredValue);
saloutos 0:083111ae2a11 239
saloutos 0:083111ae2a11 240 /**
saloutos 0:083111ae2a11 241 * Atomic compare and set. It compares the contents of a memory location to a
saloutos 0:083111ae2a11 242 * given value and, only if they are the same, modifies the contents of that
saloutos 0:083111ae2a11 243 * memory location to a given new value. This is done as a single atomic
saloutos 0:083111ae2a11 244 * operation. The atomicity guarantees that the new value is calculated based on
saloutos 0:083111ae2a11 245 * up-to-date information; if the value had been updated by another thread in
saloutos 0:083111ae2a11 246 * the meantime, the write would fail due to a mismatched expectedCurrentValue.
saloutos 0:083111ae2a11 247 *
saloutos 0:083111ae2a11 248 * Refer to https://en.wikipedia.org/wiki/Compare-and-set [which may redirect
saloutos 0:083111ae2a11 249 * you to the article on compare-and swap].
saloutos 0:083111ae2a11 250 *
saloutos 0:083111ae2a11 251 * @param ptr The target memory location.
saloutos 0:083111ae2a11 252 * @param[in,out] expectedCurrentValue A pointer to some location holding the
saloutos 0:083111ae2a11 253 * expected current value of the data being set atomically.
saloutos 0:083111ae2a11 254 * The computed 'desiredValue' should be a function of this current value.
saloutos 0:083111ae2a11 255 * @note: This is an in-out parameter. In the
saloutos 0:083111ae2a11 256 * failure case of atomic_cas (where the
saloutos 0:083111ae2a11 257 * destination isn't set), the pointee of expectedCurrentValue is
saloutos 0:083111ae2a11 258 * updated with the current value.
saloutos 0:083111ae2a11 259 * @param[in] desiredValue The new value computed based on '*expectedCurrentValue'.
saloutos 0:083111ae2a11 260 *
saloutos 0:083111ae2a11 261 * @return true if the memory location was atomically
saloutos 0:083111ae2a11 262 * updated with the desired value (after verifying
saloutos 0:083111ae2a11 263 * that it contained the expectedCurrentValue),
saloutos 0:083111ae2a11 264 * false otherwise. In the failure case,
saloutos 0:083111ae2a11 265 * exepctedCurrentValue is updated with the new
saloutos 0:083111ae2a11 266 * value of the target memory location.
saloutos 0:083111ae2a11 267 *
saloutos 0:083111ae2a11 268 * pseudocode:
saloutos 0:083111ae2a11 269 * function cas(p : pointer to int, old : pointer to int, new : int) returns bool {
saloutos 0:083111ae2a11 270 * if *p != *old {
saloutos 0:083111ae2a11 271 * *old = *p
saloutos 0:083111ae2a11 272 * return false
saloutos 0:083111ae2a11 273 * }
saloutos 0:083111ae2a11 274 * *p = new
saloutos 0:083111ae2a11 275 * return true
saloutos 0:083111ae2a11 276 * }
saloutos 0:083111ae2a11 277 *
saloutos 0:083111ae2a11 278 * @note: In the failure case (where the destination isn't set), the value
saloutos 0:083111ae2a11 279 * pointed to by expectedCurrentValue is still updated with the current value.
saloutos 0:083111ae2a11 280 * This property helps writing concise code for the following incr:
saloutos 0:083111ae2a11 281 *
saloutos 0:083111ae2a11 282 * function incr(p : pointer to int, a : int) returns int {
saloutos 0:083111ae2a11 283 * done = false
saloutos 0:083111ae2a11 284 * value = *p // This fetch operation need not be atomic.
saloutos 0:083111ae2a11 285 * while not done {
saloutos 0:083111ae2a11 286 * done = atomic_cas(p, &value, value + a) // *value gets updated automatically until success
saloutos 0:083111ae2a11 287 * }
saloutos 0:083111ae2a11 288 * return value + a
saloutos 0:083111ae2a11 289 * }
saloutos 0:083111ae2a11 290 */
saloutos 0:083111ae2a11 291 bool core_util_atomic_cas_ptr(void **ptr, void **expectedCurrentValue, void *desiredValue);
saloutos 0:083111ae2a11 292
saloutos 0:083111ae2a11 293 /**
saloutos 0:083111ae2a11 294 * Atomic increment.
saloutos 0:083111ae2a11 295 * @param valuePtr Target memory location being incremented.
saloutos 0:083111ae2a11 296 * @param delta The amount being incremented.
saloutos 0:083111ae2a11 297 * @return The new incremented value.
saloutos 0:083111ae2a11 298 */
saloutos 0:083111ae2a11 299 uint8_t core_util_atomic_incr_u8(uint8_t *valuePtr, uint8_t delta);
saloutos 0:083111ae2a11 300
saloutos 0:083111ae2a11 301 /**
saloutos 0:083111ae2a11 302 * Atomic increment.
saloutos 0:083111ae2a11 303 * @param valuePtr Target memory location being incremented.
saloutos 0:083111ae2a11 304 * @param delta The amount being incremented.
saloutos 0:083111ae2a11 305 * @return The new incremented value.
saloutos 0:083111ae2a11 306 */
saloutos 0:083111ae2a11 307 uint16_t core_util_atomic_incr_u16(uint16_t *valuePtr, uint16_t delta);
saloutos 0:083111ae2a11 308
saloutos 0:083111ae2a11 309 /**
saloutos 0:083111ae2a11 310 * Atomic increment.
saloutos 0:083111ae2a11 311 * @param valuePtr Target memory location being incremented.
saloutos 0:083111ae2a11 312 * @param delta The amount being incremented.
saloutos 0:083111ae2a11 313 * @return The new incremented value.
saloutos 0:083111ae2a11 314 */
saloutos 0:083111ae2a11 315 uint32_t core_util_atomic_incr_u32(uint32_t *valuePtr, uint32_t delta);
saloutos 0:083111ae2a11 316
saloutos 0:083111ae2a11 317 /**
saloutos 0:083111ae2a11 318 * Atomic increment.
saloutos 0:083111ae2a11 319 * @param valuePtr Target memory location being incremented.
saloutos 0:083111ae2a11 320 * @param delta The amount being incremented in bytes.
saloutos 0:083111ae2a11 321 * @return The new incremented value.
saloutos 0:083111ae2a11 322 *
saloutos 0:083111ae2a11 323 * @note The type of the pointer argument is not taken into account
saloutos 0:083111ae2a11 324 * and the pointer is incremented by bytes.
saloutos 0:083111ae2a11 325 */
saloutos 0:083111ae2a11 326 void *core_util_atomic_incr_ptr(void **valuePtr, ptrdiff_t delta);
saloutos 0:083111ae2a11 327
saloutos 0:083111ae2a11 328 /**
saloutos 0:083111ae2a11 329 * Atomic decrement.
saloutos 0:083111ae2a11 330 * @param valuePtr Target memory location being decremented.
saloutos 0:083111ae2a11 331 * @param delta The amount being decremented.
saloutos 0:083111ae2a11 332 * @return The new decremented value.
saloutos 0:083111ae2a11 333 */
saloutos 0:083111ae2a11 334 uint8_t core_util_atomic_decr_u8(uint8_t *valuePtr, uint8_t delta);
saloutos 0:083111ae2a11 335
saloutos 0:083111ae2a11 336 /**
saloutos 0:083111ae2a11 337 * Atomic decrement.
saloutos 0:083111ae2a11 338 * @param valuePtr Target memory location being decremented.
saloutos 0:083111ae2a11 339 * @param delta The amount being decremented.
saloutos 0:083111ae2a11 340 * @return The new decremented value.
saloutos 0:083111ae2a11 341 */
saloutos 0:083111ae2a11 342 uint16_t core_util_atomic_decr_u16(uint16_t *valuePtr, uint16_t delta);
saloutos 0:083111ae2a11 343
saloutos 0:083111ae2a11 344 /**
saloutos 0:083111ae2a11 345 * Atomic decrement.
saloutos 0:083111ae2a11 346 * @param valuePtr Target memory location being decremented.
saloutos 0:083111ae2a11 347 * @param delta The amount being decremented.
saloutos 0:083111ae2a11 348 * @return The new decremented value.
saloutos 0:083111ae2a11 349 */
saloutos 0:083111ae2a11 350 uint32_t core_util_atomic_decr_u32(uint32_t *valuePtr, uint32_t delta);
saloutos 0:083111ae2a11 351
saloutos 0:083111ae2a11 352 /**
saloutos 0:083111ae2a11 353 * Atomic decrement.
saloutos 0:083111ae2a11 354 * @param valuePtr Target memory location being decremented.
saloutos 0:083111ae2a11 355 * @param delta The amount being decremented in bytes.
saloutos 0:083111ae2a11 356 * @return The new decremented value.
saloutos 0:083111ae2a11 357 *
saloutos 0:083111ae2a11 358 * @note The type of the pointer argument is not taken into account
saloutos 0:083111ae2a11 359 * and the pointer is decremented by bytes
saloutos 0:083111ae2a11 360 */
saloutos 0:083111ae2a11 361 void *core_util_atomic_decr_ptr(void **valuePtr, ptrdiff_t delta);
saloutos 0:083111ae2a11 362
saloutos 0:083111ae2a11 363 #ifdef __cplusplus
saloutos 0:083111ae2a11 364 } // extern "C"
saloutos 0:083111ae2a11 365 #endif
saloutos 0:083111ae2a11 366
saloutos 0:083111ae2a11 367
saloutos 0:083111ae2a11 368 #endif // __MBED_UTIL_CRITICAL_H__
saloutos 0:083111ae2a11 369
saloutos 0:083111ae2a11 370 /** @}*/