linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] zone configration check function [1/2]
@ 2007-02-20  5:30 KAMEZAWA Hiroyuki
  2007-02-20  5:34 ` [PATCH] remove zone ifdefs under mm/ [2/2] KAMEZAWA Hiroyuki
  0 siblings, 1 reply; 2+ messages in thread
From: KAMEZAWA Hiroyuki @ 2007-02-20  5:30 UTC (permalink / raw)
  To: linux-mm

An idea for remove #ifdefs...

This defines not configured zones ids as ids bigger than MAX_NR_ZONES.
We can use is_cofigured_zone(zone_id) for accessing specific zones
instead of inserting #ifdefs in the middle of funcs.

(*)MAX_NR_ZONES means as it does now.

This patch is against 2.6.20.

Signed-Off-By: KAMEZAWA Hiroyuki <kamezaw.hiroyu@jp.fujitsu.com>


Index: linux-2.6.20-devel/include/linux/mmzone.h
===================================================================
--- linux-2.6.20-devel.orig/include/linux/mmzone.h
+++ linux-2.6.20-devel/include/linux/mmzone.h
@@ -136,9 +136,23 @@ enum zone_type {
 	 */
 	ZONE_HIGHMEM,
 #endif
-	MAX_NR_ZONES
+	MAX_NR_ZONES,
+	/* Below is invalid zone ids depends on config */
+#ifndef CONFIG_ZONE_DMA32
+	ZONE_DMA32,
+#endif
+#ifndef CONFIG_ZONE_HIGHMEM
+	ZONE_HIGHMEM,
+#endif
+	ALL_POSSIBLE_ZONES
+#
 };
 
+static inline int is_configured_zone(enum zone_type id)
+{
+	return (id < MAX_NR_ZONES);
+}
+
 /*
  * When a memory allocation must conform to specific limitations (such
  * as being suitable for DMA) the caller will pass in hints to the
@@ -480,11 +494,9 @@ static inline int populated_zone(struct 
 
 static inline int is_highmem_idx(enum zone_type idx)
 {
-#ifdef CONFIG_HIGHMEM
+	if (!is_configured_zone(ZONE_HIGHMEM))
+		return 0;
 	return (idx == ZONE_HIGHMEM);
-#else
-	return 0;
-#endif
 }
 
 static inline int is_normal_idx(enum zone_type idx)
@@ -500,11 +512,9 @@ static inline int is_normal_idx(enum zon
  */
 static inline int is_highmem(struct zone *zone)
 {
-#ifdef CONFIG_HIGHMEM
+	if (!is_configured_zone(ZONE_HIGHMEM))
+		return 0;
 	return zone == zone->zone_pgdat->node_zones + ZONE_HIGHMEM;
-#else
-	return 0;
-#endif
 }
 
 static inline int is_normal(struct zone *zone)
@@ -514,11 +524,9 @@ static inline int is_normal(struct zone 
 
 static inline int is_dma32(struct zone *zone)
 {
-#ifdef CONFIG_ZONE_DMA32
+	if (!is_configured_zone(ZONE_DMA32))
+		return 0;
 	return zone == zone->zone_pgdat->node_zones + ZONE_DMA32;
-#else
-	return 0;
-#endif
 }
 
 static inline int is_dma(struct zone *zone)

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-02-20  5:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-20  5:30 [PATCH] zone configration check function [1/2] KAMEZAWA Hiroyuki
2007-02-20  5:34 ` [PATCH] remove zone ifdefs under mm/ [2/2] KAMEZAWA Hiroyuki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox