Changeset 1c6c3e1d in mainline for kernel/arch/arm32/src/atomic.c


Ignore:
Timestamp:
2023-10-22T17:55:33Z (15 months ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
ticket/834-toolchain-update
Children:
350ec74
Parents:
315d487 (diff), 133461c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into ticket

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/arm32/src/atomic.c

    r315d487 r1c6c3e1d  
    3838#include <arch/asm.h>
    3939
    40 unsigned __atomic_fetch_add_4(volatile void *mem, unsigned val, int model)
     40unsigned __atomic_fetch_add_4(volatile void *mem0, unsigned val, int model)
    4141{
     42        volatile unsigned *mem = mem0;
     43
    4244        /*
    4345         * This implementation is for UP pre-ARMv6 systems where we do not have
     
    4547         */
    4648        ipl_t ipl = interrupts_disable();
    47         unsigned ret = *((volatile unsigned *)mem);
    48         *((volatile unsigned *)mem) += val;
     49        unsigned ret = *mem;
     50        *mem += val;
    4951        interrupts_restore(ipl);
    5052        return ret;
    5153}
    5254
    53 unsigned __atomic_fetch_sub_4(volatile void *mem, unsigned val, int model)
     55unsigned __atomic_fetch_sub_4(volatile void *mem0, unsigned val, int model)
    5456{
     57        volatile unsigned *mem = mem0;
     58
    5559        ipl_t ipl = interrupts_disable();
    56         unsigned ret = *((volatile unsigned *)mem);
    57         *((volatile unsigned *)mem) -= val;
     60        unsigned ret = *mem;
     61        *mem -= val;
    5862        interrupts_restore(ipl);
    5963        return ret;
     
    6771 * returns the previous value of \a *ptr.
    6872 */
    69 unsigned __sync_val_compare_and_swap_4(volatile void *ptr, unsigned expected, unsigned new_val)
     73unsigned __sync_val_compare_and_swap_4(volatile void *ptr0, unsigned expected,
     74    unsigned new_val)
    7075{
     76        volatile unsigned *ptr = ptr0;
     77
    7178        /*
    7279         * Using an interrupt disabling spinlock might still lead to deadlock
     
    7885        irq_spinlock_lock(&cas_lock, true);
    7986
    80         unsigned cur_val = *((volatile unsigned *)ptr);
     87        unsigned cur_val = *ptr;
    8188
    8289        if (cur_val == expected) {
    83                 *((volatile unsigned *)ptr) = new_val;
     90                *ptr = new_val;
    8491        }
    8592
     
    96103/* Naive implementations of the newer intrinsics. */
    97104
    98 _Bool __atomic_compare_exchange_4(volatile void *mem, void *expected, unsigned desired, _Bool weak, int success, int failure)
     105_Bool __atomic_compare_exchange_4(volatile void *mem, void *expected0,
     106    unsigned desired, _Bool weak, int success, int failure)
    99107{
     108        unsigned *expected = expected0;
     109
    100110        (void) weak;
    101111        (void) success;
    102112        (void) failure;
    103113
    104         unsigned old = *((unsigned *)expected);
     114        unsigned old = *expected;
    105115        unsigned new = __sync_val_compare_and_swap_4(mem, old, desired);
    106116        if (old == new) {
    107117                return 1;
    108118        } else {
    109                 *((unsigned *)expected) = new;
     119                *expected = new;
    110120                return 0;
    111121        }
    112122}
    113123
    114 unsigned __atomic_exchange_4(volatile void *mem, unsigned val, int model)
     124unsigned __atomic_exchange_4(volatile void *mem0, unsigned val, int model)
    115125{
     126        volatile unsigned *mem = mem0;
     127
    116128        (void) model;
    117129
    118130        irq_spinlock_lock(&cas_lock, true);
    119         unsigned old = *((unsigned *)mem);
    120         *((unsigned *)mem) = val;
     131        unsigned old = *mem;
     132        *mem = val;
    121133        irq_spinlock_unlock(&cas_lock, true);
    122134
Note: See TracChangeset for help on using the changeset viewer.