Changeset 4621d23 in mainline for kernel/arch/arm32/src/atomic.c


Ignore:
Timestamp:
2018-09-06T19:54:11Z (6 years ago)
Author:
Jiří Zárevúcky <jiri.zarevucky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
508b0df1
Parents:
ffa73c6
git-author:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-08-13 03:00:17)
git-committer:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-09-06 19:54:11)
Message:

Use compiler builtins for kernel atomics

File:
1 edited

Legend:

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

    rffa73c6 r4621d23  
    3636#include <synch/spinlock.h>
    3737#include <arch/barrier.h>
     38#include <arch/asm.h>
    3839
     40unsigned __atomic_fetch_add_4(volatile unsigned *mem, unsigned val, int model)
     41{
     42        /*
     43         * This implementation is for UP pre-ARMv6 systems where we do not have
     44         * the LDREX and STREX instructions.
     45         */
     46        ipl_t ipl = interrupts_disable();
     47        unsigned ret = *mem;
     48        *mem += val;
     49        interrupts_restore(ipl);
     50        return ret;
     51}
     52
     53unsigned __atomic_fetch_sub_4(volatile unsigned *mem, unsigned val, int model)
     54{
     55        ipl_t ipl = interrupts_disable();
     56        unsigned ret = *mem;
     57        *mem -= val;
     58        interrupts_restore(ipl);
     59        return ret;
     60}
    3961
    4062IRQ_SPINLOCK_STATIC_INITIALIZE_NAME(cas_lock, "arm-cas-lock");
Note: See TracChangeset for help on using the changeset viewer.