Fix tools compliation described in ticket #1934
authorproski <proski@0192ed92-7a03-0410-a25b-9323aeb14dbd>
Fri, 6 Jun 2008 05:38:29 +0000 (05:38 +0000)
committerproski <proski@0192ed92-7a03-0410-a25b-9323aeb14dbd>
Fri, 6 Jun 2008 05:38:29 +0000 (05:38 +0000)
Change compat.h to never use KERNEL_VERSION in userspace code.  Move it
to the block only used by the kernel code.  While at that, move KASSERT
to the same block.

git-svn-id: http://madwifi-project.org/svn/madwifi/trunk@3706 0192ed92-7a03-0410-a25b-9323aeb14dbd

include/compat.h

index 2637b0c8015295a1842bb512508c2a27eaddb244..9e27dc728a6fda6d6cfcf078ef20b16be7a99900 100644 (file)
 #define __force
 #endif
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
-typedef int gfp_t;
-#endif
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,3)
-static inline void *kzalloc(size_t size, gfp_t flags)
-{
-       void *p = kmalloc(size, flags);
-       if (likely(p != NULL))
-               memset(p, 0, size);
-       return p;
-}
-#endif
-
 #ifndef container_of
 #define container_of(ptr, type, member) ({                             \
            const typeof( ((type *)0)->member ) *__mptr = (ptr);        \
@@ -115,15 +101,6 @@ static inline void *kzalloc(size_t size, gfp_t flags)
 
 #define        __offsetof(t,m) offsetof(t,m)
 
-#ifdef __KERNEL__
-#define        KASSERT(exp, msg) do {                  \
-       if (unlikely(!(exp))) {                 \
-               printk msg;                     \
-               BUG();                          \
-       }                                       \
-} while (0)
-#endif /* __KERNEL__ */
-
 /*
  * NetBSD/FreeBSD defines for file version.
  */
@@ -135,6 +112,27 @@ static inline void *kzalloc(size_t size, gfp_t flags)
  */
 #ifdef __KERNEL__
 
+#define KASSERT(exp, msg) do {                 \
+       if (unlikely(!(exp))) {                 \
+               printk msg;                     \
+               BUG();                          \
+       }                                       \
+} while (0)
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
+typedef int gfp_t;
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,3)
+static inline void *kzalloc(size_t size, gfp_t flags)
+{
+       void *p = kmalloc(size, flags);
+       if (likely(p != NULL))
+               memset(p, 0, size);
+       return p;
+}
+#endif
+
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)
 #define ATH_REGISTER_SYSCTL_TABLE(t) register_sysctl_table(t, 1)
 #else