aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorZach Brown <zach.brown@oracle.com>2006-02-03 06:03:56 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-02-03 11:32:02 -0500
commit490d6ab170c94a7a59870f528d765131b8963e79 (patch)
tree909deca0ac2476a839b446de382a4866dccf0196 /include
parentbcc68b8616bcac47dbfc414398e382b3b10faf4c (diff)
[PATCH] list.h: don't evaluate macro args multiple times
I noticed that list.h init functions were evaluating macro arguments multiple times and thought it might be nice to protect the unsuspecting caller. Converting the macros to inline functions seems to reduce code size, too. A i386 defconfig build with gcc 3.3.3 from fc4: text data bss dec hex filename 3573148 565664 188828 4327640 4208d8 vmlinux.before 3572177 565664 188828 4326669 42050d vmlinux add/remove: 0/0 grow/shrink: 11/144 up/down: 88/-1016 (-928) There was no difference in checkstack output. Signed-off-by: Zach Brown <zach.brown@oracle.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/list.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/include/linux/list.h b/include/linux/list.h
index 945daa1f13dd..47208bd99f9e 100644
--- a/include/linux/list.h
+++ b/include/linux/list.h
@@ -34,9 +34,11 @@ struct list_head {
34#define LIST_HEAD(name) \ 34#define LIST_HEAD(name) \
35 struct list_head name = LIST_HEAD_INIT(name) 35 struct list_head name = LIST_HEAD_INIT(name)
36 36
37#define INIT_LIST_HEAD(ptr) do { \ 37static inline void INIT_LIST_HEAD(struct list_head *list)
38 (ptr)->next = (ptr); (ptr)->prev = (ptr); \ 38{
39} while (0) 39 list->next = list;
40 list->prev = list;
41}
40 42
41/* 43/*
42 * Insert a new entry between two known consecutive entries. 44 * Insert a new entry between two known consecutive entries.
@@ -534,7 +536,11 @@ struct hlist_node {
534#define HLIST_HEAD_INIT { .first = NULL } 536#define HLIST_HEAD_INIT { .first = NULL }
535#define HLIST_HEAD(name) struct hlist_head name = { .first = NULL } 537#define HLIST_HEAD(name) struct hlist_head name = { .first = NULL }
536#define INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL) 538#define INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL)
537#define INIT_HLIST_NODE(ptr) ((ptr)->next = NULL, (ptr)->pprev = NULL) 539static inline void INIT_HLIST_NODE(struct hlist_node *h)
540{
541 h->next = NULL;
542 h->pprev = NULL;
543}
538 544
539static inline int hlist_unhashed(const struct hlist_node *h) 545static inline int hlist_unhashed(const struct hlist_node *h)
540{ 546{