TUKS MCU Introductory course / TUKS-COURSE-TIMER
Committer:
elmot
Date:
Fri Feb 24 21:13:56 2017 +0000
Revision:
1:d0dfbce63a89
Ready-to-copy

Who changed what in which revision?

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