35using aio_context_t =
unsigned long;
37enum class iocb_cmd : uint16_t {
55constexpr int IOCB_FLAG_RESFD = 1;
60#if __BYTE_ORDER == __LITTLE_ENDIAN
63#elif __BYTE_ORDER == __BIG_ENDIAN
70 iocb_cmd aio_lio_opcode;
78 uint64_t aio_reserved2;
86 const sigset_t *sigmask;
92linux_abi::iocb make_read_iocb(
int fd, uint64_t offset,
void* buffer,
size_t len);
93linux_abi::iocb make_write_iocb(
int fd, uint64_t offset,
const void* buffer,
size_t len);
94linux_abi::iocb make_readv_iocb(
int fd, uint64_t offset, const ::iovec* iov,
size_t niov);
95linux_abi::iocb make_writev_iocb(
int fd, uint64_t offset, const ::iovec* iov,
size_t niov);
96linux_abi::iocb make_poll_iocb(
int fd, uint32_t events);
98void set_user_data(linux_abi::iocb& iocb,
void* data);
99void set_nowait(linux_abi::iocb& iocb,
bool nowait);
101void set_eventfd_notification(linux_abi::iocb& iocb,
int eventfd);
103linux_abi::iocb* get_iocb(
const linux_abi::io_event& ioev);
105int io_setup(
int nr_events, linux_abi::aio_context_t* io_context);
106int io_destroy(linux_abi::aio_context_t io_context)
noexcept;
107int io_submit(linux_abi::aio_context_t io_context,
long nr, linux_abi::iocb** iocbs);
108int io_cancel(linux_abi::aio_context_t io_context, linux_abi::iocb* iocb, linux_abi::io_event* result);
109int io_getevents(linux_abi::aio_context_t io_context,
long min_nr,
long nr, linux_abi::io_event* events, const ::timespec* timeout,
110 bool force_syscall =
false);
111int io_pgetevents(linux_abi::aio_context_t io_context,
long min_nr,
long nr, linux_abi::io_event* events, const ::timespec* timeout,
const sigset_t* sigmask,
112 bool force_syscall =
false);
114void setup_aio_context(
size_t nr, linux_abi::aio_context_t* io_context);
118extern bool aio_nowait_supported;
124make_read_iocb(
int fd, uint64_t offset,
void* buffer,
size_t len) {
125 linux_abi::iocb iocb{};
126 iocb.aio_lio_opcode = linux_abi::iocb_cmd::PREAD;
127 iocb.aio_fildes = fd;
128 iocb.aio_offset = offset;
129 iocb.aio_buf =
reinterpret_cast<uintptr_t
>(buffer);
130 iocb.aio_nbytes = len;
136make_write_iocb(
int fd, uint64_t offset,
const void* buffer,
size_t len) {
137 linux_abi::iocb iocb{};
138 iocb.aio_lio_opcode = linux_abi::iocb_cmd::PWRITE;
139 iocb.aio_fildes = fd;
140 iocb.aio_offset = offset;
141 iocb.aio_buf =
reinterpret_cast<uintptr_t
>(buffer);
142 iocb.aio_nbytes = len;
148make_readv_iocb(
int fd, uint64_t offset, const ::iovec* iov,
size_t niov) {
149 linux_abi::iocb iocb{};
150 iocb.aio_lio_opcode = linux_abi::iocb_cmd::PREADV;
151 iocb.aio_fildes = fd;
152 iocb.aio_offset = offset;
153 iocb.aio_buf =
reinterpret_cast<uintptr_t
>(iov);
154 iocb.aio_nbytes = niov;
160make_writev_iocb(
int fd, uint64_t offset, const ::iovec* iov,
size_t niov) {
161 linux_abi::iocb iocb{};
162 iocb.aio_lio_opcode = linux_abi::iocb_cmd::PWRITEV;
163 iocb.aio_fildes = fd;
164 iocb.aio_offset = offset;
165 iocb.aio_buf =
reinterpret_cast<uintptr_t
>(iov);
166 iocb.aio_nbytes = niov;
172make_poll_iocb(
int fd, uint32_t events) {
173 linux_abi::iocb iocb{};
174 iocb.aio_lio_opcode = linux_abi::iocb_cmd::POLL;
175 iocb.aio_fildes = fd;
176 iocb.aio_buf = events;
182make_fdsync_iocb(
int fd) {
183 linux_abi::iocb iocb{};
184 iocb.aio_lio_opcode = linux_abi::iocb_cmd::FDSYNC;
185 iocb.aio_fildes = fd;
191set_user_data(linux_abi::iocb& iocb,
void* data) {
192 iocb.aio_data =
reinterpret_cast<uintptr_t
>(data);
196inline T* get_user_data(
const linux_abi::iocb& iocb)
noexcept {
197 return reinterpret_cast<T*
>(uintptr_t(iocb.aio_data));
201inline T* get_user_data(
const linux_abi::io_event& ev)
noexcept {
202 return reinterpret_cast<T*
>(uintptr_t(ev.data));
207set_eventfd_notification(linux_abi::iocb& iocb,
int eventfd) {
208 iocb.aio_flags |= linux_abi::IOCB_FLAG_RESFD;
209 iocb.aio_resfd = eventfd;
214get_iocb(
const linux_abi::io_event& ev) {
215 return reinterpret_cast<linux_abi::iocb*
>(uintptr_t(ev.obj));
220set_nowait(linux_abi::iocb& iocb,
bool nowait) {
222 if (aio_nowait_supported) {
224 iocb.aio_rw_flags |= RWF_NOWAIT;
226 iocb.aio_rw_flags &= ~RWF_NOWAIT;
Seastar API namespace.
Definition: abort_on_ebadf.hh:26