source: proiecte/swift/trunk/include/swift_atomic.h @ 176

Last change on this file since 176 was 176, checked in by (none), 14 years ago
  • imported repo from "guagal"
File size: 466 bytes
Line 
1/*
2 * swift_atomic.h
3 *
4 * (c) 2009 Ionut Rosoiu <ionut.rosoiu@gmail.com>
5 *
6 */
7
8#ifndef SWIFT_ATOMIC_H_
9#define SWIFT_ATOMIC_H_
10
11#define SWIFT_ATOMIC_READ(x)    \
12        (x)
13
14#define SWIFT_ATOMIC_WRITE(x, val)      \
15        (x) = (val)
16
17#define SWIFT_ATOMIC_INCR(x)    \
18        __sync_add_and_fetch(&(x), 1)
19
20#define SWIFT_ATOMIC_DECR(x)    \
21        __sync_sub_and_fetch(&(x), 1)
22
23#define SWIFT_CAS(x, comp, val) \
24        __sync_bool_compare_and_swap((int*)&(x), (comp), (val))
25
26#endif /* SWIFT_ATOMIC_H_ */
Note: See TracBrowser for help on using the repository browser.