Changeset 320762a in mainline


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

Files:
2 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
  • uspace/lib/c/arch/arm32/src/atomic.c

    re1d93e3 r320762a  
    3838volatile unsigned *ras_page;
    3939
    40 bool __atomic_compare_exchange_4(volatile unsigned *mem, unsigned *expected, unsigned desired, bool weak, int success, int failure)
     40bool __atomic_compare_exchange_4(volatile void *mem, void *expected, unsigned desired, bool weak, int success, int failure)
    4141{
    4242        (void) success;
     
    4444        (void) weak;
    4545
    46         unsigned ov = *expected;
     46        unsigned ov = *((unsigned *)expected);
    4747        unsigned ret;
    4848
     
    6666              [rp0] "=m" (ras_page[0]),
    6767              [rp1] "=m" (ras_page[1]),
    68               [addr] "+m" (*mem)
     68              [addr] "+m" (*((unsigned *)mem))
    6969            : [ov] "r" (ov),
    7070              [nv] "r" (desired)
     
    7878                return true;
    7979
    80         *expected = ret;
     80        *((unsigned *)expected) = ret;
    8181        return false;
    8282}
    8383
    84 unsigned short __atomic_fetch_add_2(volatile unsigned short *mem, unsigned short val, int model)
     84unsigned short __atomic_fetch_add_2(volatile void *mem, unsigned short val, int model)
    8585{
    8686        (void) model;
     
    106106              [rp0] "=m" (ras_page[0]),
    107107              [rp1] "=m" (ras_page[1]),
    108               [addr] "+m" (*mem)
     108              [addr] "+m" (*((volatile unsigned short *)mem))
    109109            : [imm] "r" (val)
    110110        );
     
    116116}
    117117
    118 unsigned __atomic_fetch_add_4(volatile unsigned *mem, unsigned val, int model)
     118unsigned __atomic_fetch_add_4(volatile void *mem, unsigned val, int model)
    119119{
    120120        (void) model;
     
    140140              [rp0] "=m" (ras_page[0]),
    141141              [rp1] "=m" (ras_page[1]),
    142               [addr] "+m" (*mem)
     142              [addr] "+m" (*((volatile unsigned *)mem))
    143143            : [imm] "r" (val)
    144144        );
     
    150150}
    151151
    152 unsigned __atomic_fetch_sub_4(volatile unsigned *mem, unsigned val, int model)
     152unsigned __atomic_fetch_sub_4(volatile void *mem, unsigned val, int model)
    153153{
    154154        return __atomic_fetch_add_4(mem, -val, model);
Note: See TracChangeset for help on using the changeset viewer.