Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/libc/arch/ia64/include/atomic.h

    re86a849a r00acd66  
    2727 */
    2828
    29 /** @addtogroup libcia64
     29/** @addtogroup libcia64       
    3030 * @{
    3131 */
     
    3636#define LIBC_ia64_ATOMIC_H_
    3737
    38 static inline void atomic_inc(atomic_t *val)
     38/** Atomic addition.
     39 *
     40 * @param val Atomic value.
     41 * @param imm Value to add.
     42 *
     43 * @return Value before addition.
     44 */
     45static inline long atomic_add(atomic_t *val, int imm)
    3946{
    4047        long v;
    41        
    42         asm volatile (
    43                 "fetchadd8.rel %[v] = %[count], 1\n"
    44                 : [v] "=r" (v),
    45                   [count] "+m" (val->count)
    46         );
    47 }
    4848
    49 static inline void atomic_dec(atomic_t *val)
    50 {
    51         long v;
    52        
    53         asm volatile (
    54                 "fetchadd8.rel %[v] = %[count], -1\n"
    55                 : [v] "=r" (v),
    56                   [count] "+m" (val->count)
    57         );
    58 }
    59 
    60 static inline long atomic_preinc(atomic_t *val)
    61 {
    62         long v;
    63        
    64         asm volatile (
    65                 "fetchadd8.rel %[v] = %[count], 1\n"
    66                 : [v] "=r" (v),
    67                   [count] "+m" (val->count)
    68         );
    69        
    70         return (v + 1);
    71 }
    72 
    73 static inline long atomic_predec(atomic_t *val)
    74 {
    75         long v;
    76        
    77         asm volatile (
    78                 "fetchadd8.rel %[v] = %[count], -1\n"
    79                 : [v] "=r" (v),
    80                   [count] "+m" (val->count)
    81         );
    82        
    83         return (v - 1);
    84 }
    85 
    86 static inline long atomic_postinc(atomic_t *val)
    87 {
    88         long v;
    89        
    90         asm volatile (
    91                 "fetchadd8.rel %[v] = %[count], 1\n"
    92                 : [v] "=r" (v),
    93                   [count] "+m" (val->count)
    94         );
    95        
     49        asm volatile ("fetchadd8.rel %0 = %1, %2\n" : "=r" (v), "+m" (val->count) : "i" (imm));
     50 
    9651        return v;
    9752}
    9853
    99 static inline long atomic_postdec(atomic_t *val)
    100 {
    101         long v;
    102        
    103         asm volatile (
    104                 "fetchadd8.rel %[v] = %[count], -1\n"
    105                 : [v] "=r" (v),
    106                   [count] "+m" (val->count)
    107         );
    108        
    109         return v;
    110 }
     54static inline void atomic_inc(atomic_t *val) { atomic_add(val, 1); }
     55static inline void atomic_dec(atomic_t *val) { atomic_add(val, -1); }
     56
     57static inline long atomic_preinc(atomic_t *val) { return atomic_add(val, 1) + 1; }
     58static inline long atomic_predec(atomic_t *val) { return atomic_add(val, -1) - 1; }
     59
     60static inline long atomic_postinc(atomic_t *val) { return atomic_add(val, 1); }
     61static inline long atomic_postdec(atomic_t *val) { return atomic_add(val, -1); }
    11162
    11263#endif
Note: See TracChangeset for help on using the changeset viewer.