Changeset 18e0a6c in mainline for arch/ia32/include/atomic.h


Ignore:
Timestamp:
2005-06-09T23:43:45Z (20 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
74df77d
Parents:
d896525
Message:

Implement several assembler functions in gcc's asm notation instead of in .s or .S file.
Gain both better speed and size.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • arch/ia32/include/atomic.h

    rd896525 r18e0a6c  
    3232#include <arch/types.h>
    3333
    34 extern void atomic_inc(volatile int *val);
    35 extern void atomic_dec(volatile int *val);
     34static inline void atomic_inc(volatile int *val) {
     35#ifdef __SMP__
     36        __asm__ volatile ("lock incl (%0)\n" : : "r" (val));
     37#else
     38        __asm__ volatile ("incl (%0)\n" : : "r" (val));
     39#endif /* __SMP__ */
     40}
    3641
    37 extern int test_and_set(int *val);
     42static inline void atomic_dec(volatile int *val) {
     43#ifdef __SMP__
     44        __asm__ volatile ("lock decl (%0)\n" : : "r" (val));
     45#else
     46        __asm__ volatile ("decl (%0)\n" : : "r" (val));
     47#endif /* __SMP__ */
     48}
     49
     50static inline int test_and_set(int *val) {
     51        int v;
     52       
     53        __asm__ volatile (
     54                "movl $1, %0\n"
     55                "xchgl %0, (%1)\n"
     56                : "=r" (v)
     57                : "r" (val)
     58        );
     59       
     60        return v;
     61}
     62
     63
    3864extern void spinlock_arch(int *val);
    3965
Note: See TracChangeset for help on using the changeset viewer.