Changeset 320762a in mainline for kernel/arch/arm32/src/atomic.c


Ignore:
Timestamp:
2023-08-02T14:54:45Z (16 months ago)
Author:
Vojtech Horky <vojtech.horky@…>
Branches:
ticket/834-toolchain-update
Children:
29941ab
Parents:
e1d93e3
Message:

arm32 atomic builtins: align with compiler declarations

File:
1 edited

Legend:

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

    re1d93e3 r320762a  
    3838#include <arch/asm.h>
    3939
    40 unsigned __atomic_fetch_add_4(volatile unsigned *mem, unsigned val, int model)
     40unsigned __atomic_fetch_add_4(volatile void *mem, unsigned val, int model)
    4141{
    4242        /*
     
    4545         */
    4646        ipl_t ipl = interrupts_disable();
    47         unsigned ret = *mem;
    48         *mem += val;
     47        unsigned ret = *((volatile unsigned *)mem);
     48        *((volatile unsigned *)mem) += val;
    4949        interrupts_restore(ipl);
    5050        return ret;
    5151}
    5252
    53 unsigned __atomic_fetch_sub_4(volatile unsigned *mem, unsigned val, int model)
     53unsigned __atomic_fetch_sub_4(volatile void *mem, unsigned val, int model)
    5454{
    5555        ipl_t ipl = interrupts_disable();
    56         unsigned ret = *mem;
    57         *mem -= val;
     56        unsigned ret = *((volatile unsigned *)mem);
     57        *((volatile unsigned *)mem) -= val;
    5858        interrupts_restore(ipl);
    5959        return ret;
     
    6767 * returns the previous value of \a *ptr.
    6868 */
    69 void *__sync_val_compare_and_swap_4(void **ptr, void *expected, void *new_val)
     69unsigned __sync_val_compare_and_swap_4(volatile void *ptr, unsigned expected, unsigned new_val)
    7070{
    7171        /*
     
    7878        irq_spinlock_lock(&cas_lock, true);
    7979
    80         void *cur_val = *ptr;
     80        unsigned cur_val = *((volatile unsigned *)ptr);
    8181
    8282        if (cur_val == expected) {
    83                 *ptr = new_val;
     83                *((volatile unsigned *)ptr) = new_val;
    8484        }
    8585
     
    9696/* Naive implementations of the newer intrinsics. */
    9797
    98 _Bool __atomic_compare_exchange_4(void **mem, void **expected, void *desired, _Bool weak, int success, int failure)
     98_Bool __atomic_compare_exchange_4(volatile void *mem, void *expected, unsigned desired, _Bool weak, int success, int failure)
    9999{
    100100        (void) weak;
     
    102102        (void) failure;
    103103
    104         void *old = *expected;
    105         void *new = __sync_val_compare_and_swap_4(mem, old, desired);
     104        unsigned old = *((unsigned *)expected);
     105        unsigned new = __sync_val_compare_and_swap_4(mem, old, desired);
    106106        if (old == new) {
    107107                return 1;
    108108        } else {
    109                 *expected = new;
     109                *((unsigned *)expected) = new;
    110110                return 0;
    111111        }
    112112}
    113113
    114 void *__atomic_exchange_4(void **mem, void *val, int model)
     114unsigned __atomic_exchange_4(volatile void *mem, unsigned val, int model)
    115115{
    116116        (void) model;
    117117
    118118        irq_spinlock_lock(&cas_lock, true);
    119         void *old = *mem;
    120         *mem = val;
     119        unsigned old = *((unsigned *)mem);
     120        *((unsigned *)mem) = val;
    121121        irq_spinlock_unlock(&cas_lock, true);
    122122
Note: See TracChangeset for help on using the changeset viewer.