Changeset 371bd7d in mainline for kernel/arch/arm32/include/atomic.h


Ignore:
Timestamp:
2010-03-27T09:22:17Z (16 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
36a75a2
Parents:
cd82bb1 (diff), eaf22d4 (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 mainline changes.

File:
1 edited

Legend:

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

    rcd82bb1 r371bd7d  
    3737#define KERN_arm32_ATOMIC_H_
    3838
     39#include <arch/asm.h>
     40
    3941/** Atomic addition.
    4042 *
     
    4547 *
    4648 */
    47 static inline long atomic_add(atomic_t *val, int i)
     49static inline atomic_count_t atomic_add(atomic_t *val, atomic_count_t i)
    4850{
    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         );
     51        /*
     52         * This implementation is for UP pre-ARMv6 systems where we do not have
     53         * the LDREX and STREX instructions.
     54         */
     55        ipl_t ipl = interrupts_disable();
     56        val->count += i;
     57        atomic_count_t ret = val->count;
     58        interrupts_restore(ipl);
    6459       
    6560        return ret;
     
    6964 *
    7065 * @param val Variable to be incremented.
     66 *
    7167 */
    7268static inline void atomic_inc(atomic_t *val)
     
    7874 *
    7975 * @param val Variable to be decremented.
     76 *
    8077 */
    8178static inline void atomic_dec(atomic_t *val) {
     
    8784 * @param val Variable to be incremented.
    8885 * @return    Value after incrementation.
     86 *
    8987 */
    90 static inline long atomic_preinc(atomic_t *val)
     88static inline atomic_count_t atomic_preinc(atomic_t *val)
    9189{
    9290        return atomic_add(val, 1);
     
    9795 * @param val Variable to be decremented.
    9896 * @return    Value after decrementation.
     97 *
    9998 */
    100 static inline long atomic_predec(atomic_t *val)
     99static inline atomic_count_t atomic_predec(atomic_t *val)
    101100{
    102101        return atomic_add(val, -1);
     
    107106 * @param val Variable to be incremented.
    108107 * @return    Value before incrementation.
     108 *
    109109 */
    110 static inline long atomic_postinc(atomic_t *val)
     110static inline atomic_count_t atomic_postinc(atomic_t *val)
    111111{
    112112        return atomic_add(val, 1) - 1;
     
    117117 * @param val Variable to be decremented.
    118118 * @return    Value before decrementation.
     119 *
    119120 */
    120 static inline long atomic_postdec(atomic_t *val)
     121static inline atomic_count_t atomic_postdec(atomic_t *val)
    121122{
    122123        return atomic_add(val, -1) + 1;
Note: See TracChangeset for help on using the changeset viewer.