Subversion Repositories HelenOS

Rev

Rev 112 | Rev 477 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 112 Rev 475
Line 27... Line 27...
27
 */
27
 */
28
 
28
 
29
#ifndef __ia64_ATOMIC_H__
29
#ifndef __ia64_ATOMIC_H__
30
#define __ia64_ATOMIC_H__
30
#define __ia64_ATOMIC_H__
31
 
31
 
-
 
32
#include <arch/types.h>
-
 
33
 
-
 
34
typedef volatile __u64 atomic_t;
-
 
35
 
-
 
36
static inline atomic_t atomic_add(atomic_t *val, int imm)
-
 
37
{
-
 
38
    atomic_t v;
-
 
39
 
32
/*
40
/* 
33
 * TODO: these are just placeholders for real implementations of atomic_inc and atomic_dec.
41
 *  __asm__ volatile ("fetchadd8.rel %0 = %1, %2\n" : "=r" (v), "=m" (val) : "i" (imm));
34
 * WARNING: the following functions cause the code to be preemption-unsafe !!!
-
 
35
 */
42
 */
-
 
43
    *val += imm;
36
 
44
   
37
static inline atomic_inc(volatile int *val) {
-
 
38
    *val++;
45
    return v;
39
}
46
}
40
 
47
 
-
 
48
static inline atomic_t atomic_inc(atomic_t *val) { return atomic_add(val, 1); }
41
static inline atomic_dec(volatile int *val) {
49
static inline atomic_t atomic_dec(atomic_t *val) { return atomic_add(val, -1); }
42
    *val--;
-
 
43
}
-
 
44
 
50
 
45
#endif
51
#endif