Changeset 23684b7 in mainline for arch/amd64/include/atomic.h


Ignore:
Timestamp:
2006-03-22T17:21:15Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d71007e
Parents:
45fb65c
Message:

Define atomic_t only once in atomic.h
Change the encapsulated counter type to long so that it supports negative values as well.

File:
1 edited

Legend:

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

    r45fb65c r23684b7  
    3333#include <arch/barrier.h>
    3434#include <preemption.h>
    35 
    36 typedef struct { volatile __u64 count; } atomic_t;
    37 
    38 static inline void atomic_set(atomic_t *val, __u64 i)
    39 {
    40         val->count = i;
    41 }
    42 
    43 static inline __u64 atomic_get(atomic_t *val)
    44 {
    45         return val->count;
    46 }
     35#include <typedefs.h>
    4736
    4837static inline void atomic_inc(atomic_t *val) {
     
    6251}
    6352
    64 static inline count_t atomic_postinc(atomic_t *val)
     53static inline long atomic_postinc(atomic_t *val)
    6554{
    66         count_t r;
     55        long r;
    6756
    6857        __asm__ volatile (
     
    7564}
    7665
    77 static inline count_t atomic_postdec(atomic_t *val)
     66static inline long atomic_postdec(atomic_t *val)
    7867{
    79         count_t r;
     68        long r;
    8069       
    8170        __asm__ volatile (
     
    10493
    10594
    106 /** AMD64 specific fast spinlock */
     95/** amd64 specific fast spinlock */
    10796static inline void atomic_lock_arch(atomic_t *val)
    10897{
     
    117106                "mov %0, %1;"
    118107                "testq %1, %1;"
    119                 "jnz 0b;"       /* Leightweight looping on locked spinlock */
     108                "jnz 0b;"       /* Lightweight looping on locked spinlock */
    120109               
    121110                "incq %1;"      /* now use the atomic operation */
Note: See TracChangeset for help on using the changeset viewer.