Describes predefine macros for mbed online compiler (armcc)

Committer:
MACRUM
Date:
Thu Mar 16 21:58:09 2017 +0900
Revision:
6:40e873bbc5f7
Add licence header info

Who changed what in which revision?

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