mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-25 02:49:32 +03:00
Minor atomic cleanup, this needs to be done right.
Fixed a bug in the timer code Added missing macros git-svn-id: https://outreach.scidac.gov/svn/spl/trunk@28 7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c
This commit is contained in:
parent
ed61a7d05e
commit
b0dd3380aa
68
include/sys/atomic.h
Normal file
68
include/sys/atomic.h
Normal file
@ -0,0 +1,68 @@
|
||||
#ifndef _SPL_ATOMIC_H
|
||||
#define _SPL_ATOMIC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <linux/module.h>
|
||||
/* FIXME - NONE OF THIS IS ATOMIC, IT SHOULD BE. I think we can
|
||||
* get by for now since I'm only working on real 64bit systems but
|
||||
* this will need to be addressed properly.
|
||||
*/
|
||||
static __inline__ void
|
||||
atomic_inc_64(volatile uint64_t *target)
|
||||
{
|
||||
(*target)++;
|
||||
}
|
||||
|
||||
static __inline__ void
|
||||
atomic_dec_64(volatile uint64_t *target)
|
||||
{
|
||||
(*target)--;
|
||||
}
|
||||
|
||||
static __inline__ uint64_t
|
||||
atomic_add_64(volatile uint64_t *target, uint64_t delta)
|
||||
{
|
||||
uint64_t rc = *target;
|
||||
*target += delta;
|
||||
return rc;
|
||||
}
|
||||
|
||||
static __inline__ uint64_t
|
||||
atomic_add_64_nv(volatile uint64_t *target, uint64_t delta)
|
||||
{
|
||||
*target += delta;
|
||||
return *target;
|
||||
}
|
||||
|
||||
static __inline__ uint64_t
|
||||
atomic_cas_64(volatile uint64_t *target, uint64_t cmp,
|
||||
uint64_t newval)
|
||||
{
|
||||
uint64_t rc = *target;
|
||||
|
||||
if (*target == cmp)
|
||||
*target = newval;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static __inline__ void *
|
||||
atomic_cas_ptr(volatile void *target, void *cmp, void *newval)
|
||||
{
|
||||
void *rc = (void *)target;
|
||||
|
||||
if (target == cmp)
|
||||
target = newval;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SPL_ATOMIC_H */
|
||||
|
@ -130,49 +130,6 @@ kstat_delete(kstat_t *ksp)
|
||||
return;
|
||||
}
|
||||
|
||||
/* FIXME - NONE OF THIS IS ATOMIC, IT SHOULD BE. For the moment this is
|
||||
* OK since it is only used for the noncritical kstat counters, and we
|
||||
* are only doing testing on x86_86 platform where the entire counter
|
||||
* will be updated with one instruction. */
|
||||
static __inline__ void
|
||||
atomic_inc_64(volatile uint64_t *target)
|
||||
{
|
||||
(*target)++;
|
||||
}
|
||||
|
||||
static __inline__ void
|
||||
atomic_dec_64(volatile uint64_t *target)
|
||||
{
|
||||
(*target)--;
|
||||
}
|
||||
|
||||
static __inline__ uint64_t
|
||||
atomic_add_64(volatile uint64_t *target, uint64_t delta)
|
||||
{
|
||||
uint64_t rc = *target;
|
||||
*target += delta;
|
||||
return rc;
|
||||
}
|
||||
|
||||
static __inline__ uint64_t
|
||||
atomic_add_64_nv(volatile uint64_t *target, uint64_t delta)
|
||||
{
|
||||
*target += delta;
|
||||
return *target;
|
||||
}
|
||||
|
||||
static __inline__ uint64_t
|
||||
atomic_cas_64(volatile uint64_t *target, uint64_t cmp,
|
||||
uint64_t newval)
|
||||
{
|
||||
uint64_t rc = *target;
|
||||
|
||||
if (*target == cmp)
|
||||
*target = newval;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -15,14 +15,23 @@ extern "C" {
|
||||
*/
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
|
||||
#define INT32_MAX INT_MAX
|
||||
#define UINT64_MAX (~0ULL)
|
||||
#define NBBY 8
|
||||
#define ENOTSUP ENOTSUPP
|
||||
|
||||
#define MAXNAMELEN 256
|
||||
#define MAXPATHLEN PATH_MAX
|
||||
#define MAXOFFSET_T 0x7fffffffffffffffl
|
||||
|
||||
#define MAXBSIZE 8192
|
||||
#define DEV_BSIZE 512
|
||||
#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
|
||||
|
||||
#define __va_list va_list
|
||||
#define max_ncpus 64
|
||||
#define _NOTE(x)
|
||||
|
||||
/* 0..MAX_PRIO-1: Process priority
|
||||
* 0..MAX_RT_PRIO-1: RT priority tasks
|
||||
@ -65,6 +74,7 @@ extern "C" {
|
||||
*/
|
||||
#define bzero(ptr,size) memset(ptr,0,size)
|
||||
#define bcopy(src,dest,size) memcpy(dest,src,size)
|
||||
#define bcmp(src,dest,size) memcmp((src), (dest), (size_t)(size))
|
||||
#define ASSERT(x) BUG_ON(!(x))
|
||||
#define VERIFY(x) ASSERT(x)
|
||||
|
||||
|
@ -12,7 +12,7 @@ extern "C" {
|
||||
#define lbolt ((clock_t)jiffies)
|
||||
#define lbolt64 ((int64_t)get_jiffies_64())
|
||||
|
||||
#define delay(ticks) schedule_timeout((long timeout)(ticks))
|
||||
#define delay(ticks) schedule_timeout((long)(ticks))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user