Commit f7e1becb authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

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: default avatarJeff Moyer <jmoyer@redhat.com>
Cc: Joel Becker <jlbec@evilplan.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 98c350cd
...@@ -126,22 +126,20 @@ struct kiocb { ...@@ -126,22 +126,20 @@ struct kiocb {
struct eventfd_ctx *ki_eventfd; struct eventfd_ctx *ki_eventfd;
}; };
#define is_sync_kiocb(iocb) ((iocb)->ki_key == KIOCB_SYNC_KEY) static inline bool is_sync_kiocb(struct kiocb *kiocb)
#define init_sync_kiocb(x, filp) \ {
do { \ return kiocb->ki_key == KIOCB_SYNC_KEY;
struct task_struct *tsk = current; \ }
(x)->ki_flags = 0; \
(x)->ki_users = 1; \ static inline void init_sync_kiocb(struct kiocb *kiocb, struct file *filp)
(x)->ki_key = KIOCB_SYNC_KEY; \ {
(x)->ki_filp = (filp); \ *kiocb = (struct kiocb) {
(x)->ki_ctx = NULL; \ .ki_users = 1,
(x)->ki_cancel = NULL; \ .ki_key = KIOCB_SYNC_KEY,
(x)->ki_retry = NULL; \ .ki_filp = filp,
(x)->ki_dtor = NULL; \ .ki_obj.tsk = current,
(x)->ki_obj.tsk = tsk; \ };
(x)->ki_user_data = 0; \ }
(x)->private = NULL; \
} while (0)
#define AIO_RING_MAGIC 0xa10a10a1 #define AIO_RING_MAGIC 0xa10a10a1
#define AIO_RING_COMPAT_FEATURES 1 #define AIO_RING_COMPAT_FEATURES 1
...@@ -161,8 +159,6 @@ struct aio_ring { ...@@ -161,8 +159,6 @@ struct aio_ring {
struct io_event io_events[0]; struct io_event io_events[0];
}; /* 128 bytes + ring size */ }; /* 128 bytes + ring size */
#define aio_ring_avail(info, ring) (((ring)->head + (info)->nr - 1 - (ring)->tail) % (info)->nr)
#define AIO_RING_PAGES 8 #define AIO_RING_PAGES 8
struct aio_ring_info { struct aio_ring_info {
unsigned long mmap_base; unsigned long mmap_base;
...@@ -177,6 +173,12 @@ struct aio_ring_info { ...@@ -177,6 +173,12 @@ struct aio_ring_info {
struct page *internal_pages[AIO_RING_PAGES]; struct page *internal_pages[AIO_RING_PAGES];
}; };
static inline unsigned aio_ring_avail(struct aio_ring_info *info,
struct aio_ring *ring)
{
return (ring->head + info->nr - 1 - ring->tail) % info->nr;
}
struct kioctx { struct kioctx {
atomic_t users; atomic_t users;
int dead; int dead;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment