Skip to contentSkip to conversation

make memclass() an inline functino

PATCH William Lee Irwin III 2 participants 3 messages Jun 2, 2002 – Jun 3, 2002

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

memclass is too large to be a #define; it overflows 80 columns and does not make use of facilities available only to macros.

This patch convert memclass() to be an inline function.

Cheers,
Bill

===== include/linux/mmzone.h 1.10 vs edited =====

include/linux/mmzone.h +8 -2
@@ -142,8 +142,14 @@
 extern int numnodes;
 extern pg_data_t *pgdat_list;
 
-#define memclass(pgzone, classzone)	(((pgzone)->zone_pgdat == (classzone)->zone_pgdat) \
-			&& ((pgzone) <= (classzone)))
+static inline int memclass(zone_t *pgzone, zone_t *classzone)
+{
+	if (pgzone->zone_pgdat != classzone->zone_pgdat)
+		return 0;
+	if (pgzone > classzone)
+		return 0;
+	return 1;
+}
 
 /*
  * The following two are not meant for general usage. They are here as
#1 lore raw
Quoted 4 lines · William Lee Irwin III

memclass is too large to be a #define; it overflows 80 columns and does not make use of facilities available only to macros.

This patch convert memclass() to be an inline function.

Exercise care when doing this. Gcc sometimes optimises macros better than it optimises inline functions

#2 lore raw
In reply to William Lee Irwin III
Quoted 3 lines · William Lee Irwin III
Quoted 3 lines

memclass is too large to be a #define; it overflows 80 columns and does not make use of facilities available only to macros.
This patch convert memclass() to be an inline function.

Quoted 2 lines · Alan Cox

Exercise care when doing this. Gcc sometimes optimises macros better than it optimises inline functions

I'll go over the assembly generated for i386, though I'm not entirely convinced this is exercised in the fast path.

Cheers,
Bill