,,

Fork of Application by Daniel Sygut

Committer:
Zaitsev
Date:
Tue Jan 10 20:42:26 2017 +0000
Revision:
10:41552d038a69
USB Serial bi-directional bridge

Who changed what in which revision?

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