25class BundledProvidedBufferQueue;
26class BundledProvidedBufferPool;
33template <FdLike Fd1, FdLike Fd2>
34inline auto async_splice(Fd1 fd_in, int64_t off_in, Fd2 fd_out, int64_t off_out,
35 unsigned int nbytes,
unsigned int splice_flags) {
36 if constexpr (detail::is_fixed_fd_v<Fd1>) {
37 splice_flags |= SPLICE_F_FD_IN_FIXED;
39 auto op = detail::make_op_awaiter(io_uring_prep_splice, fd_in, off_in,
40 fd_out, off_out, nbytes, splice_flags);
41 return detail::maybe_flag_fixed_fd(std::move(op), fd_out);
47template <FdLike Fd1, FdLike Fd2>
48inline auto async_tee(Fd1 fd_in, Fd2 fd_out,
unsigned int nbytes,
49 unsigned int splice_flags) {
50 if constexpr (detail::is_fixed_fd_v<Fd1>) {
51 splice_flags |= SPLICE_F_FD_IN_FIXED;
53 auto op = detail::make_op_awaiter(io_uring_prep_tee, fd_in, fd_out, nbytes,
55 return detail::maybe_flag_fixed_fd(std::move(op), fd_out);
62inline auto async_readv(Fd fd,
const struct iovec *iovecs,
unsigned nr_vecs,
63 __u64 offset,
int flags) {
64 auto op = detail::make_op_awaiter(io_uring_prep_readv2, fd, iovecs, nr_vecs,
66 return detail::maybe_flag_fixed_fd(std::move(op), fd);
69#if CONDY_URING_VERSION_GE(2, 10)
74inline auto async_readv(Fd fd, detail::FixedBuffer<const iovec *> iovecs,
75 unsigned nr_vecs, __u64 offset,
int flags) {
77 detail::make_op_awaiter(io_uring_prep_readv_fixed, fd, iovecs.value,
78 nr_vecs, offset, flags, iovecs.buf_index);
79 return detail::maybe_flag_fixed_fd(std::move(op), fd);
88 unsigned int nr_vecs, __u64 offset,
int flags) {
89 auto op = detail::make_op_awaiter(io_uring_prep_writev2, fd, iovecs,
90 nr_vecs, offset, flags);
91 return detail::maybe_flag_fixed_fd(std::move(op), fd);
94#if CONDY_URING_VERSION_GE(2, 10)
99inline auto async_writev(Fd fd, detail::FixedBuffer<const iovec *> iovecs,
100 unsigned int nr_vecs, __u64 offset,
int flags) {
102 detail::make_op_awaiter(io_uring_prep_writev_fixed, fd, iovecs.value,
103 nr_vecs, offset, flags, iovecs.buf_index);
104 return detail::maybe_flag_fixed_fd(std::move(op), fd);
113 auto op = detail::make_op_awaiter(io_uring_prep_recvmsg, fd, msg, flags);
114 return detail::maybe_flag_fixed_fd(std::move(op), fd);
120template <FdLike Fd,
typename MultiShotFunc,
121 AnySameAs<ProvidedBufferQueue, ProvidedBufferPool> Buffer>
123 Buffer &buf, MultiShotFunc &&func) {
124 auto op = detail::make_multishot_select_buffer_op_awaiter(
125 std::forward<MultiShotFunc>(func), &buf,
126 io_uring_prep_recvmsg_multishot, fd, msg, flags);
127 return detail::maybe_flag_fixed_fd(std::move(op), fd);
135 auto op = detail::make_op_awaiter(io_uring_prep_sendmsg, fd, msg, flags);
136 return detail::maybe_flag_fixed_fd(std::move(op), fd);
142template <FdLike Fd,
typename FreeFunc>
145 auto op = detail::make_zero_copy_op_awaiter(
146 std::forward<FreeFunc>(func), io_uring_prep_sendmsg_zc, fd, msg, flags);
147 return detail::maybe_flag_fixed_fd(std::move(op), fd);
150#if CONDY_URING_VERSION_GE(2, 10)
154template <FdLike Fd,
typename FreeFunc>
156 unsigned flags, FreeFunc &&func) {
157 auto op = detail::make_zero_copy_op_awaiter(
158 std::forward<FreeFunc>(func), io_uring_prep_sendmsg_zc_fixed, fd,
159 msg.value, flags, msg.buf_index);
160 return detail::maybe_flag_fixed_fd(std::move(op), fd);
167template <FdLike Fd>
inline auto async_fsync(Fd fd,
unsigned fsync_flags) {
168 auto op = detail::make_op_awaiter(io_uring_prep_fsync, fd, fsync_flags);
169 return detail::maybe_flag_fixed_fd(std::move(op), fd);
175inline auto async_nop() {
return detail::make_op_awaiter(io_uring_prep_nop); }
177#if CONDY_URING_VERSION_GE(2, 13)
181inline auto async_nop128() {
182 return detail::make_op_awaiter128(io_uring_prep_nop128);
191 return detail::make_op_awaiter(io_uring_prep_timeout, ts, count, flags);
194#if CONDY_URING_VERSION_GE(2, 4)
199template <
typename MultiShotFunc>
200inline auto async_timeout_multishot(
struct __kernel_timespec *ts,
201 unsigned count,
unsigned flags,
202 MultiShotFunc &&func) {
203 return detail::make_multishot_op_awaiter(std::forward<MultiShotFunc>(func),
204 io_uring_prep_timeout, ts, count,
205 flags | IORING_TIMEOUT_MULTISHOT);
213inline auto async_accept(Fd fd,
struct sockaddr *addr, socklen_t *addrlen,
216 detail::make_op_awaiter(io_uring_prep_accept, fd, addr, addrlen, flags);
217 return detail::maybe_flag_fixed_fd(std::move(op), fd);
225 socklen_t *addrlen,
int flags,
226 unsigned int file_index) {
227 auto op = detail::make_op_awaiter(io_uring_prep_accept_direct, fd, addr,
228 addrlen, flags, file_index);
229 return detail::maybe_flag_fixed_fd(std::move(op), fd);
235template <FdLike Fd,
typename MultiShotFunc>
237 socklen_t *addrlen,
int flags,
238 MultiShotFunc &&func) {
239 auto op = detail::make_multishot_op_awaiter(
240 std::forward<MultiShotFunc>(func), io_uring_prep_multishot_accept, fd,
241 addr, addrlen, flags);
242 return detail::maybe_flag_fixed_fd(std::move(op), fd);
248template <FdLike Fd,
typename MultiShotFunc>
250 socklen_t *addrlen,
int flags,
251 MultiShotFunc &&func) {
252 auto op = detail::make_multishot_op_awaiter(
253 std::forward<MultiShotFunc>(func),
254 io_uring_prep_multishot_accept_direct, fd, addr, addrlen, flags);
255 return detail::maybe_flag_fixed_fd(std::move(op), fd);
262 if constexpr (detail::is_fixed_fd_v<Fd>) {
263 flags |= IORING_ASYNC_CANCEL_FD_FIXED;
265 return detail::make_op_awaiter(io_uring_prep_cancel_fd, fd, flags);
272 return detail::make_op_awaiter(io_uring_prep_link_timeout, ts, flags);
281 auto op = detail::make_op_awaiter(io_uring_prep_connect, fd, addr, addrlen);
282 return detail::maybe_flag_fixed_fd(std::move(op), fd);
289 return detail::make_op_awaiter(io_uring_prep_files_update, fds, nr_fds,
299 detail::make_op_awaiter(io_uring_prep_fallocate, fd, mode, offset, len);
300 return detail::maybe_flag_fixed_fd(std::move(op), fd);
306inline auto async_openat(
int dfd,
const char *path,
int flags, mode_t mode) {
307 return detail::make_op_awaiter(io_uring_prep_openat, dfd, path, flags,
315 mode_t mode,
unsigned file_index) {
316 return detail::make_op_awaiter(io_uring_prep_openat_direct, dfd, path,
317 flags, mode, file_index);
323inline auto async_open(
const char *path,
int flags, mode_t mode) {
331 unsigned file_index) {
339 return detail::make_op_awaiter(io_uring_prep_close, fd);
346 return detail::make_op_awaiter(io_uring_prep_close_direct, fd);
352template <FdLike Fd, BufferLike Buffer>
353inline auto async_read(Fd fd,
const Buffer &buf, __u64 offset,
int flags = 0) {
354 auto op = detail::make_op_awaiter(detail::prep_read, fd, buf.data(),
355 buf.size(), offset, flags);
356 return detail::maybe_flag_fixed_fd(std::move(op), fd);
362template <FdLike Fd, BufferLike Buffer>
363inline auto async_read(Fd fd, detail::FixedBuffer<Buffer> buf, __u64 offset,
366 detail::make_op_awaiter(detail::prep_read_fixed, fd, buf.value.data(),
367 buf.value.size(), offset, flags, buf.buf_index);
368 return detail::maybe_flag_fixed_fd(std::move(op), fd);
374template <FdLike Fd, AnySameAs<Prov
idedBufferQueue, Prov
idedBufferPool> Buffer>
376 auto op = detail::make_select_buffer_op_awaiter(&buf, io_uring_prep_read,
377 fd,
nullptr, 0, offset);
378 return detail::maybe_flag_fixed_fd(std::move(op), fd);
381#if CONDY_URING_VERSION_GE(2, 6)
385template <FdLike Fd, AnySameAs<Prov
idedBufferQueue, Prov
idedBufferPool> Buffer,
386 typename MultiShotFunc>
387inline auto async_read_multishot(Fd fd, Buffer &buf, __u64 offset,
388 MultiShotFunc &&func) {
389 auto op = detail::make_multishot_select_buffer_op_awaiter(
390 std::forward<MultiShotFunc>(func), &buf, io_uring_prep_read_multishot,
391 fd, 0, offset, buf.bgid());
392 return detail::maybe_flag_fixed_fd(std::move(op), fd);
399template <FdLike Fd, BufferLike Buffer>
400inline auto async_write(Fd fd,
const Buffer &buf, __u64 offset,
int flags = 0) {
401 auto op = detail::make_op_awaiter(detail::prep_write, fd, buf.data(),
402 buf.size(), offset, flags);
403 return detail::maybe_flag_fixed_fd(std::move(op), fd);
409template <FdLike Fd, BufferLike Buffer>
410inline auto async_write(Fd fd, detail::FixedBuffer<Buffer> buf, __u64 offset,
413 detail::make_op_awaiter(detail::prep_write_fixed, fd, buf.value.data(),
414 buf.value.size(), offset, flags, buf.buf_index);
415 return detail::maybe_flag_fixed_fd(std::move(op), fd);
421inline auto async_statx(
int dfd,
const char *path,
int flags,
unsigned mask,
422 struct statx *statxbuf) {
423 return detail::make_op_awaiter(io_uring_prep_statx, dfd, path, flags, mask,
433 detail::make_op_awaiter(io_uring_prep_fadvise, fd, offset, len, advice);
434 return detail::maybe_flag_fixed_fd(std::move(op), fd);
437#if CONDY_URING_VERSION_GE(2, 7)
442inline auto async_fadvise64(Fd fd, __u64 offset, off_t len,
int advice) {
443 auto op = detail::make_op_awaiter(io_uring_prep_fadvise64, fd, offset, len,
445 return detail::maybe_flag_fixed_fd(std::move(op), fd);
453 return detail::make_op_awaiter(io_uring_prep_madvise, addr, length, advice);
456#if CONDY_URING_VERSION_GE(2, 7)
460inline auto async_madvise64(
void *addr, off_t length,
int advice) {
462 detail::make_op_awaiter(io_uring_prep_madvise64, addr, length, advice);
470template <FdLike Fd, BufferLike Buffer>
471inline auto async_send(Fd sockfd,
const Buffer &buf,
int flags) {
472 auto op = detail::make_op_awaiter(io_uring_prep_send, sockfd, buf.data(),
474 return detail::maybe_flag_fixed_fd(std::move(op), sockfd);
480template <FdLike Fd, BufferLike Buffer>
481inline auto async_send(Fd sockfd, detail::FixedBuffer<Buffer> buf,
int flags) {
482 auto op = detail::make_op_awaiter(detail::prep_send_fixed, sockfd,
483 buf.value.data(), buf.value.size(), flags,
485 return detail::maybe_flag_fixed_fd(std::move(op), sockfd);
493 auto op = detail::make_select_buffer_op_awaiter(&buf, io_uring_prep_send,
494 sockfd,
nullptr, 0, flags);
495 return detail::maybe_flag_fixed_fd(std::move(op), sockfd);
498#if CONDY_URING_VERSION_GE(2, 7)
503inline auto async_send(Fd sockfd, detail::BundledProvidedBufferQueue &buf,
505 auto op = detail::make_bundle_select_buffer_op_awaiter(
506 &buf, io_uring_prep_send, sockfd,
nullptr, 0, flags);
507 return detail::maybe_flag_fixed_fd(std::move(op), sockfd);
514template <FdLike Fd, BufferLike Buffer>
516 const struct sockaddr *addr, socklen_t addrlen) {
517 auto op = detail::make_op_awaiter(detail::prep_sendto, sockfd, buf.data(),
518 buf.size(), flags, addr, addrlen);
519 return detail::maybe_flag_fixed_fd(std::move(op), sockfd);
525template <FdLike Fd, BufferLike Buffer>
526inline auto async_sendto(Fd sockfd, detail::FixedBuffer<Buffer> buf,
int flags,
527 const struct sockaddr *addr, socklen_t addrlen) {
528 auto op = detail::make_op_awaiter(detail::prep_sendto_fixed, sockfd,
529 buf.value.data(), buf.value.size(), flags,
530 addr, addrlen, buf.buf_index);
531 return detail::maybe_flag_fixed_fd(std::move(op), sockfd);
539 const struct sockaddr *addr, socklen_t addrlen) {
540 auto op = detail::make_select_buffer_op_awaiter(
541 &buf, detail::prep_sendto, sockfd,
nullptr, 0, flags, addr, addrlen);
542 return detail::maybe_flag_fixed_fd(std::move(op), sockfd);
545#if CONDY_URING_VERSION_GE(2, 7)
550inline auto async_sendto(Fd sockfd, detail::BundledProvidedBufferQueue &buf,
551 int flags,
const struct sockaddr *addr,
553 auto op = detail::make_bundle_select_buffer_op_awaiter(
554 &buf, detail::prep_sendto, sockfd,
nullptr, 0, flags, addr, addrlen);
555 return detail::maybe_flag_fixed_fd(std::move(op), sockfd);
562template <FdLike Fd,
typename Buffer,
typename FreeFunc>
564 unsigned zc_flags, FreeFunc &&func) {
565 auto op = detail::make_zero_copy_op_awaiter(
566 std::forward<FreeFunc>(func), io_uring_prep_send_zc, sockfd, buf.data(),
567 buf.size(), flags, zc_flags);
568 return detail::maybe_flag_fixed_fd(std::move(op), sockfd);
574template <FdLike Fd, BufferLike Buffer,
typename FreeFunc>
575inline auto async_send_zc(Fd sockfd, detail::FixedBuffer<Buffer> buf,
int flags,
576 unsigned zc_flags, FreeFunc &&func) {
577 auto op = detail::make_zero_copy_op_awaiter(
578 std::forward<FreeFunc>(func), io_uring_prep_send_zc_fixed, sockfd,
579 buf.value.data(), buf.value.size(), flags, zc_flags, buf.buf_index);
580 return detail::maybe_flag_fixed_fd(std::move(op), sockfd);
586template <FdLike Fd, BufferLike Buffer,
typename FreeFunc>
588 const struct sockaddr *addr, socklen_t addrlen,
589 unsigned zc_flags, FreeFunc &&func) {
590 auto op = detail::make_zero_copy_op_awaiter(
591 std::forward<FreeFunc>(func), detail::prep_sendto_zc, sockfd,
592 buf.data(), buf.size(), flags, addr, addrlen, zc_flags);
593 return detail::maybe_flag_fixed_fd(std::move(op), sockfd);
599template <FdLike Fd, BufferLike Buffer,
typename FreeFunc>
601 int flags,
const struct sockaddr *addr,
602 socklen_t addrlen,
unsigned zc_flags,
604 auto op = detail::make_zero_copy_op_awaiter(
605 std::forward<FreeFunc>(func), detail::prep_sendto_zc_fixed, sockfd,
606 buf.value.data(), buf.value.size(), flags, addr, addrlen, zc_flags,
608 return detail::maybe_flag_fixed_fd(std::move(op), sockfd);
614template <FdLike Fd, BufferLike Buffer>
615inline auto async_recv(Fd sockfd,
const Buffer &buf,
int flags) {
616 auto op = detail::make_op_awaiter(io_uring_prep_recv, sockfd, buf.data(),
618 return detail::maybe_flag_fixed_fd(std::move(op), sockfd);
624template <FdLike Fd, BufferLike Buffer>
625inline auto async_recv(Fd sockfd, detail::FixedBuffer<Buffer> buf,
int flags) {
626 auto op = detail::make_op_awaiter(detail::prep_recv_fixed, sockfd,
627 buf.value.data(), buf.value.size(), flags,
629 return detail::maybe_flag_fixed_fd(std::move(op), sockfd);
635template <FdLike Fd, AnySameAs<Prov
idedBufferQueue, Prov
idedBufferPool> Buffer>
637 auto op = detail::make_select_buffer_op_awaiter(&buf, io_uring_prep_recv,
638 sockfd,
nullptr, 0, flags);
639 return detail::maybe_flag_fixed_fd(std::move(op), sockfd);
642#if CONDY_URING_VERSION_GE(2, 7)
646template <FdLike Fd, AnySameAs<detail::BundledProvidedBufferQueue,
647 detail::BundledProvidedBufferPool>
649inline auto async_recv(Fd sockfd, Buffer &buf,
int flags) {
650 auto op = detail::make_bundle_select_buffer_op_awaiter(
651 &buf, io_uring_prep_recv, sockfd,
nullptr, 0, flags);
652 return detail::maybe_flag_fixed_fd(std::move(op), sockfd);
659template <FdLike Fd, AnySameAs<Prov
idedBufferQueue, Prov
idedBufferPool> Buffer,
660 typename MultiShotFunc>
662 MultiShotFunc &&func) {
663 auto op = detail::make_multishot_select_buffer_op_awaiter(
664 std::forward<MultiShotFunc>(func), &buf, io_uring_prep_recv_multishot,
665 sockfd,
nullptr, 0, flags);
666 return detail::maybe_flag_fixed_fd(std::move(op), sockfd);
669#if CONDY_URING_VERSION_GE(2, 7)
674 AnySameAs<detail::BundledProvidedBufferQueue,
675 detail::BundledProvidedBufferPool>
677 typename MultiShotFunc>
679 MultiShotFunc &&func) {
680 auto op = detail::make_multishot_bundle_select_buffer_op_awaiter(
681 std::forward<MultiShotFunc>(func), &buf, io_uring_prep_recv_multishot,
682 sockfd,
nullptr, 0, flags);
683 return detail::maybe_flag_fixed_fd(std::move(op), sockfd);
687#if CONDY_URING_VERSION_GE(2, 15)
691template <FdLike Fd,
typename MultiShotFunc>
693 [[maybe_unused]]
int flags,
694 MultiShotFunc &&func) {
695 auto zcrx_id = pool.zcrx_id();
696 auto prep_func = [=](detail::Ring *ring) {
697 auto *sqe = ring->get_sqe();
698 detail::prep_recv_zc_multishot(sqe, sockfd, zcrx_id);
702 std::move(prep_func),
704 std::forward<MultiShotFunc>(func));
705 return detail::maybe_flag_fixed_fd(std::move(op), sockfd);
713 return detail::make_op_awaiter(io_uring_prep_openat2, dfd, path, how);
720 struct open_how *how,
unsigned file_index) {
721 return detail::make_op_awaiter(io_uring_prep_openat2_direct, dfd, path, how,
729 auto op = detail::make_op_awaiter(io_uring_prep_shutdown, fd, how);
730 return detail::maybe_flag_fixed_fd(std::move(op), fd);
737 return detail::make_op_awaiter(io_uring_prep_unlinkat, dfd, path, flags);
751 const char *newpath,
unsigned int flags) {
752 return detail::make_op_awaiter(io_uring_prep_renameat, olddfd, oldpath,
753 newdfd, newpath, flags);
769 auto op = detail::make_op_awaiter(io_uring_prep_sync_file_range, fd, len,
771 return detail::maybe_flag_fixed_fd(std::move(op), fd);
778 return detail::make_op_awaiter(io_uring_prep_mkdirat, dfd, path, mode);
792 const char *linkpath) {
793 return detail::make_op_awaiter(io_uring_prep_symlinkat, target, newdirfd,
808 const char *newpath,
int flags) {
809 return detail::make_op_awaiter(io_uring_prep_linkat, olddfd, oldpath,
810 newdfd, newpath, flags);
816inline auto async_link(
const char *oldpath,
const char *newpath,
int flags) {
817 return async_linkat(AT_FDCWD, oldpath, AT_FDCWD, newpath, flags);
825 return detail::make_op_awaiter(io_uring_prep_getxattr, name, value, path,
833 const char *path,
int flags,
unsigned int len) {
834 return detail::make_op_awaiter(io_uring_prep_setxattr, name, value, path,
843 return detail::make_op_awaiter(io_uring_prep_fgetxattr, fd, name, value,
851 int flags,
unsigned int len) {
852 return detail::make_op_awaiter(io_uring_prep_fsetxattr, fd, name, value,
860 unsigned int flags) {
861 return detail::make_op_awaiter(io_uring_prep_socket, domain, type, protocol,
869 unsigned file_index,
unsigned int flags) {
870 return detail::make_op_awaiter(io_uring_prep_socket_direct, domain, type,
871 protocol, file_index, flags);
882template <CQEHandlerLike CQEHandler = SimpleCQEHandler, FdLike Fd,
883 typename CmdFunc,
typename... Args>
884[[deprecated]]
inline auto
887 CQEHandler(std::forward<Args>(handler_args)...));
896template <FdLike Fd,
typename CmdFunc, CQEHandlerLike CQEHandler>
898 CQEHandler &&cqe_handler) {
899 auto prep_func = [cmd_op, fd = detail::unwrap_fixed(fd),
901 std::forward<CmdFunc>(cmd_func)](detail::Ring *ring) {
902 auto *sqe = ring->get_sqe();
903 io_uring_prep_uring_cmd(sqe, cmd_op, fd);
908 std::forward<CQEHandler>(cqe_handler));
909 return detail::maybe_flag_fixed_fd(std::move(op), fd);
921template <CQEHandlerLike CQEHandler = SimpleCQEHandler, FdLike Fd,
922 typename CmdFunc,
typename MultiShotFunc,
typename... Args>
923[[deprecated]]
inline auto
925 MultiShotFunc &&func, Args &&...handler_args) {
927 cmd_op, fd, std::forward<CmdFunc>(cmd_func),
928 CQEHandler(std::forward<Args>(handler_args)...),
929 std::forward<MultiShotFunc>(func));
939template <FdLike Fd,
typename CmdFunc, CQEHandlerLike CQEHandler,
940 typename MultiShotFunc>
942 CQEHandler &&cqe_handler,
943 MultiShotFunc &&func) {
944 auto prep_func = [cmd_op, fd = detail::unwrap_fixed(fd),
946 std::forward<CmdFunc>(cmd_func)](detail::Ring *ring) {
947 auto *sqe = ring->get_sqe();
948 io_uring_prep_uring_cmd(sqe, cmd_op, fd);
953 std::forward<CQEHandler>(cqe_handler),
954 std::forward<MultiShotFunc>(func));
955 return detail::maybe_flag_fixed_fd(std::move(op), fd);
958#if CONDY_URING_VERSION_GE(2, 13)
967template <CQEHandlerLike CQEHandler = SimpleCQEHandler, FdLike Fd,
968 typename CmdFunc,
typename... Args>
969[[deprecated]]
inline auto async_uring_cmd128(
int cmd_op, Fd fd,
971 Args &&...handler_args) {
972 return async_uring_cmd128(cmd_op, fd, std::forward<CmdFunc>(cmd_func),
973 CQEHandler(std::forward<Args>(handler_args)...));
982template <FdLike Fd,
typename CmdFunc, CQEHandlerLike CQEHandler>
983inline auto async_uring_cmd128(
int cmd_op, Fd fd, CmdFunc &&cmd_func,
984 CQEHandler &&cqe_handler) {
985 auto prep_func = [cmd_op, fd = detail::unwrap_fixed(fd),
987 std::forward<CmdFunc>(cmd_func)](detail::Ring *ring) {
988 auto *sqe = ring->get_sqe128();
990 io_uring_prep_uring_cmd128(sqe, cmd_op, fd);
996 std::forward<CQEHandler>(cqe_handler));
997 return detail::maybe_flag_fixed_fd(std::move(op), fd);
1001#if CONDY_URING_VERSION_GE(2, 5)
1006inline auto async_cmd_sock(
int cmd_op, Fd fd,
int level,
int optname,
1007 void *optval,
int optlen) {
1008 auto op = detail::make_op_awaiter(io_uring_prep_cmd_sock, cmd_op, fd, level,
1009 optname, optval, optlen);
1010 return detail::maybe_flag_fixed_fd(std::move(op), fd);
1014#if CONDY_URING_VERSION_GE(2, 13)
1019inline auto async_cmd_getsockname(Fd fd,
struct sockaddr *sockaddr,
1020 socklen_t *sockaddr_len,
int peer) {
1021 auto op = detail::make_op_awaiter(io_uring_prep_cmd_getsockname, fd,
1022 sockaddr, sockaddr_len, peer);
1023 return detail::maybe_flag_fixed_fd(std::move(op), fd);
1027#if CONDY_URING_VERSION_GE(2, 6)
1031inline auto async_waitid(idtype_t idtype, id_t
id, siginfo_t *infop,
1032 int options,
unsigned int flags) {
1033 return detail::make_op_awaiter(io_uring_prep_waitid, idtype,
id, infop,
1038#if CONDY_URING_VERSION_GE(2, 6)
1042inline auto async_futex_wake(uint32_t *futex, uint64_t val, uint64_t mask,
1043 uint32_t futex_flags,
unsigned int flags) {
1044 return detail::make_op_awaiter(io_uring_prep_futex_wake, futex, val, mask,
1045 futex_flags, flags);
1049#if CONDY_URING_VERSION_GE(2, 6)
1053inline auto async_futex_wait(uint32_t *futex, uint64_t val, uint64_t mask,
1054 uint32_t futex_flags,
unsigned int flags) {
1055 return detail::make_op_awaiter(io_uring_prep_futex_wait, futex, val, mask,
1056 futex_flags, flags);
1060#if CONDY_URING_VERSION_GE(2, 6)
1064inline auto async_futex_waitv(
struct futex_waitv *futex, uint32_t nr_futex,
1065 unsigned int flags) {
1066 return detail::make_op_awaiter(io_uring_prep_futex_waitv, futex, nr_futex,
1071#if CONDY_URING_VERSION_GE(2, 6)
1075inline auto async_fixed_fd_install(
int fixed_fd,
unsigned int flags) {
1076 return detail::make_op_awaiter(io_uring_prep_fixed_fd_install, fixed_fd,
1081#if CONDY_URING_VERSION_GE(2, 6)
1085template <FdLike Fd>
inline auto async_ftruncate(Fd fd, loff_t len) {
1086 auto op = detail::make_op_awaiter(io_uring_prep_ftruncate, fd, len);
1087 return detail::maybe_flag_fixed_fd(std::move(op), fd);
1091#if CONDY_URING_VERSION_GE(2, 8)
1096inline auto async_cmd_discard(Fd fd, uint64_t offset, uint64_t nbytes) {
1098 detail::make_op_awaiter(io_uring_prep_cmd_discard, fd, offset, nbytes);
1099 return detail::maybe_flag_fixed_fd(std::move(op), fd);
1103#if CONDY_URING_VERSION_GE(2, 7)
1108inline auto async_bind(Fd fd,
struct sockaddr *addr, socklen_t addrlen) {
1109 auto op = detail::make_op_awaiter(io_uring_prep_bind, fd, addr, addrlen);
1110 return detail::maybe_flag_fixed_fd(std::move(op), fd);
1114#if CONDY_URING_VERSION_GE(2, 7)
1118template <FdLike Fd>
inline auto async_listen(Fd fd,
int backlog) {
1119 auto op = detail::make_op_awaiter(io_uring_prep_listen, fd, backlog);
1120 return detail::maybe_flag_fixed_fd(std::move(op), fd);
1128 return detail::make_op_awaiter(io_uring_prep_epoll_ctl, epfd, fd, op, ev);
1131#if CONDY_URING_VERSION_GE(2, 10)
1135inline auto async_epoll_wait(
int fd,
struct epoll_event *events,
int maxevents,
1137 return detail::make_op_awaiter(io_uring_prep_epoll_wait, fd, events,
1142#if CONDY_URING_VERSION_GE(2, 12)
1146inline auto async_pipe(
int *fds,
int pipe_flags) {
1147 return detail::make_op_awaiter(io_uring_prep_pipe, fds, pipe_flags);
1151#if CONDY_URING_VERSION_GE(2, 12)
1155inline auto async_pipe_direct(
int *fds,
int pipe_flags,
1156 unsigned int file_index) {
1157 return detail::make_op_awaiter(io_uring_prep_pipe_direct, fds, pipe_flags,
Helper functions for composing asynchronous operations.
A CQE handler that returns the selected buffers based on the result of the CQE.
Definitions of asynchronous operations.
Helper functions for asynchronous operations.
The main namespace for the Condy library.
auto async_symlinkat(const char *target, int newdirfd, const char *linkpath)
See io_uring_prep_symlinkat.
auto async_splice(Fd1 fd_in, int64_t off_in, Fd2 fd_out, int64_t off_out, unsigned int nbytes, unsigned int splice_flags)
See io_uring_prep_splice.
auto async_read(Fd fd, const Buffer &buf, __u64 offset, int flags=0)
See io_uring_prep_read.
auto async_sendto(Fd sockfd, const Buffer &buf, int flags, const struct sockaddr *addr, socklen_t addrlen)
See io_uring_prep_send and io_uring_prep_send_set_addr.
auto async_fsetxattr(int fd, const char *name, const char *value, int flags, unsigned int len)
See io_uring_prep_fsetxattr.
auto async_fadvise(Fd fd, __u64 offset, off_t len, int advice)
See io_uring_prep_fadvise.
auto async_writev(Fd fd, const struct iovec *iovecs, unsigned int nr_vecs, __u64 offset, int flags)
See io_uring_prep_writev2.
auto async_socket_direct(int domain, int type, int protocol, unsigned file_index, unsigned int flags)
See io_uring_prep_socket_direct.
auto async_fsync(Fd fd, unsigned fsync_flags)
See io_uring_prep_fsync.
auto async_recvmsg(Fd fd, struct msghdr *msg, unsigned flags)
See io_uring_prep_recvmsg.
auto async_openat2(int dfd, const char *path, struct open_how *how)
See io_uring_prep_openat2.
auto async_open_direct(const char *path, int flags, mode_t mode, unsigned file_index)
See io_uring_prep_openat_direct.
auto async_getxattr(const char *name, char *value, const char *path, unsigned int len)
See io_uring_prep_getxattr.
auto async_unlinkat(int dfd, const char *path, int flags)
See io_uring_prep_unlinkat.
auto async_openat_direct(int dfd, const char *path, int flags, mode_t mode, unsigned file_index)
See io_uring_prep_openat_direct.
auto async_epoll_ctl(int epfd, int fd, int op, struct epoll_event *ev)
See io_uring_prep_epoll_ctl.
auto async_mkdir(const char *path, mode_t mode)
See io_uring_prep_mkdirat.
auto async_fgetxattr(int fd, const char *name, char *value, unsigned int len)
See io_uring_prep_fgetxattr.
auto async_statx(int dfd, const char *path, int flags, unsigned mask, struct statx *statxbuf)
See io_uring_prep_statx.
auto async_send_zc(Fd sockfd, const Buffer &buf, int flags, unsigned zc_flags, FreeFunc &&func)
See io_uring_prep_send_zc.
auto async_link(const char *oldpath, const char *newpath, int flags)
See io_uring_prep_linkat.
auto async_multishot_accept_direct(Fd fd, struct sockaddr *addr, socklen_t *addrlen, int flags, MultiShotFunc &&func)
See io_uring_prep_multishot_accept_direct.
auto async_recv_multishot(Fd sockfd, Buffer &buf, int flags, MultiShotFunc &&func)
See io_uring_prep_recv_multishot.
auto async_multishot_accept(Fd fd, struct sockaddr *addr, socklen_t *addrlen, int flags, MultiShotFunc &&func)
See io_uring_prep_multishot_accept.
auto async_fallocate(Fd fd, int mode, __u64 offset, __u64 len)
See io_uring_prep_fallocate.
auto async_madvise(void *addr, __u32 length, int advice)
See io_uring_prep_madvise.
auto async_symlink(const char *target, const char *linkpath)
See io_uring_prep_symlinkat.
auto async_sync_file_range(Fd fd, unsigned len, __u64 offset, int flags)
See io_uring_prep_sync_file_range.
auto async_connect(Fd fd, const struct sockaddr *addr, socklen_t addrlen)
See io_uring_prep_connect.
auto async_files_update(int *fds, unsigned nr_fds, int offset)
See io_uring_prep_files_update.
auto build_op_awaiter(PrepFunc &&func, CQEHandler &&cqe_handler)
Build a single-shot operation awaiter with custom CQE handler.
auto async_tee(Fd1 fd_in, Fd2 fd_out, unsigned int nbytes, unsigned int splice_flags)
See io_uring_prep_tee.
auto async_send(Fd sockfd, const Buffer &buf, int flags)
See io_uring_prep_send.
auto async_recvmsg_multishot(Fd fd, struct msghdr *msg, unsigned flags, Buffer &buf, MultiShotFunc &&func)
See io_uring_prep_recvmsg_multishot.
auto async_write(Fd fd, const Buffer &buf, __u64 offset, int flags=0)
See io_uring_prep_write.
auto async_sendmsg(Fd fd, const struct msghdr *msg, unsigned flags)
See io_uring_prep_sendmsg.
auto async_cancel_fd(Fd fd, unsigned int flags)
See io_uring_prep_cancel_fd.
auto async_recv(Fd sockfd, const Buffer &buf, int flags)
See io_uring_prep_recv.
auto async_link_timeout(struct __kernel_timespec *ts, unsigned flags)
See io_uring_prep_link_timeout.
auto async_nop()
See io_uring_prep_nop.
auto async_sendmsg_zc(Fd fd, const struct msghdr *msg, unsigned flags, FreeFunc &&func)
See io_uring_prep_sendmsg_zc.
auto async_close(int fd)
See io_uring_prep_close.
auto async_uring_cmd_multishot(int cmd_op, Fd fd, CmdFunc &&cmd_func, MultiShotFunc &&func, Args &&...handler_args)
See io_uring_prep_uring_cmd.
auto async_sendto_zc(Fd sockfd, const Buffer &buf, int flags, const struct sockaddr *addr, socklen_t addrlen, unsigned zc_flags, FreeFunc &&func)
See io_uring_prep_send_zc and io_uring_prep_send_set_addr.
auto async_open(const char *path, int flags, mode_t mode)
See io_uring_prep_openat.
auto async_renameat(int olddfd, const char *oldpath, int newdfd, const char *newpath, unsigned int flags)
See io_uring_prep_renameat.
auto async_accept_direct(Fd fd, struct sockaddr *addr, socklen_t *addrlen, int flags, unsigned int file_index)
See io_uring_prep_accept_direct.
auto async_timeout(struct __kernel_timespec *ts, unsigned count, unsigned flags)
See io_uring_prep_timeout.
auto async_rename(const char *oldpath, const char *newpath)
See io_uring_prep_renameat.
auto async_setxattr(const char *name, const char *value, const char *path, int flags, unsigned int len)
See io_uring_prep_setxattr.
auto async_openat2_direct(int dfd, const char *path, struct open_how *how, unsigned file_index)
See io_uring_prep_openat2_direct.
auto async_unlink(const char *path, int flags)
See io_uring_prep_unlinkat.
auto async_accept(Fd fd, struct sockaddr *addr, socklen_t *addrlen, int flags)
See io_uring_prep_accept.
auto async_mkdirat(int dfd, const char *path, mode_t mode)
See io_uring_prep_mkdirat.
auto build_multishot_op_awaiter(PrepFunc &&func, CQEHandler &&cqe_handler, MultiShotFunc &&multishot_func)
Build a multi-shot operation awaiter with custom CQE handler.
auto async_readv(Fd fd, const struct iovec *iovecs, unsigned nr_vecs, __u64 offset, int flags)
See io_uring_prep_readv2.
auto async_openat(int dfd, const char *path, int flags, mode_t mode)
See io_uring_prep_openat.
auto async_linkat(int olddfd, const char *oldpath, int newdfd, const char *newpath, int flags)
See io_uring_prep_linkat.
auto async_uring_cmd(int cmd_op, Fd fd, CmdFunc &&cmd_func, Args &&...handler_args)
See io_uring_prep_uring_cmd.
auto async_shutdown(Fd fd, int how)
See io_uring_prep_shutdown.
auto async_socket(int domain, int type, int protocol, unsigned int flags)
See io_uring_prep_socket.
Support for io_uring zero-copy receive (zcrx) buffers.