diff options
author | Andrew Morton <akpm@linux-foundation.org> | 2012-07-30 17:42:56 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-07-30 20:25:21 -0400 |
commit | f7e1becb078c2b996420a61f2a411ef19335e2da (patch) | |
tree | dd4f700147f69579db0ae79feadcdc7d93e6c942 | |
parent | 98c350cda2c14a343d34ea01a3d9c24fea5ec66d (diff) |
include/linux/aio.h: cpp->C conversions
Convert init_sync_kiocb() from a nasty macro into a nice C function. The
struct assignment trick takes care of zeroing all unmentioned fields.
Shrinks fs/read_write.o's .text from 9857 bytes to 9714.
Also demacroize is_sync_kiocb() and aio_ring_avail(). The latter fixes an
arg-referenced-multiple-times hand grenade.
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Mark Fasheh <mfasheh@suse.com>
Acked-by: Jeff Moyer <jmoyer@redhat.com>
Cc: Joel Becker <jlbec@evilplan.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | include/linux/aio.h | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/include/linux/aio.h b/include/linux/aio.h index b1a520ec8b59..31ff6dba4872 100644 --- a/include/linux/aio.h +++ b/include/linux/aio.h | |||
@@ -126,22 +126,20 @@ struct kiocb { | |||
126 | struct eventfd_ctx *ki_eventfd; | 126 | struct eventfd_ctx *ki_eventfd; |
127 | }; | 127 | }; |
128 | 128 | ||
129 | #define is_sync_kiocb(iocb) ((iocb)->ki_key == KIOCB_SYNC_KEY) | 129 | static inline bool is_sync_kiocb(struct kiocb *kiocb) |
130 | #define init_sync_kiocb(x, filp) \ | 130 | { |
131 | do { \ | 131 | return kiocb->ki_key == KIOCB_SYNC_KEY; |
132 | struct task_struct *tsk = current; \ | 132 | } |
133 | (x)->ki_flags = 0; \ | 133 | |
134 | (x)->ki_users = 1; \ | 134 | static inline void init_sync_kiocb(struct kiocb *kiocb, struct file *filp) |
135 | (x)->ki_key = KIOCB_SYNC_KEY; \ | 135 | { |
136 | (x)->ki_filp = (filp); \ | 136 | *kiocb = (struct kiocb) { |
137 | (x)->ki_ctx = NULL; \ | 137 | .ki_users = 1, |
138 | (x)->ki_cancel = NULL; \ | 138 | .ki_key = KIOCB_SYNC_KEY, |
139 | (x)->ki_retry = NULL; \ | 139 | .ki_filp = filp, |
140 | (x)->ki_dtor = NULL; \ | 140 | .ki_obj.tsk = current, |
141 | (x)->ki_obj.tsk = tsk; \ | 141 | }; |
142 | (x)->ki_user_data = 0; \ | 142 | } |
143 | (x)->private = NULL; \ | ||
144 | } while (0) | ||
145 | 143 | ||
146 | #define AIO_RING_MAGIC 0xa10a10a1 | 144 | #define AIO_RING_MAGIC 0xa10a10a1 |
147 | #define AIO_RING_COMPAT_FEATURES 1 | 145 | #define AIO_RING_COMPAT_FEATURES 1 |
@@ -161,8 +159,6 @@ struct aio_ring { | |||
161 | struct io_event io_events[0]; | 159 | struct io_event io_events[0]; |
162 | }; /* 128 bytes + ring size */ | 160 | }; /* 128 bytes + ring size */ |
163 | 161 | ||
164 | #define aio_ring_avail(info, ring) (((ring)->head + (info)->nr - 1 - (ring)->tail) % (info)->nr) | ||
165 | |||
166 | #define AIO_RING_PAGES 8 | 162 | #define AIO_RING_PAGES 8 |
167 | struct aio_ring_info { | 163 | struct aio_ring_info { |
168 | unsigned long mmap_base; | 164 | unsigned long mmap_base; |
@@ -177,6 +173,12 @@ struct aio_ring_info { | |||
177 | struct page *internal_pages[AIO_RING_PAGES]; | 173 | struct page *internal_pages[AIO_RING_PAGES]; |
178 | }; | 174 | }; |
179 | 175 | ||
176 | static inline unsigned aio_ring_avail(struct aio_ring_info *info, | ||
177 | struct aio_ring *ring) | ||
178 | { | ||
179 | return (ring->head + info->nr - 1 - ring->tail) % info->nr; | ||
180 | } | ||
181 | |||
180 | struct kioctx { | 182 | struct kioctx { |
181 | atomic_t users; | 183 | atomic_t users; |
182 | int dead; | 184 | int dead; |