Subversion Repositories HelenOS-historic

Rev

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

Rev 631 Rev 633
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 __u64 count; } atomic_t;
34
typedef struct { volatile __u32 count; } atomic_t;
35
 
35
 
36
static inline void atomic_set(atomic_t *val, __u64 i)
36
static inline void atomic_set(atomic_t *val, __u32 i)
37
{
37
{
38
    val->count = i;
38
    val->count = i;
39
}
39
}
40
 
40
 
41
static inline __u64 atomic_get(atomic_t *val)
41
static inline __u32 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 86... Line 86...
86
}
86
}
87
 
87
 
88
#define atomic_inc_post(val) (atomic_inc_pre(val)+1)
88
#define atomic_inc_post(val) (atomic_inc_pre(val)+1)
89
#define atomic_dec_post(val) (atomic_dec_pre(val)-1)
89
#define atomic_dec_post(val) (atomic_dec_pre(val)-1)
90
 
90
 
91
static inline int test_and_set(atomic_t *val) {
91
static inline __u32 test_and_set(atomic_t *val) {
92
    int v;
92
    __u32 v;
93
   
93
   
94
    __asm__ volatile (
94
    __asm__ volatile (
95
        "movl $1, %0\n"
95
        "movl $1, %0\n"
96
        "xchgl %0, %1\n"
96
        "xchgl %0, %1\n"
97
        : "=r" (v),"=m" (val->count)
97
        : "=r" (v),"=m" (val->count)