From a844f4510dce23c07f3923cb42138f5fdd745017 Mon Sep 17 00:00:00 2001
From: Nathan Scott <nathans@sgi.com>
Date: Wed, 2 Nov 2005 14:38:42 +1100
Subject: [XFS] Remove xfs_macros.c, xfs_macros.h, rework headers a whole lot.

SGI-PV: 943122
SGI-Modid: xfs-linux:xfs-kern:23901a

Signed-off-by: Nathan Scott <nathans@sgi.com>
---
 fs/xfs/xfs_dir2_leaf.h | 310 ++++++++++++++++++++-----------------------------
 1 file changed, 123 insertions(+), 187 deletions(-)

(limited to 'fs/xfs/xfs_dir2_leaf.h')

diff --git a/fs/xfs/xfs_dir2_leaf.h b/fs/xfs/xfs_dir2_leaf.h
index 3303cd6f4c00..43f0ec2131a9 100644
--- a/fs/xfs/xfs_dir2_leaf.h
+++ b/fs/xfs/xfs_dir2_leaf.h
@@ -43,10 +43,6 @@ struct xfs_inode;
 struct xfs_mount;
 struct xfs_trans;
 
-/*
- * Constants.
- */
-
 /*
  * Offset of the leaf/node space.  First block in this space
  * is the btree root.
@@ -56,10 +52,6 @@ struct xfs_trans;
 #define	XFS_DIR2_LEAF_FIRSTDB(mp)	\
 	XFS_DIR2_BYTE_TO_DB(mp, XFS_DIR2_LEAF_OFFSET)
 
-/*
- * Types.
- */
-
 /*
  * Offset in data space of a data entry.
  */
@@ -67,10 +59,6 @@ typedef	__uint32_t	xfs_dir2_dataptr_t;
 #define	XFS_DIR2_MAX_DATAPTR	((xfs_dir2_dataptr_t)0xffffffff)
 #define	XFS_DIR2_NULL_DATAPTR	((xfs_dir2_dataptr_t)0)
 
-/*
- * Structures.
- */
-
 /*
  * Leaf block header.
  */
@@ -109,245 +97,193 @@ typedef struct xfs_dir2_leaf {
 } xfs_dir2_leaf_t;
 
 /*
- * Macros.
- * The DB blocks are logical directory block numbers, not filesystem blocks.
+ * DB blocks here are logical directory block numbers, not filesystem blocks.
  */
 
-#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_MAX_LEAF_ENTS)
-int
-xfs_dir2_max_leaf_ents(struct xfs_mount *mp);
-#define	XFS_DIR2_MAX_LEAF_ENTS(mp)	\
-	xfs_dir2_max_leaf_ents(mp)
-#else
-#define	XFS_DIR2_MAX_LEAF_ENTS(mp)	\
-	((int)(((mp)->m_dirblksize - (uint)sizeof(xfs_dir2_leaf_hdr_t)) / \
-	       (uint)sizeof(xfs_dir2_leaf_entry_t)))
-#endif
+#define	XFS_DIR2_MAX_LEAF_ENTS(mp)	xfs_dir2_max_leaf_ents(mp)
+static inline int xfs_dir2_max_leaf_ents(struct xfs_mount *mp)
+{
+	return (int)(((mp)->m_dirblksize - (uint)sizeof(xfs_dir2_leaf_hdr_t)) /
+	       (uint)sizeof(xfs_dir2_leaf_entry_t));
+}
 
 /*
  * Get address of the bestcount field in the single-leaf block.
  */
-#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_LEAF_TAIL_P)
-xfs_dir2_leaf_tail_t *
-xfs_dir2_leaf_tail_p(struct xfs_mount *mp, xfs_dir2_leaf_t *lp);
-#define	XFS_DIR2_LEAF_TAIL_P(mp,lp)	\
-	xfs_dir2_leaf_tail_p(mp, lp)
-#else
-#define	XFS_DIR2_LEAF_TAIL_P(mp,lp)	\
-	((xfs_dir2_leaf_tail_t *)\
-	 ((char *)(lp) + (mp)->m_dirblksize - \
-	  (uint)sizeof(xfs_dir2_leaf_tail_t)))
-#endif
+#define	XFS_DIR2_LEAF_TAIL_P(mp,lp)	xfs_dir2_leaf_tail_p(mp, lp)
+static inline xfs_dir2_leaf_tail_t *
+xfs_dir2_leaf_tail_p(struct xfs_mount *mp, xfs_dir2_leaf_t *lp)
+{
+	return (xfs_dir2_leaf_tail_t *)
+		((char *)(lp) + (mp)->m_dirblksize - 
+		  (uint)sizeof(xfs_dir2_leaf_tail_t));
+}
 
 /*
  * Get address of the bests array in the single-leaf block.
  */
-#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_LEAF_BESTS_P)
-xfs_dir2_data_off_t *
-xfs_dir2_leaf_bests_p(xfs_dir2_leaf_tail_t *ltp);
 #define	XFS_DIR2_LEAF_BESTS_P(ltp)	xfs_dir2_leaf_bests_p(ltp)
-#else
-#define	XFS_DIR2_LEAF_BESTS_P(ltp)	\
-	((xfs_dir2_data_off_t *)(ltp) - INT_GET((ltp)->bestcount, ARCH_CONVERT))
-#endif
+static inline xfs_dir2_data_off_t *
+xfs_dir2_leaf_bests_p(xfs_dir2_leaf_tail_t *ltp)
+{
+	return (xfs_dir2_data_off_t *)
+		(ltp) - INT_GET((ltp)->bestcount, ARCH_CONVERT);
+}
 
 /*
  * Convert dataptr to byte in file space
  */
-#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_DATAPTR_TO_BYTE)
-xfs_dir2_off_t
-xfs_dir2_dataptr_to_byte(struct xfs_mount *mp, xfs_dir2_dataptr_t dp);
 #define	XFS_DIR2_DATAPTR_TO_BYTE(mp,dp)	xfs_dir2_dataptr_to_byte(mp, dp)
-#else
-#define	XFS_DIR2_DATAPTR_TO_BYTE(mp,dp)	\
-	((xfs_dir2_off_t)(dp) << XFS_DIR2_DATA_ALIGN_LOG)
-#endif
+static inline xfs_dir2_off_t
+xfs_dir2_dataptr_to_byte(struct xfs_mount *mp, xfs_dir2_dataptr_t dp)
+{
+	return (xfs_dir2_off_t)(dp) << XFS_DIR2_DATA_ALIGN_LOG;
+}
 
 /*
  * Convert byte in file space to dataptr.  It had better be aligned.
  */
-#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_BYTE_TO_DATAPTR)
-xfs_dir2_dataptr_t
-xfs_dir2_byte_to_dataptr(struct xfs_mount *mp, xfs_dir2_off_t by);
 #define	XFS_DIR2_BYTE_TO_DATAPTR(mp,by)	xfs_dir2_byte_to_dataptr(mp,by)
-#else
-#define	XFS_DIR2_BYTE_TO_DATAPTR(mp,by)	\
-	((xfs_dir2_dataptr_t)((by) >> XFS_DIR2_DATA_ALIGN_LOG))
-#endif
+static inline xfs_dir2_dataptr_t
+xfs_dir2_byte_to_dataptr(struct xfs_mount *mp, xfs_dir2_off_t by)
+{
+	return (xfs_dir2_dataptr_t)((by) >> XFS_DIR2_DATA_ALIGN_LOG);
+}
+
+/*
+ * Convert byte in space to (DB) block
+ */
+#define	XFS_DIR2_BYTE_TO_DB(mp,by)	xfs_dir2_byte_to_db(mp, by)
+static inline xfs_dir2_db_t
+xfs_dir2_byte_to_db(struct xfs_mount *mp, xfs_dir2_off_t by)
+{
+	return (xfs_dir2_db_t)((by) >> \
+		 ((mp)->m_sb.sb_blocklog + (mp)->m_sb.sb_dirblklog));
+}
 
 /*
  * Convert dataptr to a block number
  */
-#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_DATAPTR_TO_DB)
-xfs_dir2_db_t
-xfs_dir2_dataptr_to_db(struct xfs_mount *mp, xfs_dir2_dataptr_t dp);
 #define	XFS_DIR2_DATAPTR_TO_DB(mp,dp)	xfs_dir2_dataptr_to_db(mp, dp)
-#else
-#define	XFS_DIR2_DATAPTR_TO_DB(mp,dp)	\
-	XFS_DIR2_BYTE_TO_DB(mp, XFS_DIR2_DATAPTR_TO_BYTE(mp, dp))
-#endif
+static inline xfs_dir2_db_t
+xfs_dir2_dataptr_to_db(struct xfs_mount *mp, xfs_dir2_dataptr_t dp)
+{
+	return XFS_DIR2_BYTE_TO_DB(mp, XFS_DIR2_DATAPTR_TO_BYTE(mp, dp));
+}
+
+/*
+ * Convert byte in space to offset in a block
+ */
+#define	XFS_DIR2_BYTE_TO_OFF(mp,by)	xfs_dir2_byte_to_off(mp, by)
+static inline xfs_dir2_data_aoff_t
+xfs_dir2_byte_to_off(struct xfs_mount *mp, xfs_dir2_off_t by)
+{
+	return (xfs_dir2_data_aoff_t)((by) & \
+		((1 << ((mp)->m_sb.sb_blocklog + (mp)->m_sb.sb_dirblklog)) - 1));
+}
 
 /*
  * Convert dataptr to a byte offset in a block
  */
-#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_DATAPTR_TO_OFF)
-xfs_dir2_data_aoff_t
-xfs_dir2_dataptr_to_off(struct xfs_mount *mp, xfs_dir2_dataptr_t dp);
 #define	XFS_DIR2_DATAPTR_TO_OFF(mp,dp)	xfs_dir2_dataptr_to_off(mp, dp)
-#else
-#define	XFS_DIR2_DATAPTR_TO_OFF(mp,dp)	\
-	XFS_DIR2_BYTE_TO_OFF(mp, XFS_DIR2_DATAPTR_TO_BYTE(mp, dp))
-#endif
+static inline xfs_dir2_data_aoff_t
+xfs_dir2_dataptr_to_off(struct xfs_mount *mp, xfs_dir2_dataptr_t dp)
+{
+	return XFS_DIR2_BYTE_TO_OFF(mp, XFS_DIR2_DATAPTR_TO_BYTE(mp, dp));
+}
 
 /*
  * Convert block and offset to byte in space
  */
-#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_DB_OFF_TO_BYTE)
-xfs_dir2_off_t
-xfs_dir2_db_off_to_byte(struct xfs_mount *mp, xfs_dir2_db_t db,
-			xfs_dir2_data_aoff_t o);
 #define	XFS_DIR2_DB_OFF_TO_BYTE(mp,db,o)	\
 	xfs_dir2_db_off_to_byte(mp, db, o)
-#else
-#define	XFS_DIR2_DB_OFF_TO_BYTE(mp,db,o)	\
-	(((xfs_dir2_off_t)(db) << \
-	 ((mp)->m_sb.sb_blocklog + (mp)->m_sb.sb_dirblklog)) + (o))
-#endif
+static inline xfs_dir2_off_t
+xfs_dir2_db_off_to_byte(struct xfs_mount *mp, xfs_dir2_db_t db,
+			xfs_dir2_data_aoff_t o)
+{
+	return ((xfs_dir2_off_t)(db) << \
+		((mp)->m_sb.sb_blocklog + (mp)->m_sb.sb_dirblklog)) + (o);
+}
 
 /*
- * Convert byte in space to (DB) block
+ * Convert block (DB) to block (dablk)
  */
-#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_BYTE_TO_DB)
-xfs_dir2_db_t xfs_dir2_byte_to_db(struct xfs_mount *mp, xfs_dir2_off_t by);
-#define	XFS_DIR2_BYTE_TO_DB(mp,by)	xfs_dir2_byte_to_db(mp, by)
-#else
-#define	XFS_DIR2_BYTE_TO_DB(mp,by)	\
-	((xfs_dir2_db_t)((by) >> \
-			 ((mp)->m_sb.sb_blocklog + (mp)->m_sb.sb_dirblklog)))
-#endif
+#define	XFS_DIR2_DB_TO_DA(mp,db)	xfs_dir2_db_to_da(mp, db)
+static inline xfs_dablk_t
+xfs_dir2_db_to_da(struct xfs_mount *mp, xfs_dir2_db_t db)
+{
+	return (xfs_dablk_t)((db) << (mp)->m_sb.sb_dirblklog);
+}
 
 /*
  * Convert byte in space to (DA) block
  */
-#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_BYTE_TO_DA)
-xfs_dablk_t xfs_dir2_byte_to_da(struct xfs_mount *mp, xfs_dir2_off_t by);
 #define	XFS_DIR2_BYTE_TO_DA(mp,by)	xfs_dir2_byte_to_da(mp, by)
-#else
-#define	XFS_DIR2_BYTE_TO_DA(mp,by)	\
-	XFS_DIR2_DB_TO_DA(mp, XFS_DIR2_BYTE_TO_DB(mp, by))
-#endif
-
-/*
- * Convert byte in space to offset in a block
- */
-#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_BYTE_TO_OFF)
-xfs_dir2_data_aoff_t
-xfs_dir2_byte_to_off(struct xfs_mount *mp, xfs_dir2_off_t by);
-#define	XFS_DIR2_BYTE_TO_OFF(mp,by)	xfs_dir2_byte_to_off(mp, by)
-#else
-#define	XFS_DIR2_BYTE_TO_OFF(mp,by)	\
-	((xfs_dir2_data_aoff_t)((by) & \
-				((1 << ((mp)->m_sb.sb_blocklog + \
-					(mp)->m_sb.sb_dirblklog)) - 1)))
-#endif
+static inline xfs_dablk_t
+xfs_dir2_byte_to_da(struct xfs_mount *mp, xfs_dir2_off_t by)
+{
+	return XFS_DIR2_DB_TO_DA(mp, XFS_DIR2_BYTE_TO_DB(mp, by));
+}
 
 /*
  * Convert block and offset to dataptr
  */
-#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_DB_OFF_TO_DATAPTR)
-xfs_dir2_dataptr_t
-xfs_dir2_db_off_to_dataptr(struct xfs_mount *mp, xfs_dir2_db_t db,
-			   xfs_dir2_data_aoff_t o);
 #define	XFS_DIR2_DB_OFF_TO_DATAPTR(mp,db,o)	\
 	xfs_dir2_db_off_to_dataptr(mp, db, o)
-#else
-#define	XFS_DIR2_DB_OFF_TO_DATAPTR(mp,db,o)	\
-	XFS_DIR2_BYTE_TO_DATAPTR(mp, XFS_DIR2_DB_OFF_TO_BYTE(mp, db, o))
-#endif
-
-/*
- * Convert block (DB) to block (dablk)
- */
-#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_DB_TO_DA)
-xfs_dablk_t xfs_dir2_db_to_da(struct xfs_mount *mp, xfs_dir2_db_t db);
-#define	XFS_DIR2_DB_TO_DA(mp,db)	xfs_dir2_db_to_da(mp, db)
-#else
-#define	XFS_DIR2_DB_TO_DA(mp,db)	\
-	((xfs_dablk_t)((db) << (mp)->m_sb.sb_dirblklog))
-#endif
+static inline xfs_dir2_dataptr_t
+xfs_dir2_db_off_to_dataptr(struct xfs_mount *mp, xfs_dir2_db_t db,
+			   xfs_dir2_data_aoff_t o)
+{
+	return XFS_DIR2_BYTE_TO_DATAPTR(mp, XFS_DIR2_DB_OFF_TO_BYTE(mp, db, o));
+}
 
 /*
  * Convert block (dablk) to block (DB)
  */
-#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_DA_TO_DB)
-xfs_dir2_db_t xfs_dir2_da_to_db(struct xfs_mount *mp, xfs_dablk_t da);
 #define	XFS_DIR2_DA_TO_DB(mp,da)	xfs_dir2_da_to_db(mp, da)
-#else
-#define	XFS_DIR2_DA_TO_DB(mp,da)	\
-	((xfs_dir2_db_t)((da) >> (mp)->m_sb.sb_dirblklog))
-#endif
+static inline xfs_dir2_db_t
+xfs_dir2_da_to_db(struct xfs_mount *mp, xfs_dablk_t da)
+{
+	return (xfs_dir2_db_t)((da) >> (mp)->m_sb.sb_dirblklog);
+}
 
 /*
  * Convert block (dablk) to byte offset in space
  */
-#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DIR2_DA_TO_BYTE)
-xfs_dir2_off_t xfs_dir2_da_to_byte(struct xfs_mount *mp, xfs_dablk_t da);
 #define XFS_DIR2_DA_TO_BYTE(mp,da)	xfs_dir2_da_to_byte(mp, da)
-#else
-#define	XFS_DIR2_DA_TO_BYTE(mp,da)	\
-	XFS_DIR2_DB_OFF_TO_BYTE(mp, XFS_DIR2_DA_TO_DB(mp, da), 0)
-#endif
+static inline xfs_dir2_off_t
+xfs_dir2_da_to_byte(struct xfs_mount *mp, xfs_dablk_t da)
+{
+	return XFS_DIR2_DB_OFF_TO_BYTE(mp, XFS_DIR2_DA_TO_DB(mp, da), 0);
+}
 
 /*
  * Function declarations.
  */
-
-extern int
-	xfs_dir2_block_to_leaf(struct xfs_da_args *args, struct xfs_dabuf *dbp);
-
-extern int
-	xfs_dir2_leaf_addname(struct xfs_da_args *args);
-
-extern void
-	xfs_dir2_leaf_compact(struct xfs_da_args *args, struct xfs_dabuf *bp);
-
-extern void
-	xfs_dir2_leaf_compact_x1(struct xfs_dabuf *bp, int *indexp,
-				 int *lowstalep, int *highstalep, int *lowlogp,
-				 int *highlogp);
-
-extern int
-	xfs_dir2_leaf_getdents(struct xfs_trans *tp, struct xfs_inode *dp,
-			       struct uio *uio, int *eofp, struct xfs_dirent *dbp,
-			       xfs_dir2_put_t put);
-
-extern int
-	xfs_dir2_leaf_init(struct xfs_da_args *args, xfs_dir2_db_t bno,
-			   struct xfs_dabuf **bpp, int magic);
-
-extern void
-	xfs_dir2_leaf_log_ents(struct xfs_trans *tp, struct xfs_dabuf *bp,
-			       int first, int last);
-
-extern void
-	xfs_dir2_leaf_log_header(struct xfs_trans *tp, struct xfs_dabuf *bp);
-
-extern int
-	xfs_dir2_leaf_lookup(struct xfs_da_args *args);
-
-extern int
-	xfs_dir2_leaf_removename(struct xfs_da_args *args);
-
-extern int
-	xfs_dir2_leaf_replace(struct xfs_da_args *args);
-
-extern int
-	xfs_dir2_leaf_search_hash(struct xfs_da_args *args,
-				  struct xfs_dabuf *lbp);
-extern int
-	xfs_dir2_leaf_trim_data(struct xfs_da_args *args, struct xfs_dabuf *lbp,				xfs_dir2_db_t db);
-
-extern int
-	xfs_dir2_node_to_leaf(struct xfs_da_state *state);
+extern int xfs_dir2_block_to_leaf(struct xfs_da_args *args,
+				  struct xfs_dabuf *dbp);
+extern int xfs_dir2_leaf_addname(struct xfs_da_args *args);
+extern void xfs_dir2_leaf_compact(struct xfs_da_args *args,
+				  struct xfs_dabuf *bp);
+extern void xfs_dir2_leaf_compact_x1(struct xfs_dabuf *bp, int *indexp,
+				     int *lowstalep, int *highstalep,
+				     int *lowlogp, int *highlogp);
+extern int xfs_dir2_leaf_getdents(struct xfs_trans *tp, struct xfs_inode *dp,
+				  struct uio *uio, int *eofp,
+				  struct xfs_dirent *dbp, xfs_dir2_put_t put);
+extern int xfs_dir2_leaf_init(struct xfs_da_args *args, xfs_dir2_db_t bno,
+			      struct xfs_dabuf **bpp, int magic);
+extern void xfs_dir2_leaf_log_ents(struct xfs_trans *tp, struct xfs_dabuf *bp,
+				   int first, int last);
+extern void xfs_dir2_leaf_log_header(struct xfs_trans *tp,
+				     struct xfs_dabuf *bp);
+extern int xfs_dir2_leaf_lookup(struct xfs_da_args *args);
+extern int xfs_dir2_leaf_removename(struct xfs_da_args *args);
+extern int xfs_dir2_leaf_replace(struct xfs_da_args *args);
+extern int xfs_dir2_leaf_search_hash(struct xfs_da_args *args,
+				     struct xfs_dabuf *lbp);
+extern int xfs_dir2_leaf_trim_data(struct xfs_da_args *args,
+				   struct xfs_dabuf *lbp, xfs_dir2_db_t db);
+extern int xfs_dir2_node_to_leaf(struct xfs_da_state *state);
 
 #endif	/* __XFS_DIR2_LEAF_H__ */
-- 
cgit v1.2.1