Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/arm32/include/atomic.h

    r7a0359b re762b43  
    3737#define KERN_arm32_ATOMIC_H_
    3838
    39 #include <arch/asm.h>
    40 #include <trace.h>
    41 
    4239/** Atomic addition.
    4340 *
     
    4845 *
    4946 */
    50 NO_TRACE static inline atomic_count_t atomic_add(atomic_t *val,
    51     atomic_count_t i)
     47static inline long atomic_add(atomic_t *val, int i)
    5248{
    53         /*
    54          * This implementation is for UP pre-ARMv6 systems where we do not have
    55          * the LDREX and STREX instructions.
    56          */
    57         ipl_t ipl = interrupts_disable();
    58         val->count += i;
    59         atomic_count_t ret = val->count;
    60         interrupts_restore(ipl);
     49        int ret;
     50        volatile long *mem = &(val->count);
     51       
     52        asm volatile (
     53                "1:\n"
     54                        "ldr r2, [%[mem]]\n"
     55                        "add r3, r2, %[i]\n"
     56                        "str r3, %[ret]\n"
     57                        "swp r3, r3, [%[mem]]\n"
     58                        "cmp r3, r2\n"
     59                        "bne 1b\n"
     60                : [ret] "=m" (ret)
     61                : [mem] "r" (mem), [i] "r" (i)
     62                : "r3", "r2"
     63        );
    6164       
    6265        return ret;
     
    6669 *
    6770 * @param val Variable to be incremented.
    68  *
    6971 */
    70 NO_TRACE static inline void atomic_inc(atomic_t *val)
     72static inline void atomic_inc(atomic_t *val)
    7173{
    7274        atomic_add(val, 1);
     
    7678 *
    7779 * @param val Variable to be decremented.
    78  *
    7980 */
    80 NO_TRACE static inline void atomic_dec(atomic_t *val) {
     81static inline void atomic_dec(atomic_t *val) {
    8182        atomic_add(val, -1);
    8283}
     
    8687 * @param val Variable to be incremented.
    8788 * @return    Value after incrementation.
    88  *
    8989 */
    90 NO_TRACE static inline atomic_count_t atomic_preinc(atomic_t *val)
     90static inline long atomic_preinc(atomic_t *val)
    9191{
    9292        return atomic_add(val, 1);
     
    9797 * @param val Variable to be decremented.
    9898 * @return    Value after decrementation.
    99  *
    10099 */
    101 NO_TRACE static inline atomic_count_t atomic_predec(atomic_t *val)
     100static inline long atomic_predec(atomic_t *val)
    102101{
    103102        return atomic_add(val, -1);
     
    108107 * @param val Variable to be incremented.
    109108 * @return    Value before incrementation.
    110  *
    111109 */
    112 NO_TRACE static inline atomic_count_t atomic_postinc(atomic_t *val)
     110static inline long atomic_postinc(atomic_t *val)
    113111{
    114112        return atomic_add(val, 1) - 1;
     
    119117 * @param val Variable to be decremented.
    120118 * @return    Value before decrementation.
    121  *
    122119 */
    123 NO_TRACE static inline atomic_count_t atomic_postdec(atomic_t *val)
     120static inline long atomic_postdec(atomic_t *val)
    124121{
    125122        return atomic_add(val, -1) + 1;
Note: See TracChangeset for help on using the changeset viewer.