Skip to contentSkip to conversation

Make linux/swap.h usable by userspace code.

PATCH In review Steven J. Hill 2 participants 3 messages Mar 1, 2004 MM swap

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Make linux/swap.h usable by userspace code.

Greetings.

This patch allows 'swap.h' to be included by userspace code. AFAIK the LTP suite is the only code that does this so far.

-Steve

include/linux/swap.h +14 -13
@@ -2,6 +2,20 @@
 #define _LINUX_SWAP_H
 
 #include <linux/config.h>
+
+/*
+ * MAX_SWAPFILES defines the maximum number of swaptypes: things which can
+ * be swapped to.  The swap type and the offset into that swap type are
+ * encoded into pte's and into pgoff_t's in the swapcache.  Using five bits
+ * for the type means that the maximum number of swapcache pages is 27 bits
+ * on 32-bit-pgoff_t architectures.  And that assumes that the architecture packs
+ * the type/offset into the pte as 5/27 as well.
+ */
+#define MAX_SWAPFILES_SHIFT	5
+#define MAX_SWAPFILES		(1 << MAX_SWAPFILES_SHIFT)
+
+#ifdef __KERNEL__
+
 #include <linux/spinlock.h>
 #include <linux/linkage.h>
 #include <linux/mmzone.h>
@@ -20,17 +34,6 @@
 }
 
 /*
- * MAX_SWAPFILES defines the maximum number of swaptypes: things which can
- * be swapped to.  The swap type and the offset into that swap type are
- * encoded into pte's and into pgoff_t's in the swapcache.  Using five bits
- * for the type means that the maximum number of swapcache pages is 27 bits
- * on 32-bit-pgoff_t architectures.  And that assumes that the architecture packs
- * the type/offset into the pte as 5/27 as well.
- */
-#define MAX_SWAPFILES_SHIFT	5
-#define MAX_SWAPFILES		(1 << MAX_SWAPFILES_SHIFT)
-
-/*
  * Magic header for a swap area. The first part of the union is
  * what the swap magic looks like for the old (limited to 128MB)
  * swap area format, the second part of the union adds - in the
@@ -72,8 +75,6 @@
 struct reclaim_state {
 	unsigned long reclaimed_slab;
 };
-
-#ifdef __KERNEL__
 
 struct address_space;
 struct pte_chain;
#1 lore raw
Quoted 4 lines · Steven J. Hill

Greetings.

This patch allows 'swap.h' to be included by userspace code. AFAIK the LTP suite is the only code that does this so far.

Gack. Including swap.h is really silly. Fix ltp to not do such things instead.

#2 lore raw
Quoted 4 lines · Christoph Hellwig

Gack. Including swap.h is really silly. Fix ltp to not do such things instead.

Fine, then let's just remove the #ifdef __KERNEL__ all together then.

-Steve