Subversion Repositories HelenOS-historic

Rev

Rev 627 | Rev 633 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 627 Rev 631
Line 29... Line 29...
29
#ifndef __ia32_ATOMIC_H__
29
#ifndef __ia32_ATOMIC_H__
30
#define __ia32_ATOMIC_H__
30
#define __ia32_ATOMIC_H__
31
 
31
 
32
#include <arch/types.h>
32
#include <arch/types.h>
33
 
33
 
34
typedef struct { volatile __u32 count; } atomic_t;
34
typedef struct { volatile __u64 count; } atomic_t;
35
 
35
 
36
static inline void atomic_set(atomic_t *val, __u32 i)
36
static inline void atomic_set(atomic_t *val, __u64 i)
37
{
37
{
38
    val->count = i;
38
    val->count = i;
39
}
39
}
40
 
40
 
41
static inline __u32 atomic_get(atomic_t *val)
41
static inline __u64 atomic_get(atomic_t *val)
42
{
42
{
43
    return val->count;
43
    return val->count;
44
}
44
}
45
 
45
 
46
static inline void atomic_inc(atomic_t *val) {
46
static inline void atomic_inc(atomic_t *val) {
Line 77... Line 77...
77
    count_t r;
77
    count_t r;
78
   
78
   
79
    __asm__ volatile (
79
    __asm__ volatile (
80
        "movl $-1, %0\n"
80
        "movl $-1, %0\n"
81
        "lock xaddl %0, %1\n"
81
        "lock xaddl %0, %1\n"
82
        : "=r" (r), "=m" (*val)
82
        : "=r" (r), "=m" (val->count)
83
    );
83
    );
84
   
84
   
85
    return r;
85
    return r;
86
}
86
}
87
 
87