]> git.proxmox.com Git - mirror_spl-debian.git/commitdiff
More stub headers,
authorbehlendo <behlendo@7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c>
Tue, 4 Mar 2008 18:22:31 +0000 (18:22 +0000)
committerbehlendo <behlendo@7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c>
Tue, 4 Mar 2008 18:22:31 +0000 (18:22 +0000)
moved generic to sysmacros,
added some more macros for kernel compatibility

git-svn-id: https://outreach.scidac.gov/svn/spl/trunk@22 7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c

include/strings.h [new file with mode: 0644]
include/sys/Makefile.am
include/sys/generic.h [deleted file]
include/sys/spl.h
include/sys/sysmacros.h [new file with mode: 0644]
include/sys/thread.h
include/sys/types.h
include/unistd.h [new file with mode: 0644]
modules/spl/spl-generic.c

diff --git a/include/strings.h b/include/strings.h
new file mode 100644 (file)
index 0000000..697ac4d
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef _SPL_STRINGS_H
+#define _SPL_STRINGS_H
+
+#endif /* SPL_STRINGS_H */
index c44748e02764d70de7b5593cbc591d6a57c3a1a5..8fc6f91b0e7390517d26b70272e4986d96750bdc 100644 (file)
@@ -1,5 +1,5 @@
 EXTRA_DIST  = callb.h cmn_err.h condvar.h cred.h
-EXTRA_DIST += debug.h generic.h kmem.h kstat.h
+EXTRA_DIST += debug.h kmem.h kstat.h
 EXTRA_DIST += mutex.h param.h random.h rwlock.h
 EXTRA_DIST += spl.h taskq.h thread.h time.h
 EXTRA_DIST += timer.h types.h
diff --git a/include/sys/generic.h b/include/sys/generic.h
deleted file mode 100644 (file)
index 2d09892..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-#ifndef _SPL_GENERIC_H
-#define _SPL_GENERIC_H
-
-#ifdef  __cplusplus
-extern "C" {
-#endif
-
-#include <linux/module.h>
-
-/* Missing defines.
- */
-#define INT32_MAX                       INT_MAX
-#define UINT64_MAX                      (~0ULL)
-#define NBBY                            8
-#define ENOTSUP                         ENOTSUPP
-#define MAXNAMELEN                      256
-#define MAXPATHLEN                      PATH_MAX
-#define __va_list                       va_list
-#define _KERNEL                         __KERNEL__
-#define max_ncpus                       64
-
-/* 0..MAX_PRIO-1:              Process priority
- * 0..MAX_RT_PRIO-1:           RT priority tasks
- * MAX_RT_PRIO..MAX_PRIO-1:    SCHED_NORMAL tasks
- *
- * Treat shim tasks as SCHED_NORMAL tasks
- */
-#define minclsyspri                     (MAX_RT_PRIO)
-#define maxclsyspri                     (MAX_PRIO-1)
-
-#define NICE_TO_PRIO(nice)             (MAX_RT_PRIO + (nice) + 20)
-#define PRIO_TO_NICE(prio)             ((prio) - MAX_RT_PRIO - 20)
-
-#define kred                            NULL
-
-#define FREAD                           1
-#define FWRITE                          2
-#define FCREAT  O_CREAT
-#define FTRUNC  O_TRUNC
-#define FOFFMAX O_LARGEFILE
-#define FSYNC   O_SYNC
-#define FDSYNC  O_DSYNC
-#define FRSYNC  O_RSYNC
-#define FEXCL   O_EXCL
-
-#define FNODSYNC  0x10000 /* fsync pseudo flag */
-#define FNOFOLLOW 0x20000 /* don't follow symlinks */
-
-/* Missing macros
- */
-#define PAGESIZE                        PAGE_SIZE
-
-/* from Solaris sys/byteorder.h */
-#define BSWAP_8(x)      ((x) & 0xff)
-#define BSWAP_16(x)     ((BSWAP_8(x) << 8) | BSWAP_8((x) >> 8))
-#define BSWAP_32(x)     ((BSWAP_16(x) << 16) | BSWAP_16((x) >> 16))
-#define BSWAP_64(x)     ((BSWAP_32(x) << 32) | BSWAP_32((x) >> 32))
-
-/* Map some simple functions.
- */
-#define bzero(ptr,size)                 memset(ptr,0,size)
-#define bcopy(src,dest,size)            memcpy(dest,src,size)
-#define ASSERT(x)                       BUG_ON(!(x))
-#define ASSERT3U(left,OP,right)         BUG_ON(!((left) OP (right)))
-
-/* Missing globals
- */
-extern int p0;
-
-#ifdef  __cplusplus
-}
-#endif
-
-#endif  /* _SPL_GENERIC_H */
index 7cc1cab5835d3c14bcd197f9e2e7ae51b8ede337..b8c1c383792340a181c6d84260b657c06032c214 100644 (file)
@@ -4,7 +4,7 @@
 #include <sys/callb.h>
 #include <sys/condvar.h>
 #include <sys/cred.h>
-#include <sys/generic.h>
+#include <sys/sysmacros.h>
 #include <sys/kmem.h>
 #include <sys/kstat.h>
 #include <sys/mutex.h>
diff --git a/include/sys/sysmacros.h b/include/sys/sysmacros.h
new file mode 100644 (file)
index 0000000..c48019f
--- /dev/null
@@ -0,0 +1,141 @@
+#ifndef _SPL_SYSMACROS_H
+#define _SPL_SYSMACROS_H
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+#include <linux/module.h>
+
+#ifndef _KERNEL
+#define _KERNEL                         __KERNEL__
+#endif
+
+/* Missing defines.
+ */
+#define INT32_MAX                       INT_MAX
+#define UINT64_MAX                      (~0ULL)
+#define NBBY                            8
+#define ENOTSUP                         ENOTSUPP
+#define MAXNAMELEN                      256
+#define MAXPATHLEN                      PATH_MAX
+#define __va_list                       va_list
+#define max_ncpus                       64
+
+/* 0..MAX_PRIO-1:              Process priority
+ * 0..MAX_RT_PRIO-1:           RT priority tasks
+ * MAX_RT_PRIO..MAX_PRIO-1:    SCHED_NORMAL tasks
+ *
+ * Treat shim tasks as SCHED_NORMAL tasks
+ */
+#define minclsyspri                     (MAX_RT_PRIO)
+#define maxclsyspri                     (MAX_PRIO-1)
+
+#define NICE_TO_PRIO(nice)             (MAX_RT_PRIO + (nice) + 20)
+#define PRIO_TO_NICE(prio)             ((prio) - MAX_RT_PRIO - 20)
+
+#define kred                            NULL
+
+#define FREAD                           1
+#define FWRITE                          2
+#define FCREAT  O_CREAT
+#define FTRUNC  O_TRUNC
+#define FOFFMAX O_LARGEFILE
+#define FSYNC   O_SYNC
+#define FDSYNC  O_DSYNC
+#define FRSYNC  O_RSYNC
+#define FEXCL   O_EXCL
+
+#define FNODSYNC  0x10000 /* fsync pseudo flag */
+#define FNOFOLLOW 0x20000 /* don't follow symlinks */
+
+/* Missing macros
+ */
+#define PAGESIZE                        PAGE_SIZE
+
+/* from Solaris sys/byteorder.h */
+#define BSWAP_8(x)      ((x) & 0xff)
+#define BSWAP_16(x)     ((BSWAP_8(x) << 8) | BSWAP_8((x) >> 8))
+#define BSWAP_32(x)     ((BSWAP_16(x) << 16) | BSWAP_16((x) >> 16))
+#define BSWAP_64(x)     ((BSWAP_32(x) << 32) | BSWAP_32((x) >> 32))
+
+/* Map some simple functions.
+ */
+#define bzero(ptr,size)                 memset(ptr,0,size)
+#define bcopy(src,dest,size)            memcpy(dest,src,size)
+#define ASSERT(x)                       BUG_ON(!(x))
+#define ASSERT3U(left,OP,right)         BUG_ON(!((left) OP (right)))
+
+/* Missing globals
+ */
+extern int p0;
+
+#define makedevice(maj,min) makedev(maj,min)
+
+/* XXX - Borrowed from zfs project libsolcompat/include/sys/sysmacros.h */
+/* common macros */
+#ifndef MIN
+#define MIN(a, b)       ((a) < (b) ? (a) : (b))
+#endif
+#ifndef MAX
+#define MAX(a, b)       ((a) < (b) ? (b) : (a))
+#endif
+#ifndef ABS
+#define ABS(a)          ((a) < 0 ? -(a) : (a))
+#endif
+
+/*
+ * Compatibility macros/typedefs needed for Solaris -> Linux port
+ */
+#define P2ALIGN(x, align)    ((x) & -(align))
+#define P2CROSS(x, y, align) (((x) ^ (y)) > (align) - 1)
+#define P2ROUNDUP(x, align)  (-(-(x) & -(align)))
+#define P2ROUNDUP_TYPED(x, align, type) \
+                             (-(-(type)(x) & -(type)(align)))
+#define P2PHASE(x, align)    ((x) & ((align) - 1))
+#define P2NPHASE(x, align)   (-(x) & ((align) - 1))
+#define P2NPHASE_TYPED(x, align, type) \
+                             (-(type)(x) & ((type)(align) - 1))
+#define ISP2(x)              (((x) & ((x) - 1)) == 0)
+#define IS_P2ALIGNED(v, a)   ((((uintptr_t)(v)) & ((uintptr_t)(a) - 1)) == 0)
+
+/*
+ * Typed version of the P2* macros.  These macros should be used to ensure
+ * that the result is correctly calculated based on the data type of (x),
+ * which is passed in as the last argument, regardless of the data
+ * type of the alignment.  For example, if (x) is of type uint64_t,
+ * and we want to round it up to a page boundary using "PAGESIZE" as
+ * the alignment, we can do either
+ * P2ROUNDUP(x, (uint64_t)PAGESIZE)
+ * or
+ * P2ROUNDUP_TYPED(x, PAGESIZE, uint64_t)
+ */
+#define P2ALIGN_TYPED(x, align, type)   \
+        ((type)(x) & -(type)(align))
+#define P2PHASE_TYPED(x, align, type)   \
+        ((type)(x) & ((type)(align) - 1))
+#define P2NPHASE_TYPED(x, align, type)  \
+        (-(type)(x) & ((type)(align) - 1))
+#define P2ROUNDUP_TYPED(x, align, type) \
+        (-(-(type)(x) & -(type)(align)))
+#define P2END_TYPED(x, align, type)     \
+        (-(~(type)(x) & -(type)(align)))
+#define P2PHASEUP_TYPED(x, align, phase, type)  \
+        ((type)(phase) - (((type)(phase) - (type)(x)) & -(type)(align)))
+#define P2CROSS_TYPED(x, y, align, type)        \
+        (((type)(x) ^ (type)(y)) > (type)(align) - 1)
+#define P2SAMEHIGHBIT_TYPED(x, y, type) \
+        (((type)(x) ^ (type)(y)) < ((type)(x) & (type)(y)))
+
+#if defined(_KERNEL) && !defined(_KMEMUSER) && !defined(offsetof)
+
+/* avoid any possibility of clashing with <stddef.h> version */
+
+#define offsetof(s, m)  ((size_t)(&(((s *)0)->m)))
+#endif
+
+#ifdef  __cplusplus
+}
+#endif
+
+#endif  /* _SPL_SYSMACROS_H */
index e7f99c96d4466d6f50dd1935c1b0033d306edcd2..d1009ab6d8c7713012f07dd930caa361b8830d2f 100644 (file)
@@ -9,7 +9,7 @@ extern "C" {
 #include <linux/mm.h>
 #include <linux/spinlock.h>
 #include <sys/types.h>
-#include <sys/generic.h>
+#include <sys/sysmacros.h>
 
 /*
  * Thread interfaces
index 28dc16435c5610dd6a5ece721ddd8b656c207666..0a6cbfe791237308331766047b367958f1391504 100644 (file)
@@ -6,7 +6,7 @@ extern "C" {
 #endif
 
 #include <linux/types.h>
-#include <sys/generic.h>
+#include <sys/sysmacros.h>
 
 typedef enum { B_FALSE=0, B_TRUE=1 }   boolean_t;
 typedef unsigned long                  uintptr_t;
diff --git a/include/unistd.h b/include/unistd.h
new file mode 100644 (file)
index 0000000..c6b298a
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef _SPL_UNISTD_H
+#define _SPL_UNISTD_H
+
+#endif /* SPL_UNISTD_H */
index 653b8cd1f71d6206f1e54637d911c9274d266d7a..60bebfdc47bf85094b5b5e2c2e3ae4371d499ee9 100644 (file)
@@ -1,4 +1,4 @@
-#include <sys/generic.h>
+#include <sys/sysmacros.h>
 #include "config.h"
 
 /*