Subversion Repositories HelenOS

Rev

Rev 112 | Rev 477 | Go to most recent revision | Show entire file | Ignore 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
/*
-
 
33
 * TODO: these are just placeholders for real implementations of atomic_inc and atomic_dec.
-
 
34
 * WARNING: the following functions cause the code to be preemption-unsafe !!!
32
#include <arch/types.h>
35
 */
-
 
36
 
33
 
-
 
34
typedef volatile __u64 atomic_t;
-
 
35
 
37
static inline atomic_inc(volatile int *val) {
36
static inline atomic_t atomic_add(atomic_t *val, int imm)
38
    *val++;
-
 
39
}
37
{
-
 
38
    atomic_t v;
40
 
39
 
-
 
40
/* 
41
static inline atomic_dec(volatile int *val) {
41
 *  __asm__ volatile ("fetchadd8.rel %0 = %1, %2\n" : "=r" (v), "=m" (val) : "i" (imm));
-
 
42
 */
42
    *val--;
43
    *val += imm;
-
 
44
   
-
 
45
    return v;
43
}
46
}
44
 
47
 
-
 
48
static inline atomic_t atomic_inc(atomic_t *val) { return atomic_add(val, 1); }
-
 
49
static inline atomic_t atomic_dec(atomic_t *val) { return atomic_add(val, -1); }
-
 
50
 
45
#endif
51
#endif