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