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