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>
This commit is contained in:
parent
98c350cda2
commit
f7e1becb07
|
@ -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 {
|
||||||
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 {
|
||||||
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;
|
||||||
|
|
Loading…
Reference in New Issue