]> git.proxmox.com Git - mirror_spl.git/commitdiff
Minor atomic cleanup, this needs to be done right.
authorbehlendo <behlendo@7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c>
Fri, 7 Mar 2008 00:28:32 +0000 (00:28 +0000)
committerbehlendo <behlendo@7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c>
Fri, 7 Mar 2008 00:28:32 +0000 (00:28 +0000)
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

include/sys/atomic.h [new file with mode: 0644]
include/sys/kstat.h
include/sys/sysmacros.h
include/sys/timer.h

diff --git a/include/sys/atomic.h b/include/sys/atomic.h
new file mode 100644 (file)
index 0000000..ae21303
--- /dev/null
@@ -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 */
+
index 0b6ce0583e3c12e86d987aa6762c551a2b445e6e..0b79a41c04e6068cf5efb0a8e35ace82431c3f79 100644 (file)
@@ -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
index 2c3ec0e4e6955c4290c48e1e016759f132491d90..a96c47fa4e56032043a8a38e8a040359617c2b2a 100644 (file)
@@ -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)
 
index 237195d76381640ad3f42004b2e9ad93cdae0076..7e8c6fd41aa8cb25f3d7045be1b2ba0302673e32 100644 (file)
@@ -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
 }