mbed library sources. Supersedes mbed-src.
Fork of mbed-dev by
platform/mbed_critical.h@160:d5399cc887bb, 2017-03-14 (annotated)
- Committer:
- <>
- Date:
- Tue Mar 14 16:40:56 2017 +0000
- Revision:
- 160:d5399cc887bb
This updates the lib to the mbed lib v138
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. |
<> | 160:d5399cc887bb | 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 | |
<> | 160:d5399cc887bb | 44 | /** Mark the start of a critical section |
<> | 160:d5399cc887bb | 45 | * |
<> | 160:d5399cc887bb | 46 | * This function should be called to mark the start of a critical section of code. |
<> | 160:d5399cc887bb | 47 | * \note |
<> | 160:d5399cc887bb | 48 | * NOTES: |
<> | 160:d5399cc887bb | 49 | * 1) The use of this style of critical section is targetted at C based implementations. |
<> | 160:d5399cc887bb | 50 | * 2) These critical sections can be nested. |
<> | 160:d5399cc887bb | 51 | * 3) The interrupt enable state on entry to the first critical section (of a nested set, or single |
<> | 160:d5399cc887bb | 52 | * section) will be preserved on exit from the section. |
<> | 160:d5399cc887bb | 53 | * 4) This implementation will currently only work on code running in privileged mode. |
<> | 160:d5399cc887bb | 54 | */ |
<> | 160:d5399cc887bb | 55 | void core_util_critical_section_enter(void); |
<> | 160:d5399cc887bb | 56 | |
<> | 160:d5399cc887bb | 57 | /** Mark the end of a critical section |
<> | 160:d5399cc887bb | 58 | * |
<> | 160:d5399cc887bb | 59 | * This function should be called to mark the end of a critical section of code. |
<> | 160:d5399cc887bb | 60 | * \note |
<> | 160:d5399cc887bb | 61 | * NOTES: |
<> | 160:d5399cc887bb | 62 | * 1) The use of this style of critical section is targetted at C based implementations. |
<> | 160:d5399cc887bb | 63 | * 2) These critical sections can be nested. |
<> | 160:d5399cc887bb | 64 | * 3) The interrupt enable state on entry to the first critical section (of a nested set, or single |
<> | 160:d5399cc887bb | 65 | * section) will be preserved on exit from the section. |
<> | 160:d5399cc887bb | 66 | * 4) This implementation will currently only work on code running in privileged mode. |
<> | 160:d5399cc887bb | 67 | */ |
<> | 160:d5399cc887bb | 68 | void core_util_critical_section_exit(void); |
<> | 160:d5399cc887bb | 69 | |
<> | 160:d5399cc887bb | 70 | /** |
<> | 160:d5399cc887bb | 71 | * Atomic compare and set. It compares the contents of a memory location to a |
<> | 160:d5399cc887bb | 72 | * given value and, only if they are the same, modifies the contents of that |
<> | 160:d5399cc887bb | 73 | * memory location to a given new value. This is done as a single atomic |
<> | 160:d5399cc887bb | 74 | * operation. The atomicity guarantees that the new value is calculated based on |
<> | 160:d5399cc887bb | 75 | * up-to-date information; if the value had been updated by another thread in |
<> | 160:d5399cc887bb | 76 | * the meantime, the write would fail due to a mismatched expectedCurrentValue. |
<> | 160:d5399cc887bb | 77 | * |
<> | 160:d5399cc887bb | 78 | * Refer to https://en.wikipedia.org/wiki/Compare-and-set [which may redirect |
<> | 160:d5399cc887bb | 79 | * you to the article on compare-and swap]. |
<> | 160:d5399cc887bb | 80 | * |
<> | 160:d5399cc887bb | 81 | * @param ptr The target memory location. |
<> | 160:d5399cc887bb | 82 | * @param[in,out] expectedCurrentValue A pointer to some location holding the |
<> | 160:d5399cc887bb | 83 | * expected current value of the data being set atomically. |
<> | 160:d5399cc887bb | 84 | * The computed 'desiredValue' should be a function of this current value. |
<> | 160:d5399cc887bb | 85 | * @Note: This is an in-out parameter. In the |
<> | 160:d5399cc887bb | 86 | * failure case of atomic_cas (where the |
<> | 160:d5399cc887bb | 87 | * destination isn't set), the pointee of expectedCurrentValue is |
<> | 160:d5399cc887bb | 88 | * updated with the current value. |
<> | 160:d5399cc887bb | 89 | * @param[in] desiredValue The new value computed based on '*expectedCurrentValue'. |
<> | 160:d5399cc887bb | 90 | * |
<> | 160:d5399cc887bb | 91 | * @return true if the memory location was atomically |
<> | 160:d5399cc887bb | 92 | * updated with the desired value (after verifying |
<> | 160:d5399cc887bb | 93 | * that it contained the expectedCurrentValue), |
<> | 160:d5399cc887bb | 94 | * false otherwise. In the failure case, |
<> | 160:d5399cc887bb | 95 | * exepctedCurrentValue is updated with the new |
<> | 160:d5399cc887bb | 96 | * value of the target memory location. |
<> | 160:d5399cc887bb | 97 | * |
<> | 160:d5399cc887bb | 98 | * pseudocode: |
<> | 160:d5399cc887bb | 99 | * function cas(p : pointer to int, old : pointer to int, new : int) returns bool { |
<> | 160:d5399cc887bb | 100 | * if *p != *old { |
<> | 160:d5399cc887bb | 101 | * *old = *p |
<> | 160:d5399cc887bb | 102 | * return false |
<> | 160:d5399cc887bb | 103 | * } |
<> | 160:d5399cc887bb | 104 | * *p = new |
<> | 160:d5399cc887bb | 105 | * return true |
<> | 160:d5399cc887bb | 106 | * } |
<> | 160:d5399cc887bb | 107 | * |
<> | 160:d5399cc887bb | 108 | * @Note: In the failure case (where the destination isn't set), the value |
<> | 160:d5399cc887bb | 109 | * pointed to by expectedCurrentValue is still updated with the current value. |
<> | 160:d5399cc887bb | 110 | * This property helps writing concise code for the following incr: |
<> | 160:d5399cc887bb | 111 | * |
<> | 160:d5399cc887bb | 112 | * function incr(p : pointer to int, a : int) returns int { |
<> | 160:d5399cc887bb | 113 | * done = false |
<> | 160:d5399cc887bb | 114 | * value = *p // This fetch operation need not be atomic. |
<> | 160:d5399cc887bb | 115 | * while not done { |
<> | 160:d5399cc887bb | 116 | * done = atomic_cas(p, &value, value + a) // *value gets updated automatically until success |
<> | 160:d5399cc887bb | 117 | * } |
<> | 160:d5399cc887bb | 118 | * return value + a |
<> | 160:d5399cc887bb | 119 | * } |
<> | 160:d5399cc887bb | 120 | */ |
<> | 160:d5399cc887bb | 121 | bool core_util_atomic_cas_u8(uint8_t *ptr, uint8_t *expectedCurrentValue, uint8_t desiredValue); |
<> | 160:d5399cc887bb | 122 | |
<> | 160:d5399cc887bb | 123 | /** |
<> | 160:d5399cc887bb | 124 | * Atomic compare and set. It compares the contents of a memory location to a |
<> | 160:d5399cc887bb | 125 | * given value and, only if they are the same, modifies the contents of that |
<> | 160:d5399cc887bb | 126 | * memory location to a given new value. This is done as a single atomic |
<> | 160:d5399cc887bb | 127 | * operation. The atomicity guarantees that the new value is calculated based on |
<> | 160:d5399cc887bb | 128 | * up-to-date information; if the value had been updated by another thread in |
<> | 160:d5399cc887bb | 129 | * the meantime, the write would fail due to a mismatched expectedCurrentValue. |
<> | 160:d5399cc887bb | 130 | * |
<> | 160:d5399cc887bb | 131 | * Refer to https://en.wikipedia.org/wiki/Compare-and-set [which may redirect |
<> | 160:d5399cc887bb | 132 | * you to the article on compare-and swap]. |
<> | 160:d5399cc887bb | 133 | * |
<> | 160:d5399cc887bb | 134 | * @param ptr The target memory location. |
<> | 160:d5399cc887bb | 135 | * @param[in,out] expectedCurrentValue A pointer to some location holding the |
<> | 160:d5399cc887bb | 136 | * expected current value of the data being set atomically. |
<> | 160:d5399cc887bb | 137 | * The computed 'desiredValue' should be a function of this current value. |
<> | 160:d5399cc887bb | 138 | * @Note: This is an in-out parameter. In the |
<> | 160:d5399cc887bb | 139 | * failure case of atomic_cas (where the |
<> | 160:d5399cc887bb | 140 | * destination isn't set), the pointee of expectedCurrentValue is |
<> | 160:d5399cc887bb | 141 | * updated with the current value. |
<> | 160:d5399cc887bb | 142 | * @param[in] desiredValue The new value computed based on '*expectedCurrentValue'. |
<> | 160:d5399cc887bb | 143 | * |
<> | 160:d5399cc887bb | 144 | * @return true if the memory location was atomically |
<> | 160:d5399cc887bb | 145 | * updated with the desired value (after verifying |
<> | 160:d5399cc887bb | 146 | * that it contained the expectedCurrentValue), |
<> | 160:d5399cc887bb | 147 | * false otherwise. In the failure case, |
<> | 160:d5399cc887bb | 148 | * exepctedCurrentValue is updated with the new |
<> | 160:d5399cc887bb | 149 | * value of the target memory location. |
<> | 160:d5399cc887bb | 150 | * |
<> | 160:d5399cc887bb | 151 | * pseudocode: |
<> | 160:d5399cc887bb | 152 | * function cas(p : pointer to int, old : pointer to int, new : int) returns bool { |
<> | 160:d5399cc887bb | 153 | * if *p != *old { |
<> | 160:d5399cc887bb | 154 | * *old = *p |
<> | 160:d5399cc887bb | 155 | * return false |
<> | 160:d5399cc887bb | 156 | * } |
<> | 160:d5399cc887bb | 157 | * *p = new |
<> | 160:d5399cc887bb | 158 | * return true |
<> | 160:d5399cc887bb | 159 | * } |
<> | 160:d5399cc887bb | 160 | * |
<> | 160:d5399cc887bb | 161 | * @Note: In the failure case (where the destination isn't set), the value |
<> | 160:d5399cc887bb | 162 | * pointed to by expectedCurrentValue is still updated with the current value. |
<> | 160:d5399cc887bb | 163 | * This property helps writing concise code for the following incr: |
<> | 160:d5399cc887bb | 164 | * |
<> | 160:d5399cc887bb | 165 | * function incr(p : pointer to int, a : int) returns int { |
<> | 160:d5399cc887bb | 166 | * done = false |
<> | 160:d5399cc887bb | 167 | * value = *p // This fetch operation need not be atomic. |
<> | 160:d5399cc887bb | 168 | * while not done { |
<> | 160:d5399cc887bb | 169 | * done = atomic_cas(p, &value, value + a) // *value gets updated automatically until success |
<> | 160:d5399cc887bb | 170 | * } |
<> | 160:d5399cc887bb | 171 | * return value + a |
<> | 160:d5399cc887bb | 172 | * } |
<> | 160:d5399cc887bb | 173 | */ |
<> | 160:d5399cc887bb | 174 | bool core_util_atomic_cas_u16(uint16_t *ptr, uint16_t *expectedCurrentValue, uint16_t desiredValue); |
<> | 160:d5399cc887bb | 175 | |
<> | 160:d5399cc887bb | 176 | /** |
<> | 160:d5399cc887bb | 177 | * Atomic compare and set. It compares the contents of a memory location to a |
<> | 160:d5399cc887bb | 178 | * given value and, only if they are the same, modifies the contents of that |
<> | 160:d5399cc887bb | 179 | * memory location to a given new value. This is done as a single atomic |
<> | 160:d5399cc887bb | 180 | * operation. The atomicity guarantees that the new value is calculated based on |
<> | 160:d5399cc887bb | 181 | * up-to-date information; if the value had been updated by another thread in |
<> | 160:d5399cc887bb | 182 | * the meantime, the write would fail due to a mismatched expectedCurrentValue. |
<> | 160:d5399cc887bb | 183 | * |
<> | 160:d5399cc887bb | 184 | * Refer to https://en.wikipedia.org/wiki/Compare-and-set [which may redirect |
<> | 160:d5399cc887bb | 185 | * you to the article on compare-and swap]. |
<> | 160:d5399cc887bb | 186 | * |
<> | 160:d5399cc887bb | 187 | * @param ptr The target memory location. |
<> | 160:d5399cc887bb | 188 | * @param[in,out] expectedCurrentValue A pointer to some location holding the |
<> | 160:d5399cc887bb | 189 | * expected current value of the data being set atomically. |
<> | 160:d5399cc887bb | 190 | * The computed 'desiredValue' should be a function of this current value. |
<> | 160:d5399cc887bb | 191 | * @Note: This is an in-out parameter. In the |
<> | 160:d5399cc887bb | 192 | * failure case of atomic_cas (where the |
<> | 160:d5399cc887bb | 193 | * destination isn't set), the pointee of expectedCurrentValue is |
<> | 160:d5399cc887bb | 194 | * updated with the current value. |
<> | 160:d5399cc887bb | 195 | * @param[in] desiredValue The new value computed based on '*expectedCurrentValue'. |
<> | 160:d5399cc887bb | 196 | * |
<> | 160:d5399cc887bb | 197 | * @return true if the memory location was atomically |
<> | 160:d5399cc887bb | 198 | * updated with the desired value (after verifying |
<> | 160:d5399cc887bb | 199 | * that it contained the expectedCurrentValue), |
<> | 160:d5399cc887bb | 200 | * false otherwise. In the failure case, |
<> | 160:d5399cc887bb | 201 | * exepctedCurrentValue is updated with the new |
<> | 160:d5399cc887bb | 202 | * value of the target memory location. |
<> | 160:d5399cc887bb | 203 | * |
<> | 160:d5399cc887bb | 204 | * pseudocode: |
<> | 160:d5399cc887bb | 205 | * function cas(p : pointer to int, old : pointer to int, new : int) returns bool { |
<> | 160:d5399cc887bb | 206 | * if *p != *old { |
<> | 160:d5399cc887bb | 207 | * *old = *p |
<> | 160:d5399cc887bb | 208 | * return false |
<> | 160:d5399cc887bb | 209 | * } |
<> | 160:d5399cc887bb | 210 | * *p = new |
<> | 160:d5399cc887bb | 211 | * return true |
<> | 160:d5399cc887bb | 212 | * } |
<> | 160:d5399cc887bb | 213 | * |
<> | 160:d5399cc887bb | 214 | * @Note: In the failure case (where the destination isn't set), the value |
<> | 160:d5399cc887bb | 215 | * pointed to by expectedCurrentValue is still updated with the current value. |
<> | 160:d5399cc887bb | 216 | * This property helps writing concise code for the following incr: |
<> | 160:d5399cc887bb | 217 | * |
<> | 160:d5399cc887bb | 218 | * function incr(p : pointer to int, a : int) returns int { |
<> | 160:d5399cc887bb | 219 | * done = false |
<> | 160:d5399cc887bb | 220 | * value = *p // This fetch operation need not be atomic. |
<> | 160:d5399cc887bb | 221 | * while not done { |
<> | 160:d5399cc887bb | 222 | * done = atomic_cas(p, &value, value + a) // *value gets updated automatically until success |
<> | 160:d5399cc887bb | 223 | * } |
<> | 160:d5399cc887bb | 224 | * return value + a |
<> | 160:d5399cc887bb | 225 | * } |
<> | 160:d5399cc887bb | 226 | */ |
<> | 160:d5399cc887bb | 227 | bool core_util_atomic_cas_u32(uint32_t *ptr, uint32_t *expectedCurrentValue, uint32_t desiredValue); |
<> | 160:d5399cc887bb | 228 | |
<> | 160:d5399cc887bb | 229 | /** |
<> | 160:d5399cc887bb | 230 | * Atomic compare and set. It compares the contents of a memory location to a |
<> | 160:d5399cc887bb | 231 | * given value and, only if they are the same, modifies the contents of that |
<> | 160:d5399cc887bb | 232 | * memory location to a given new value. This is done as a single atomic |
<> | 160:d5399cc887bb | 233 | * operation. The atomicity guarantees that the new value is calculated based on |
<> | 160:d5399cc887bb | 234 | * up-to-date information; if the value had been updated by another thread in |
<> | 160:d5399cc887bb | 235 | * the meantime, the write would fail due to a mismatched expectedCurrentValue. |
<> | 160:d5399cc887bb | 236 | * |
<> | 160:d5399cc887bb | 237 | * Refer to https://en.wikipedia.org/wiki/Compare-and-set [which may redirect |
<> | 160:d5399cc887bb | 238 | * you to the article on compare-and swap]. |
<> | 160:d5399cc887bb | 239 | * |
<> | 160:d5399cc887bb | 240 | * @param ptr The target memory location. |
<> | 160:d5399cc887bb | 241 | * @param[in,out] expectedCurrentValue A pointer to some location holding the |
<> | 160:d5399cc887bb | 242 | * expected current value of the data being set atomically. |
<> | 160:d5399cc887bb | 243 | * The computed 'desiredValue' should be a function of this current value. |
<> | 160:d5399cc887bb | 244 | * @Note: This is an in-out parameter. In the |
<> | 160:d5399cc887bb | 245 | * failure case of atomic_cas (where the |
<> | 160:d5399cc887bb | 246 | * destination isn't set), the pointee of expectedCurrentValue is |
<> | 160:d5399cc887bb | 247 | * updated with the current value. |
<> | 160:d5399cc887bb | 248 | * @param[in] desiredValue The new value computed based on '*expectedCurrentValue'. |
<> | 160:d5399cc887bb | 249 | * |
<> | 160:d5399cc887bb | 250 | * @return true if the memory location was atomically |
<> | 160:d5399cc887bb | 251 | * updated with the desired value (after verifying |
<> | 160:d5399cc887bb | 252 | * that it contained the expectedCurrentValue), |
<> | 160:d5399cc887bb | 253 | * false otherwise. In the failure case, |
<> | 160:d5399cc887bb | 254 | * exepctedCurrentValue is updated with the new |
<> | 160:d5399cc887bb | 255 | * value of the target memory location. |
<> | 160:d5399cc887bb | 256 | * |
<> | 160:d5399cc887bb | 257 | * pseudocode: |
<> | 160:d5399cc887bb | 258 | * function cas(p : pointer to int, old : pointer to int, new : int) returns bool { |
<> | 160:d5399cc887bb | 259 | * if *p != *old { |
<> | 160:d5399cc887bb | 260 | * *old = *p |
<> | 160:d5399cc887bb | 261 | * return false |
<> | 160:d5399cc887bb | 262 | * } |
<> | 160:d5399cc887bb | 263 | * *p = new |
<> | 160:d5399cc887bb | 264 | * return true |
<> | 160:d5399cc887bb | 265 | * } |
<> | 160:d5399cc887bb | 266 | * |
<> | 160:d5399cc887bb | 267 | * @Note: In the failure case (where the destination isn't set), the value |
<> | 160:d5399cc887bb | 268 | * pointed to by expectedCurrentValue is still updated with the current value. |
<> | 160:d5399cc887bb | 269 | * This property helps writing concise code for the following incr: |
<> | 160:d5399cc887bb | 270 | * |
<> | 160:d5399cc887bb | 271 | * function incr(p : pointer to int, a : int) returns int { |
<> | 160:d5399cc887bb | 272 | * done = false |
<> | 160:d5399cc887bb | 273 | * value = *p // This fetch operation need not be atomic. |
<> | 160:d5399cc887bb | 274 | * while not done { |
<> | 160:d5399cc887bb | 275 | * done = atomic_cas(p, &value, value + a) // *value gets updated automatically until success |
<> | 160:d5399cc887bb | 276 | * } |
<> | 160:d5399cc887bb | 277 | * return value + a |
<> | 160:d5399cc887bb | 278 | * } |
<> | 160:d5399cc887bb | 279 | */ |
<> | 160:d5399cc887bb | 280 | bool core_util_atomic_cas_ptr(void **ptr, void **expectedCurrentValue, void *desiredValue); |
<> | 160:d5399cc887bb | 281 | |
<> | 160:d5399cc887bb | 282 | /** |
<> | 160:d5399cc887bb | 283 | * Atomic increment. |
<> | 160:d5399cc887bb | 284 | * @param valuePtr Target memory location being incremented. |
<> | 160:d5399cc887bb | 285 | * @param delta The amount being incremented. |
<> | 160:d5399cc887bb | 286 | * @return The new incremented value. |
<> | 160:d5399cc887bb | 287 | */ |
<> | 160:d5399cc887bb | 288 | uint8_t core_util_atomic_incr_u8(uint8_t *valuePtr, uint8_t delta); |
<> | 160:d5399cc887bb | 289 | |
<> | 160:d5399cc887bb | 290 | /** |
<> | 160:d5399cc887bb | 291 | * Atomic increment. |
<> | 160:d5399cc887bb | 292 | * @param valuePtr Target memory location being incremented. |
<> | 160:d5399cc887bb | 293 | * @param delta The amount being incremented. |
<> | 160:d5399cc887bb | 294 | * @return The new incremented value. |
<> | 160:d5399cc887bb | 295 | */ |
<> | 160:d5399cc887bb | 296 | uint16_t core_util_atomic_incr_u16(uint16_t *valuePtr, uint16_t delta); |
<> | 160:d5399cc887bb | 297 | |
<> | 160:d5399cc887bb | 298 | /** |
<> | 160:d5399cc887bb | 299 | * Atomic increment. |
<> | 160:d5399cc887bb | 300 | * @param valuePtr Target memory location being incremented. |
<> | 160:d5399cc887bb | 301 | * @param delta The amount being incremented. |
<> | 160:d5399cc887bb | 302 | * @return The new incremented value. |
<> | 160:d5399cc887bb | 303 | */ |
<> | 160:d5399cc887bb | 304 | uint32_t core_util_atomic_incr_u32(uint32_t *valuePtr, uint32_t delta); |
<> | 160:d5399cc887bb | 305 | |
<> | 160:d5399cc887bb | 306 | /** |
<> | 160:d5399cc887bb | 307 | * Atomic increment. |
<> | 160:d5399cc887bb | 308 | * @param valuePtr Target memory location being incremented. |
<> | 160:d5399cc887bb | 309 | * @param delta The amount being incremented in bytes. |
<> | 160:d5399cc887bb | 310 | * @return The new incremented value. |
<> | 160:d5399cc887bb | 311 | * |
<> | 160:d5399cc887bb | 312 | * @note The type of the pointer argument is not taken into account |
<> | 160:d5399cc887bb | 313 | * and the pointer is incremented by bytes. |
<> | 160:d5399cc887bb | 314 | */ |
<> | 160:d5399cc887bb | 315 | void *core_util_atomic_incr_ptr(void **valuePtr, ptrdiff_t delta); |
<> | 160:d5399cc887bb | 316 | |
<> | 160:d5399cc887bb | 317 | /** |
<> | 160:d5399cc887bb | 318 | * Atomic decrement. |
<> | 160:d5399cc887bb | 319 | * @param valuePtr Target memory location being decremented. |
<> | 160:d5399cc887bb | 320 | * @param delta The amount being decremented. |
<> | 160:d5399cc887bb | 321 | * @return The new decremented value. |
<> | 160:d5399cc887bb | 322 | */ |
<> | 160:d5399cc887bb | 323 | uint8_t core_util_atomic_decr_u8(uint8_t *valuePtr, uint8_t delta); |
<> | 160:d5399cc887bb | 324 | |
<> | 160:d5399cc887bb | 325 | /** |
<> | 160:d5399cc887bb | 326 | * Atomic decrement. |
<> | 160:d5399cc887bb | 327 | * @param valuePtr Target memory location being decremented. |
<> | 160:d5399cc887bb | 328 | * @param delta The amount being decremented. |
<> | 160:d5399cc887bb | 329 | * @return The new decremented value. |
<> | 160:d5399cc887bb | 330 | */ |
<> | 160:d5399cc887bb | 331 | uint16_t core_util_atomic_decr_u16(uint16_t *valuePtr, uint16_t delta); |
<> | 160:d5399cc887bb | 332 | |
<> | 160:d5399cc887bb | 333 | /** |
<> | 160:d5399cc887bb | 334 | * Atomic decrement. |
<> | 160:d5399cc887bb | 335 | * @param valuePtr Target memory location being decremented. |
<> | 160:d5399cc887bb | 336 | * @param delta The amount being decremented. |
<> | 160:d5399cc887bb | 337 | * @return The new decremented value. |
<> | 160:d5399cc887bb | 338 | */ |
<> | 160:d5399cc887bb | 339 | uint32_t core_util_atomic_decr_u32(uint32_t *valuePtr, uint32_t delta); |
<> | 160:d5399cc887bb | 340 | |
<> | 160:d5399cc887bb | 341 | /** |
<> | 160:d5399cc887bb | 342 | * Atomic decrement. |
<> | 160:d5399cc887bb | 343 | * @param valuePtr Target memory location being decremented. |
<> | 160:d5399cc887bb | 344 | * @param delta The amount being decremented in bytes. |
<> | 160:d5399cc887bb | 345 | * @return The new decremented value. |
<> | 160:d5399cc887bb | 346 | * |
<> | 160:d5399cc887bb | 347 | * @note The type of the pointer argument is not taken into account |
<> | 160:d5399cc887bb | 348 | * and the pointer is decremented by bytes |
<> | 160:d5399cc887bb | 349 | */ |
<> | 160:d5399cc887bb | 350 | void *core_util_atomic_decr_ptr(void **valuePtr, ptrdiff_t delta); |
<> | 160:d5399cc887bb | 351 | |
<> | 160:d5399cc887bb | 352 | #ifdef __cplusplus |
<> | 160:d5399cc887bb | 353 | } // extern "C" |
<> | 160:d5399cc887bb | 354 | #endif |
<> | 160:d5399cc887bb | 355 | |
<> | 160:d5399cc887bb | 356 | |
<> | 160:d5399cc887bb | 357 | #endif // __MBED_UTIL_CRITICAL_H__ |
<> | 160:d5399cc887bb | 358 | |
<> | 160:d5399cc887bb | 359 | /** @}*/ |