--- /dev/null
+#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 */
+
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
*/
#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
*/
#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)
#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
}