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