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