]> git.proxmox.com Git - mirror_spl.git/blame - include/sys/atomic.h
Fix systemic naming mistake
[mirror_spl.git] / include / sys / atomic.h
CommitLineData
b0dd3380 1#ifndef _SPL_ATOMIC_H
2#define _SPL_ATOMIC_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <linux/module.h>
9/* FIXME - NONE OF THIS IS ATOMIC, IT SHOULD BE. I think we can
10 * get by for now since I'm only working on real 64bit systems but
11 * this will need to be addressed properly.
12 */
13static __inline__ void
14atomic_inc_64(volatile uint64_t *target)
15{
16 (*target)++;
17}
18
19static __inline__ void
20atomic_dec_64(volatile uint64_t *target)
21{
22 (*target)--;
23}
24
25static __inline__ uint64_t
26atomic_add_64(volatile uint64_t *target, uint64_t delta)
27{
28 uint64_t rc = *target;
29 *target += delta;
30 return rc;
31}
32
33static __inline__ uint64_t
34atomic_add_64_nv(volatile uint64_t *target, uint64_t delta)
35{
36 *target += delta;
37 return *target;
38}
39
40static __inline__ uint64_t
41atomic_cas_64(volatile uint64_t *target, uint64_t cmp,
42 uint64_t newval)
43{
44 uint64_t rc = *target;
45
46 if (*target == cmp)
47 *target = newval;
48
49 return rc;
50}
51
52static __inline__ void *
53atomic_cas_ptr(volatile void *target, void *cmp, void *newval)
54{
55 void *rc = (void *)target;
56
57 if (target == cmp)
58 target = newval;
59
60 return rc;
61}
62
63#ifdef __cplusplus
64}
65#endif
66
67#endif /* _SPL_ATOMIC_H */
68