Skip to content

Commit 9461991

Browse files
committed
Minor documentation updates for critical
- extra dereference in cas example - clarification of incr/decr
1 parent 9067148 commit 9461991

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

hal/api/critical.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ void core_util_critical_section_exit(void);
108108
*
109109
* function incr(p : pointer to int, a : int) returns int {
110110
* done = false
111-
* *value = *p // This fetch operation need not be atomic.
111+
* value = *p // This fetch operation need not be atomic.
112112
* while not done {
113113
* done = atomic_cas(p, &value, value + a) // *value gets updated automatically until success
114114
* }
@@ -161,7 +161,7 @@ bool core_util_atomic_cas_u8(uint8_t *ptr, uint8_t *expectedCurrentValue, uint8_
161161
*
162162
* function incr(p : pointer to int, a : int) returns int {
163163
* done = false
164-
* *value = *p // This fetch operation need not be atomic.
164+
* value = *p // This fetch operation need not be atomic.
165165
* while not done {
166166
* done = atomic_cas(p, &value, value + a) // *value gets updated automatically until success
167167
* }
@@ -214,7 +214,7 @@ bool core_util_atomic_cas_u16(uint16_t *ptr, uint16_t *expectedCurrentValue, uin
214214
*
215215
* function incr(p : pointer to int, a : int) returns int {
216216
* done = false
217-
* *value = *p // This fetch operation need not be atomic.
217+
* value = *p // This fetch operation need not be atomic.
218218
* while not done {
219219
* done = atomic_cas(p, &value, value + a) // *value gets updated automatically until success
220220
* }
@@ -267,7 +267,7 @@ bool core_util_atomic_cas_u32(uint32_t *ptr, uint32_t *expectedCurrentValue, uin
267267
*
268268
* function incr(p : pointer to int, a : int) returns int {
269269
* done = false
270-
* *value = *p // This fetch operation need not be atomic.
270+
* value = *p // This fetch operation need not be atomic.
271271
* while not done {
272272
* done = atomic_cas(p, &value, value + a) // *value gets updated automatically until success
273273
* }
@@ -303,8 +303,11 @@ uint32_t core_util_atomic_incr_u32(uint32_t *valuePtr, uint32_t delta);
303303
/**
304304
* Atomic increment.
305305
* @param valuePtr Target memory location being incremented.
306-
* @param delta The amount being incremented.
306+
* @param delta The amount being incremented in bytes.
307307
* @return The new incremented value.
308+
*
309+
* @note The type of the pointer argument is not taken into account
310+
* and the pointer is incremented by bytes.
308311
*/
309312
void *core_util_atomic_incr_ptr(void **valuePtr, ptrdiff_t delta);
310313

@@ -335,8 +338,11 @@ uint32_t core_util_atomic_decr_u32(uint32_t *valuePtr, uint32_t delta);
335338
/**
336339
* Atomic decrement.
337340
* @param valuePtr Target memory location being decremented.
338-
* @param delta The amount being decremented.
341+
* @param delta The amount being decremented in bytes.
339342
* @return The new decremented value.
343+
*
344+
* @note The type of the pointer argument is not taken into account
345+
* and the pointer is decremented by bytes
340346
*/
341347
void *core_util_atomic_decr_ptr(void **valuePtr, ptrdiff_t delta);
342348

0 commit comments

Comments
 (0)