diff options
author | behlendo <behlendo@7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c> | 2008-03-07 00:28:32 +0000 |
---|---|---|
committer | behlendo <behlendo@7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c> | 2008-03-07 00:28:32 +0000 |
commit | b0dd3380aae2a976d4d3afa4d3b2aff820c36f23 (patch) | |
tree | a42374a72544ca96c8ca944cd6e55f3f1a2d44b5 /include/sys | |
parent | ed61a7d05eb95ab453a95baf52d6af7b0c60a132 (diff) |
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
Diffstat (limited to 'include/sys')
-rw-r--r-- | include/sys/atomic.h | 68 | ||||
-rw-r--r-- | include/sys/kstat.h | 43 | ||||
-rw-r--r-- | include/sys/sysmacros.h | 10 | ||||
-rw-r--r-- | include/sys/timer.h | 2 |
4 files changed, 79 insertions, 44 deletions
diff --git a/include/sys/atomic.h b/include/sys/atomic.h new file mode 100644 index 000000000..ae2130331 --- /dev/null +++ b/include/sys/atomic.h @@ -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 */ + diff --git a/include/sys/kstat.h b/include/sys/kstat.h index 0b6ce0583..0b79a41c0 100644 --- a/include/sys/kstat.h +++ b/include/sys/kstat.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 diff --git a/include/sys/sysmacros.h b/include/sys/sysmacros.h index 2c3ec0e4e..a96c47fa4 100644 --- a/include/sys/sysmacros.h +++ b/include/sys/sysmacros.h @@ -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) diff --git a/include/sys/timer.h b/include/sys/timer.h index 237195d76..7e8c6fd41 100644 --- a/include/sys/timer.h +++ b/include/sys/timer.h @@ -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 } |