mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-11-18 02:20:59 +03:00
0cbaeb117a
We need dependent packages to be able to include spl_config.h so they can leverage the configure checks the SPL has done. This is important because several of the spl headers need the results of these checks to work properly. Unfortunately, the autoheader build product is always private to a particular build and defined certain common things. (PACKAGE, VERSION, etc). This prevents other packages which also use autoheader from being include because the definitions conflict. To avoid this problem the SPL build system leverage AH_BOTTOM to include a spl_unconfig.h at the botton of the autoheader build product. This custom include undefs all known shared symbols to prevent the confict. This does however mean that those definition are also not availble to the SPL package either. The SPL package therefore uses the equivilant SPL_META_* definitions.
60 lines
1.1 KiB
C
60 lines
1.1 KiB
C
#ifndef _SPL_ATOMIC_COMPAT_H
|
|
#define _SPL_ATOMIC_COMPAT_H
|
|
|
|
#include <asm/atomic.h>
|
|
#include <spl_config.h>
|
|
|
|
#ifndef HAVE_ATOMIC64_T
|
|
#include <linux/spinlock.h>
|
|
|
|
typedef struct {
|
|
spinlock_t lock;
|
|
__s64 val;
|
|
} atomic64_t;
|
|
|
|
#define ATOMIC64_INIT(i) { .lock = SPIN_LOCK_UNLOCKED, .val = (i) }
|
|
|
|
static inline void atomic64_add(__s64 i, atomic64_t *v)
|
|
{
|
|
unsigned long flags;
|
|
|
|
spin_lock_irqsave(&v->lock, flags);
|
|
v->val += i;
|
|
spin_unlock_irqrestore(&v->lock, flags);
|
|
}
|
|
|
|
static inline void atomic64_sub(__s64 i, atomic64_t *v)
|
|
{
|
|
unsigned long flags;
|
|
|
|
spin_lock_irqsave(&v->lock, flags);
|
|
v->val -= i;
|
|
spin_unlock_irqrestore(&v->lock, flags);
|
|
}
|
|
|
|
static inline __s64 atomic64_read(atomic64_t *v)
|
|
{
|
|
unsigned long flags;
|
|
__s64 r;
|
|
|
|
spin_lock_irqsave(&v->lock, flags);
|
|
r = v->val;
|
|
spin_unlock_irqrestore(&v->lock, flags);
|
|
|
|
return r;
|
|
}
|
|
|
|
static inline void atomic64_set(atomic64_t *v, __s64 i)
|
|
{
|
|
unsigned long flags;
|
|
|
|
spin_lock_irqsave(&v->lock, flags);
|
|
v->val = i;
|
|
spin_unlock_irqrestore(&v->lock, flags);
|
|
}
|
|
|
|
#endif /* HAVE_ATOMIC64_T */
|
|
|
|
#endif /* _SPL_ATOMIC_COMPAT_H */
|
|
|