aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ctree.h
diff options
context:
space:
mode:
authorLi Zefan <lizefan@huawei.com>2012-07-09 22:22:35 -0400
committerChris Mason <chris.mason@fusionio.com>2012-07-23 16:28:06 -0400
commit18077bb413687f96bd168efcfb2b8778529e3b74 (patch)
tree44adcefcc2177267437826b800800021cc2f4faf /fs/btrfs/ctree.h
parent293f7e07405a63975cee4e95a2cfa0c17b34b3aa (diff)
Btrfs: rewrite BTRFS_SETGET_FUNCS
BTRFS_SETGET_FUNCS macro is used to generate btrfs_set_foo() and btrfs_foo() functions, which read and write specific fields in the extent buffer. The total number of set/get functions is ~200, but in fact we only need 8 functions: 2 for u8 field, 2 for u16, 2 for u32 and 2 for u64. It results in redunction of ~37K bytes. text data bss dec hex filename 629661 12489 216 642366 9cd3e fs/btrfs/btrfs.o.orig 592637 12489 216 605342 93c9e fs/btrfs/btrfs.o Signed-off-by: Li Zefan <lizefan@huawei.com>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r--fs/btrfs/ctree.h53
1 files changed, 47 insertions, 6 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 6761490b91cd..a0ee2f8e0566 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -1623,13 +1623,54 @@ static inline void btrfs_init_map_token (struct btrfs_map_token *token)
1623 offsetof(type, member), \ 1623 offsetof(type, member), \
1624 sizeof(((type *)0)->member))) 1624 sizeof(((type *)0)->member)))
1625 1625
1626#ifndef BTRFS_SETGET_FUNCS 1626#define DECLARE_BTRFS_SETGET_BITS(bits) \
1627u##bits btrfs_get_token_##bits(struct extent_buffer *eb, void *ptr, \
1628 unsigned long off, \
1629 struct btrfs_map_token *token); \
1630void btrfs_set_token_##bits(struct extent_buffer *eb, void *ptr, \
1631 unsigned long off, u##bits val, \
1632 struct btrfs_map_token *token); \
1633static inline u##bits btrfs_get_##bits(struct extent_buffer *eb, void *ptr, \
1634 unsigned long off) \
1635{ \
1636 return btrfs_get_token_##bits(eb, ptr, off, NULL); \
1637} \
1638static inline void btrfs_set_##bits(struct extent_buffer *eb, void *ptr, \
1639 unsigned long off, u##bits val) \
1640{ \
1641 btrfs_set_token_##bits(eb, ptr, off, val, NULL); \
1642}
1643
1644DECLARE_BTRFS_SETGET_BITS(8)
1645DECLARE_BTRFS_SETGET_BITS(16)
1646DECLARE_BTRFS_SETGET_BITS(32)
1647DECLARE_BTRFS_SETGET_BITS(64)
1648
1627#define BTRFS_SETGET_FUNCS(name, type, member, bits) \ 1649#define BTRFS_SETGET_FUNCS(name, type, member, bits) \
1628u##bits btrfs_##name(struct extent_buffer *eb, type *s); \ 1650static inline u##bits btrfs_##name(struct extent_buffer *eb, type *s) \
1629u##bits btrfs_token_##name(struct extent_buffer *eb, type *s, struct btrfs_map_token *token); \ 1651{ \
1630void btrfs_set_token_##name(struct extent_buffer *eb, type *s, u##bits val, struct btrfs_map_token *token);\ 1652 BUILD_BUG_ON(sizeof(u##bits) != sizeof(((type *)0))->member); \
1631void btrfs_set_##name(struct extent_buffer *eb, type *s, u##bits val); 1653 return btrfs_get_##bits(eb, s, offsetof(type, member)); \
1632#endif 1654} \
1655static inline void btrfs_set_##name(struct extent_buffer *eb, type *s, \
1656 u##bits val) \
1657{ \
1658 BUILD_BUG_ON(sizeof(u##bits) != sizeof(((type *)0))->member); \
1659 btrfs_set_##bits(eb, s, offsetof(type, member), val); \
1660} \
1661static inline u##bits btrfs_token_##name(struct extent_buffer *eb, type *s, \
1662 struct btrfs_map_token *token) \
1663{ \
1664 BUILD_BUG_ON(sizeof(u##bits) != sizeof(((type *)0))->member); \
1665 return btrfs_get_token_##bits(eb, s, offsetof(type, member), token); \
1666} \
1667static inline void btrfs_set_token_##name(struct extent_buffer *eb, \
1668 type *s, u##bits val, \
1669 struct btrfs_map_token *token) \
1670{ \
1671 BUILD_BUG_ON(sizeof(u##bits) != sizeof(((type *)0))->member); \
1672 btrfs_set_token_##bits(eb, s, offsetof(type, member), val, token); \
1673}
1633 1674
1634#define BTRFS_SETGET_HEADER_FUNCS(name, type, member, bits) \ 1675#define BTRFS_SETGET_HEADER_FUNCS(name, type, member, bits) \
1635static inline u##bits btrfs_##name(struct extent_buffer *eb) \ 1676static inline u##bits btrfs_##name(struct extent_buffer *eb) \