polyphony 0.94 → 0.95

Sign up to get free protection for your applications and to get access to all the features.
Files changed (306) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +2 -2
  3. data/.gitignore +3 -3
  4. data/CHANGELOG.md +14 -0
  5. data/docs/api-reference/fiber.md +2 -2
  6. data/docs/api-reference/object.md +3 -3
  7. data/docs/main-concepts/exception-handling.md +2 -2
  8. data/ext/polyphony/backend_common.c +3 -3
  9. data/ext/polyphony/backend_io_uring.c +18 -16
  10. data/ext/polyphony/event.c +1 -1
  11. data/ext/polyphony/extconf.rb +5 -3
  12. data/ext/polyphony/fiber.c +5 -13
  13. data/ext/polyphony/io_extensions.c +1 -1
  14. data/ext/polyphony/pipe.c +1 -1
  15. data/ext/polyphony/polyphony.c +1 -1
  16. data/ext/polyphony/polyphony_ext.c +1 -1
  17. data/ext/polyphony/queue.c +1 -1
  18. data/ext/polyphony/ring_buffer.c +1 -0
  19. data/ext/polyphony/socket_extensions.c +1 -1
  20. data/ext/polyphony/thread.c +1 -1
  21. data/lib/polyphony/extensions/enumerator.rb +16 -0
  22. data/lib/polyphony/extensions/socket.rb +2 -0
  23. data/lib/polyphony/extensions.rb +1 -0
  24. data/lib/polyphony/version.rb +1 -1
  25. data/polyphony.gemspec +2 -2
  26. data/test/test_backend.rb +5 -1
  27. data/test/test_enumerator.rb +46 -0
  28. data/test/test_io.rb +241 -216
  29. data/test/test_socket.rb +1 -1
  30. data/test/test_thread_pool.rb +3 -3
  31. data/vendor/liburing/.github/workflows/build.yml +51 -5
  32. data/vendor/liburing/.github/workflows/shellcheck.yml +1 -1
  33. data/vendor/liburing/.gitignore +6 -123
  34. data/vendor/liburing/CHANGELOG +35 -0
  35. data/vendor/liburing/CITATION.cff +11 -0
  36. data/vendor/liburing/LICENSE +16 -3
  37. data/vendor/liburing/Makefile +3 -1
  38. data/vendor/liburing/Makefile.common +1 -0
  39. data/vendor/liburing/README +14 -2
  40. data/vendor/liburing/SECURITY.md +6 -0
  41. data/vendor/liburing/configure +16 -15
  42. data/vendor/liburing/examples/Makefile +4 -1
  43. data/vendor/liburing/examples/io_uring-udp.c +395 -0
  44. data/vendor/liburing/examples/poll-bench.c +101 -0
  45. data/vendor/liburing/examples/send-zerocopy.c +339 -0
  46. data/vendor/liburing/liburing.spec +1 -1
  47. data/vendor/liburing/man/io_uring.7 +38 -11
  48. data/vendor/liburing/man/io_uring_buf_ring_add.3 +53 -0
  49. data/vendor/liburing/man/io_uring_buf_ring_advance.3 +31 -0
  50. data/vendor/liburing/man/io_uring_buf_ring_cq_advance.3 +41 -0
  51. data/vendor/liburing/man/io_uring_buf_ring_init.3 +30 -0
  52. data/vendor/liburing/man/io_uring_buf_ring_mask.3 +27 -0
  53. data/vendor/liburing/man/io_uring_cq_advance.3 +29 -15
  54. data/vendor/liburing/man/io_uring_cq_has_overflow.3 +25 -0
  55. data/vendor/liburing/man/io_uring_cq_ready.3 +9 -8
  56. data/vendor/liburing/man/io_uring_cqe_get_data.3 +32 -13
  57. data/vendor/liburing/man/io_uring_cqe_get_data64.3 +1 -0
  58. data/vendor/liburing/man/io_uring_cqe_seen.3 +22 -12
  59. data/vendor/liburing/man/io_uring_enter.2 +249 -32
  60. data/vendor/liburing/man/io_uring_enter2.2 +1 -0
  61. data/vendor/liburing/man/io_uring_free_probe.3 +11 -8
  62. data/vendor/liburing/man/io_uring_get_events.3 +33 -0
  63. data/vendor/liburing/man/io_uring_get_probe.3 +9 -8
  64. data/vendor/liburing/man/io_uring_get_sqe.3 +29 -10
  65. data/vendor/liburing/man/io_uring_opcode_supported.3 +11 -10
  66. data/vendor/liburing/man/io_uring_peek_cqe.3 +38 -0
  67. data/vendor/liburing/man/io_uring_prep_accept.3 +197 -0
  68. data/vendor/liburing/man/io_uring_prep_accept_direct.3 +1 -0
  69. data/vendor/liburing/man/io_uring_prep_cancel.3 +118 -0
  70. data/vendor/liburing/man/io_uring_prep_cancel64.3 +1 -0
  71. data/vendor/liburing/man/io_uring_prep_close.3 +59 -0
  72. data/vendor/liburing/man/io_uring_prep_close_direct.3 +1 -0
  73. data/vendor/liburing/man/io_uring_prep_connect.3 +66 -0
  74. data/vendor/liburing/man/io_uring_prep_fadvise.3 +59 -0
  75. data/vendor/liburing/man/io_uring_prep_fallocate.3 +59 -0
  76. data/vendor/liburing/man/io_uring_prep_files_update.3 +92 -0
  77. data/vendor/liburing/man/io_uring_prep_fsync.3 +70 -0
  78. data/vendor/liburing/man/io_uring_prep_link.3 +1 -0
  79. data/vendor/liburing/man/io_uring_prep_linkat.3 +91 -0
  80. data/vendor/liburing/man/io_uring_prep_madvise.3 +56 -0
  81. data/vendor/liburing/man/io_uring_prep_mkdir.3 +1 -0
  82. data/vendor/liburing/man/io_uring_prep_mkdirat.3 +83 -0
  83. data/vendor/liburing/man/io_uring_prep_msg_ring.3 +39 -25
  84. data/vendor/liburing/man/io_uring_prep_multishot_accept.3 +1 -0
  85. data/vendor/liburing/man/io_uring_prep_multishot_accept_direct.3 +1 -0
  86. data/vendor/liburing/man/io_uring_prep_nop.3 +28 -0
  87. data/vendor/liburing/man/io_uring_prep_openat.3 +117 -0
  88. data/vendor/liburing/man/io_uring_prep_openat2.3 +117 -0
  89. data/vendor/liburing/man/io_uring_prep_openat2_direct.3 +1 -0
  90. data/vendor/liburing/man/io_uring_prep_openat_direct.3 +1 -0
  91. data/vendor/liburing/man/io_uring_prep_poll_add.3 +72 -0
  92. data/vendor/liburing/man/io_uring_prep_poll_multishot.3 +1 -0
  93. data/vendor/liburing/man/io_uring_prep_poll_remove.3 +55 -0
  94. data/vendor/liburing/man/io_uring_prep_poll_update.3 +89 -0
  95. data/vendor/liburing/man/io_uring_prep_provide_buffers.3 +131 -0
  96. data/vendor/liburing/man/io_uring_prep_read.3 +33 -14
  97. data/vendor/liburing/man/io_uring_prep_read_fixed.3 +39 -21
  98. data/vendor/liburing/man/io_uring_prep_readv.3 +49 -15
  99. data/vendor/liburing/man/io_uring_prep_readv2.3 +49 -17
  100. data/vendor/liburing/man/io_uring_prep_recv.3 +105 -0
  101. data/vendor/liburing/man/io_uring_prep_recv_multishot.3 +1 -0
  102. data/vendor/liburing/man/io_uring_prep_recvmsg.3 +124 -0
  103. data/vendor/liburing/man/io_uring_prep_recvmsg_multishot.3 +1 -0
  104. data/vendor/liburing/man/io_uring_prep_remove_buffers.3 +52 -0
  105. data/vendor/liburing/man/io_uring_prep_rename.3 +1 -0
  106. data/vendor/liburing/man/io_uring_prep_renameat.3 +96 -0
  107. data/vendor/liburing/man/io_uring_prep_send.3 +57 -0
  108. data/vendor/liburing/man/io_uring_prep_send_zc.3 +64 -0
  109. data/vendor/liburing/man/io_uring_prep_sendmsg.3 +69 -0
  110. data/vendor/liburing/man/io_uring_prep_shutdown.3 +53 -0
  111. data/vendor/liburing/man/io_uring_prep_socket.3 +118 -0
  112. data/vendor/liburing/man/io_uring_prep_socket_direct.3 +1 -0
  113. data/vendor/liburing/man/io_uring_prep_socket_direct_alloc.3 +1 -0
  114. data/vendor/liburing/man/io_uring_prep_splice.3 +80 -0
  115. data/vendor/liburing/man/io_uring_prep_statx.3 +74 -0
  116. data/vendor/liburing/man/io_uring_prep_symlink.3 +1 -0
  117. data/vendor/liburing/man/io_uring_prep_symlinkat.3 +85 -0
  118. data/vendor/liburing/man/io_uring_prep_sync_file_range.3 +59 -0
  119. data/vendor/liburing/man/io_uring_prep_tee.3 +74 -0
  120. data/vendor/liburing/man/io_uring_prep_timeout.3 +95 -0
  121. data/vendor/liburing/man/io_uring_prep_timeout_remove.3 +1 -0
  122. data/vendor/liburing/man/io_uring_prep_timeout_update.3 +98 -0
  123. data/vendor/liburing/man/io_uring_prep_unlink.3 +1 -0
  124. data/vendor/liburing/man/io_uring_prep_unlinkat.3 +82 -0
  125. data/vendor/liburing/man/io_uring_prep_write.3 +32 -15
  126. data/vendor/liburing/man/io_uring_prep_write_fixed.3 +39 -21
  127. data/vendor/liburing/man/io_uring_prep_writev.3 +50 -16
  128. data/vendor/liburing/man/io_uring_prep_writev2.3 +50 -17
  129. data/vendor/liburing/man/io_uring_queue_exit.3 +3 -4
  130. data/vendor/liburing/man/io_uring_queue_init.3 +58 -13
  131. data/vendor/liburing/man/io_uring_queue_init_params.3 +1 -0
  132. data/vendor/liburing/man/io_uring_recvmsg_cmsg_firsthdr.3 +1 -0
  133. data/vendor/liburing/man/io_uring_recvmsg_cmsg_nexthdr.3 +1 -0
  134. data/vendor/liburing/man/io_uring_recvmsg_name.3 +1 -0
  135. data/vendor/liburing/man/io_uring_recvmsg_out.3 +78 -0
  136. data/vendor/liburing/man/io_uring_recvmsg_payload.3 +1 -0
  137. data/vendor/liburing/man/io_uring_recvmsg_payload_length.3 +1 -0
  138. data/vendor/liburing/man/io_uring_recvmsg_validate.3 +1 -0
  139. data/vendor/liburing/man/io_uring_register.2 +153 -13
  140. data/vendor/liburing/man/io_uring_register_buf_ring.3 +140 -0
  141. data/vendor/liburing/man/io_uring_register_buffers.3 +32 -12
  142. data/vendor/liburing/man/io_uring_register_eventfd.3 +51 -0
  143. data/vendor/liburing/man/io_uring_register_eventfd_async.3 +1 -0
  144. data/vendor/liburing/man/io_uring_register_file_alloc_range.3 +52 -0
  145. data/vendor/liburing/man/io_uring_register_files.3 +33 -11
  146. data/vendor/liburing/man/io_uring_register_files_sparse.3 +1 -0
  147. data/vendor/liburing/man/io_uring_register_iowq_aff.3 +61 -0
  148. data/vendor/liburing/man/io_uring_register_iowq_max_workers.3 +71 -0
  149. data/vendor/liburing/man/io_uring_register_ring_fd.3 +49 -0
  150. data/vendor/liburing/man/io_uring_register_sync_cancel.3 +71 -0
  151. data/vendor/liburing/man/io_uring_setup.2 +119 -13
  152. data/vendor/liburing/man/io_uring_sq_ready.3 +14 -8
  153. data/vendor/liburing/man/io_uring_sq_space_left.3 +9 -9
  154. data/vendor/liburing/man/io_uring_sqe_set_data.3 +29 -11
  155. data/vendor/liburing/man/io_uring_sqe_set_data64.3 +1 -0
  156. data/vendor/liburing/man/io_uring_sqe_set_flags.3 +38 -11
  157. data/vendor/liburing/man/io_uring_sqring_wait.3 +13 -9
  158. data/vendor/liburing/man/io_uring_submit.3 +29 -12
  159. data/vendor/liburing/man/io_uring_submit_and_get_events.3 +31 -0
  160. data/vendor/liburing/man/io_uring_submit_and_wait.3 +16 -12
  161. data/vendor/liburing/man/io_uring_submit_and_wait_timeout.3 +30 -23
  162. data/vendor/liburing/man/io_uring_unregister_buf_ring.3 +30 -0
  163. data/vendor/liburing/man/io_uring_unregister_buffers.3 +11 -10
  164. data/vendor/liburing/man/io_uring_unregister_eventfd.3 +1 -0
  165. data/vendor/liburing/man/io_uring_unregister_files.3 +11 -10
  166. data/vendor/liburing/man/io_uring_unregister_iowq_aff.3 +1 -0
  167. data/vendor/liburing/man/io_uring_unregister_ring_fd.3 +32 -0
  168. data/vendor/liburing/man/io_uring_wait_cqe.3 +19 -12
  169. data/vendor/liburing/man/io_uring_wait_cqe_nr.3 +21 -14
  170. data/vendor/liburing/man/io_uring_wait_cqe_timeout.3 +27 -13
  171. data/vendor/liburing/man/io_uring_wait_cqes.3 +24 -14
  172. data/vendor/liburing/src/Makefile +8 -7
  173. data/vendor/liburing/src/arch/aarch64/lib.h +48 -0
  174. data/vendor/liburing/src/arch/aarch64/syscall.h +0 -4
  175. data/vendor/liburing/src/arch/generic/lib.h +0 -4
  176. data/vendor/liburing/src/arch/generic/syscall.h +29 -16
  177. data/vendor/liburing/src/arch/syscall-defs.h +41 -14
  178. data/vendor/liburing/src/arch/x86/lib.h +0 -21
  179. data/vendor/liburing/src/arch/x86/syscall.h +146 -10
  180. data/vendor/liburing/src/include/liburing/io_uring.h +245 -5
  181. data/vendor/liburing/src/include/liburing.h +468 -35
  182. data/vendor/liburing/src/int_flags.h +1 -0
  183. data/vendor/liburing/src/lib.h +20 -16
  184. data/vendor/liburing/src/liburing.map +16 -0
  185. data/vendor/liburing/src/nolibc.c +1 -1
  186. data/vendor/liburing/src/queue.c +87 -55
  187. data/vendor/liburing/src/register.c +129 -53
  188. data/vendor/liburing/src/setup.c +65 -28
  189. data/vendor/liburing/src/syscall.c +14 -32
  190. data/vendor/liburing/src/syscall.h +12 -64
  191. data/vendor/liburing/test/{232c93d07b74-test.c → 232c93d07b74.c} +8 -9
  192. data/vendor/liburing/test/{35fa71a030ca-test.c → 35fa71a030ca.c} +4 -4
  193. data/vendor/liburing/test/{500f9fbadef8-test.c → 500f9fbadef8.c} +7 -7
  194. data/vendor/liburing/test/{7ad0e4b2f83c-test.c → 7ad0e4b2f83c.c} +8 -7
  195. data/vendor/liburing/test/{8a9973408177-test.c → 8a9973408177.c} +4 -3
  196. data/vendor/liburing/test/{917257daa0fe-test.c → 917257daa0fe.c} +3 -2
  197. data/vendor/liburing/test/Makefile +60 -62
  198. data/vendor/liburing/test/{a0908ae19763-test.c → a0908ae19763.c} +3 -2
  199. data/vendor/liburing/test/{a4c0b3decb33-test.c → a4c0b3decb33.c} +3 -2
  200. data/vendor/liburing/test/accept-link.c +5 -4
  201. data/vendor/liburing/test/accept-reuse.c +17 -16
  202. data/vendor/liburing/test/accept-test.c +14 -10
  203. data/vendor/liburing/test/accept.c +529 -107
  204. data/vendor/liburing/test/across-fork.c +7 -6
  205. data/vendor/liburing/test/{b19062a56726-test.c → b19062a56726.c} +3 -2
  206. data/vendor/liburing/test/{b5837bd5311d-test.c → b5837bd5311d.c} +10 -9
  207. data/vendor/liburing/test/buf-ring.c +420 -0
  208. data/vendor/liburing/test/{ce593a6c480a-test.c → ce593a6c480a.c} +15 -12
  209. data/vendor/liburing/test/connect.c +8 -7
  210. data/vendor/liburing/test/cq-full.c +5 -4
  211. data/vendor/liburing/test/cq-overflow.c +242 -12
  212. data/vendor/liburing/test/cq-peek-batch.c +5 -4
  213. data/vendor/liburing/test/cq-ready.c +5 -4
  214. data/vendor/liburing/test/cq-size.c +5 -4
  215. data/vendor/liburing/test/{d4ae271dfaae-test.c → d4ae271dfaae.c} +2 -2
  216. data/vendor/liburing/test/{d77a67ed5f27-test.c → d77a67ed5f27.c} +6 -6
  217. data/vendor/liburing/test/defer-taskrun.c +336 -0
  218. data/vendor/liburing/test/defer.c +26 -14
  219. data/vendor/liburing/test/double-poll-crash.c +15 -5
  220. data/vendor/liburing/test/drop-submit.c +5 -3
  221. data/vendor/liburing/test/{eeed8b54e0df-test.c → eeed8b54e0df.c} +7 -6
  222. data/vendor/liburing/test/empty-eownerdead.c +4 -4
  223. data/vendor/liburing/test/eventfd-disable.c +48 -20
  224. data/vendor/liburing/test/eventfd-reg.c +10 -9
  225. data/vendor/liburing/test/eventfd-ring.c +13 -12
  226. data/vendor/liburing/test/eventfd.c +13 -12
  227. data/vendor/liburing/test/exit-no-cleanup.c +1 -1
  228. data/vendor/liburing/test/fadvise.c +3 -3
  229. data/vendor/liburing/test/fallocate.c +16 -9
  230. data/vendor/liburing/test/{fc2a85cb02ef-test.c → fc2a85cb02ef.c} +4 -3
  231. data/vendor/liburing/test/fd-pass.c +187 -0
  232. data/vendor/liburing/test/file-register.c +302 -36
  233. data/vendor/liburing/test/file-update.c +62 -4
  234. data/vendor/liburing/test/file-verify.c +6 -2
  235. data/vendor/liburing/test/files-exit-hang-poll.c +11 -25
  236. data/vendor/liburing/test/files-exit-hang-timeout.c +13 -10
  237. data/vendor/liburing/test/fixed-buf-iter.c +115 -0
  238. data/vendor/liburing/test/fixed-link.c +10 -10
  239. data/vendor/liburing/test/fixed-reuse.c +160 -0
  240. data/vendor/liburing/test/fpos.c +6 -3
  241. data/vendor/liburing/test/fsync.c +3 -3
  242. data/vendor/liburing/test/hardlink.c +10 -6
  243. data/vendor/liburing/test/helpers.c +137 -4
  244. data/vendor/liburing/test/helpers.h +27 -0
  245. data/vendor/liburing/test/io-cancel.c +16 -11
  246. data/vendor/liburing/test/io_uring_enter.c +46 -81
  247. data/vendor/liburing/test/io_uring_passthrough.c +451 -0
  248. data/vendor/liburing/test/io_uring_register.c +59 -229
  249. data/vendor/liburing/test/io_uring_setup.c +24 -29
  250. data/vendor/liburing/test/iopoll-leak.c +85 -0
  251. data/vendor/liburing/test/iopoll.c +16 -9
  252. data/vendor/liburing/test/lfs-openat-write.c +3 -1
  253. data/vendor/liburing/test/link-timeout.c +4 -3
  254. data/vendor/liburing/test/link.c +8 -7
  255. data/vendor/liburing/test/madvise.c +2 -2
  256. data/vendor/liburing/test/mkdir.c +9 -5
  257. data/vendor/liburing/test/msg-ring.c +46 -20
  258. data/vendor/liburing/test/multicqes_drain.c +51 -12
  259. data/vendor/liburing/test/nolibc.c +60 -0
  260. data/vendor/liburing/test/nop.c +78 -16
  261. data/vendor/liburing/test/nvme.h +168 -0
  262. data/vendor/liburing/test/open-direct-link.c +188 -0
  263. data/vendor/liburing/test/open-direct-pick.c +180 -0
  264. data/vendor/liburing/test/openat2.c +3 -3
  265. data/vendor/liburing/test/poll-cancel-all.c +472 -0
  266. data/vendor/liburing/test/poll-link.c +9 -18
  267. data/vendor/liburing/test/poll-mshot-overflow.c +162 -0
  268. data/vendor/liburing/test/poll-mshot-update.c +83 -33
  269. data/vendor/liburing/test/pollfree.c +2 -2
  270. data/vendor/liburing/test/read-before-exit.c +112 -0
  271. data/vendor/liburing/test/read-write.c +83 -1
  272. data/vendor/liburing/test/recv-msgall-stream.c +398 -0
  273. data/vendor/liburing/test/recv-msgall.c +265 -0
  274. data/vendor/liburing/test/recv-multishot.c +505 -0
  275. data/vendor/liburing/test/rename.c +2 -5
  276. data/vendor/liburing/test/ring-leak.c +97 -0
  277. data/vendor/liburing/test/ringbuf-read.c +200 -0
  278. data/vendor/liburing/test/rsrc_tags.c +25 -13
  279. data/vendor/liburing/test/runtests-quiet.sh +11 -0
  280. data/vendor/liburing/test/runtests.sh +18 -20
  281. data/vendor/liburing/test/rw_merge_test.c +3 -2
  282. data/vendor/liburing/test/send-zerocopy.c +684 -0
  283. data/vendor/liburing/test/send_recv.c +49 -2
  284. data/vendor/liburing/test/send_recvmsg.c +165 -55
  285. data/vendor/liburing/test/shutdown.c +3 -4
  286. data/vendor/liburing/test/sigfd-deadlock.c +22 -8
  287. data/vendor/liburing/test/single-issuer.c +171 -0
  288. data/vendor/liburing/test/socket-rw-eagain.c +2 -12
  289. data/vendor/liburing/test/socket-rw-offset.c +2 -11
  290. data/vendor/liburing/test/socket-rw.c +2 -11
  291. data/vendor/liburing/test/socket.c +409 -0
  292. data/vendor/liburing/test/sq-poll-dup.c +1 -1
  293. data/vendor/liburing/test/sq-poll-share.c +1 -1
  294. data/vendor/liburing/test/statx.c +2 -2
  295. data/vendor/liburing/test/submit-and-wait.c +108 -0
  296. data/vendor/liburing/test/submit-link-fail.c +5 -3
  297. data/vendor/liburing/test/submit-reuse.c +0 -2
  298. data/vendor/liburing/test/sync-cancel.c +235 -0
  299. data/vendor/liburing/test/test.h +35 -0
  300. data/vendor/liburing/test/timeout-overflow.c +11 -11
  301. data/vendor/liburing/test/timeout.c +7 -7
  302. data/vendor/liburing/test/tty-write-dpoll.c +60 -0
  303. data/vendor/liburing/test/unlink.c +1 -1
  304. data/vendor/liburing/test/xattr.c +425 -0
  305. metadata +143 -22
  306. data/Gemfile.lock +0 -78
@@ -1,32 +1,11 @@
1
1
  /* SPDX-License-Identifier: MIT */
2
2
 
3
- #ifndef __INTERNAL__LIBURING_LIB_H
4
- #error "This file should be included from src/lib.h (liburing)"
5
- #endif
6
-
7
3
  #ifndef LIBURING_ARCH_X86_LIB_H
8
4
  #define LIBURING_ARCH_X86_LIB_H
9
5
 
10
- #if defined(__x86_64__)
11
-
12
6
  static inline long get_page_size(void)
13
7
  {
14
8
  return 4096;
15
9
  }
16
10
 
17
- #else /* #if defined(__x86_64__) */
18
-
19
- /*
20
- * For x86 (32-bit), fallback to libc wrapper.
21
- * We can't use CONFIG_NOLIBC for x86 (32-bit) at the moment.
22
- *
23
- * TODO: Add x86 (32-bit) nolibc support.
24
- */
25
- #ifdef CONFIG_NOLIBC
26
- #error "x86 (32-bit) is currently not supported for nolibc builds"
27
- #endif
28
- #include "../generic/lib.h"
29
-
30
- #endif /* #if defined(__x86_64__) */
31
-
32
11
  #endif /* #ifndef LIBURING_ARCH_X86_LIB_H */
@@ -1,9 +1,5 @@
1
1
  /* SPDX-License-Identifier: MIT */
2
2
 
3
- #ifndef __INTERNAL__LIBURING_SYSCALL_H
4
- #error "This file should be included from src/syscall.h (liburing)"
5
- #endif
6
-
7
3
  #ifndef LIBURING_ARCH_X86_SYSCALL_H
8
4
  #define LIBURING_ARCH_X86_SYSCALL_H
9
5
 
@@ -144,17 +140,157 @@
144
140
 
145
141
  #else /* #if defined(__x86_64__) */
146
142
 
143
+ #ifdef CONFIG_NOLIBC
144
+ /**
145
+ * Note for syscall registers usage (x86, 32-bit):
146
+ * - %eax is the syscall number.
147
+ * - %eax is also the return value.
148
+ * - %ebx is the 1st argument.
149
+ * - %ecx is the 2nd argument.
150
+ * - %edx is the 3rd argument.
151
+ * - %esi is the 4th argument.
152
+ * - %edi is the 5th argument.
153
+ * - %ebp is the 6th argument.
154
+ */
155
+
156
+ #define __do_syscall0(NUM) ({ \
157
+ intptr_t eax; \
158
+ \
159
+ __asm__ volatile( \
160
+ "int $0x80" \
161
+ : "=a"(eax) /* %eax */ \
162
+ : "a"(NUM) /* %eax */ \
163
+ : "memory" \
164
+ ); \
165
+ eax; \
166
+ })
167
+
168
+ #define __do_syscall1(NUM, ARG1) ({ \
169
+ intptr_t eax; \
170
+ \
171
+ __asm__ volatile( \
172
+ "int $0x80" \
173
+ : "=a"(eax) /* %eax */ \
174
+ : "a"(NUM), /* %eax */ \
175
+ "b"((ARG1)) /* %ebx */ \
176
+ : "memory" \
177
+ ); \
178
+ eax; \
179
+ })
180
+
181
+ #define __do_syscall2(NUM, ARG1, ARG2) ({ \
182
+ intptr_t eax; \
183
+ \
184
+ __asm__ volatile( \
185
+ "int $0x80" \
186
+ : "=a" (eax) /* %eax */ \
187
+ : "a"(NUM), /* %eax */ \
188
+ "b"((ARG1)), /* %ebx */ \
189
+ "c"((ARG2)) /* %ecx */ \
190
+ : "memory" \
191
+ ); \
192
+ eax; \
193
+ })
194
+
195
+ #define __do_syscall3(NUM, ARG1, ARG2, ARG3) ({ \
196
+ intptr_t eax; \
197
+ \
198
+ __asm__ volatile( \
199
+ "int $0x80" \
200
+ : "=a" (eax) /* %eax */ \
201
+ : "a"(NUM), /* %eax */ \
202
+ "b"((ARG1)), /* %ebx */ \
203
+ "c"((ARG2)), /* %ecx */ \
204
+ "d"((ARG3)) /* %edx */ \
205
+ : "memory" \
206
+ ); \
207
+ eax; \
208
+ })
209
+
210
+ #define __do_syscall4(NUM, ARG1, ARG2, ARG3, ARG4) ({ \
211
+ intptr_t eax; \
212
+ \
213
+ __asm__ volatile( \
214
+ "int $0x80" \
215
+ : "=a" (eax) /* %eax */ \
216
+ : "a"(NUM), /* %eax */ \
217
+ "b"((ARG1)), /* %ebx */ \
218
+ "c"((ARG2)), /* %ecx */ \
219
+ "d"((ARG3)), /* %edx */ \
220
+ "S"((ARG4)) /* %esi */ \
221
+ : "memory" \
222
+ ); \
223
+ eax; \
224
+ })
225
+
226
+ #define __do_syscall5(NUM, ARG1, ARG2, ARG3, ARG4, ARG5) ({ \
227
+ intptr_t eax; \
228
+ \
229
+ __asm__ volatile( \
230
+ "int $0x80" \
231
+ : "=a" (eax) /* %eax */ \
232
+ : "a"(NUM), /* %eax */ \
233
+ "b"((ARG1)), /* %ebx */ \
234
+ "c"((ARG2)), /* %ecx */ \
235
+ "d"((ARG3)), /* %edx */ \
236
+ "S"((ARG4)), /* %esi */ \
237
+ "D"((ARG5)) /* %edi */ \
238
+ : "memory" \
239
+ ); \
240
+ eax; \
241
+ })
242
+
243
+
147
244
  /*
148
- * For x86 (32-bit), fallback to libc wrapper.
149
- * We can't use CONFIG_NOLIBC for x86 (32-bit) at the moment.
245
+ * On i386, the 6th argument of syscall goes in %ebp. However, both Clang
246
+ * and GCC cannot use %ebp in the clobber list and in the "r" constraint
247
+ * without using -fomit-frame-pointer. To make it always available for
248
+ * any kind of compilation, the below workaround is implemented:
249
+ *
250
+ * 1) Push the 6-th argument.
251
+ * 2) Push %ebp.
252
+ * 3) Load the 6-th argument from 4(%esp) to %ebp.
253
+ * 4) Do the syscall (int $0x80).
254
+ * 5) Pop %ebp (restore the old value of %ebp).
255
+ * 6) Add %esp by 4 (undo the stack pointer).
256
+ *
257
+ * WARNING:
258
+ * Don't use register variables for __do_syscall6(), there is a known
259
+ * GCC bug that results in an endless loop.
260
+ *
261
+ * BugLink: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105032
150
262
  *
151
- * TODO: Add x86 (32-bit) nolibc support.
152
263
  */
153
- #ifdef CONFIG_NOLIBC
154
- #error "x86 (32-bit) is currently not supported for nolibc builds"
155
- #endif
264
+ #define __do_syscall6(NUM, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6) ({ \
265
+ intptr_t eax = (intptr_t)(NUM); \
266
+ intptr_t arg6 = (intptr_t)(ARG6); /* Always in memory */ \
267
+ __asm__ volatile ( \
268
+ "pushl %[_arg6]\n\t" \
269
+ "pushl %%ebp\n\t" \
270
+ "movl 4(%%esp),%%ebp\n\t" \
271
+ "int $0x80\n\t" \
272
+ "popl %%ebp\n\t" \
273
+ "addl $4,%%esp" \
274
+ : "+a"(eax) /* %eax */ \
275
+ : "b"(ARG1), /* %ebx */ \
276
+ "c"(ARG2), /* %ecx */ \
277
+ "d"(ARG3), /* %edx */ \
278
+ "S"(ARG4), /* %esi */ \
279
+ "D"(ARG5), /* %edi */ \
280
+ [_arg6]"m"(arg6) /* memory */ \
281
+ : "memory", "cc" \
282
+ ); \
283
+ eax; \
284
+ })
285
+
286
+ #include "../syscall-defs.h"
287
+
288
+ #else /* #ifdef CONFIG_NOLIBC */
289
+
156
290
  #include "../generic/syscall.h"
157
291
 
292
+ #endif /* #ifdef CONFIG_NOLIBC */
293
+
158
294
  #endif /* #if defined(__x86_64__) */
159
295
 
160
296
  #endif /* #ifndef LIBURING_ARCH_X86_SYSCALL_H */
@@ -10,6 +10,16 @@
10
10
 
11
11
  #include <linux/fs.h>
12
12
  #include <linux/types.h>
13
+ /*
14
+ * this file is shared with liburing and that has to autodetect
15
+ * if linux/time_types.h is available
16
+ */
17
+ #ifdef __KERNEL__
18
+ #define HAVE_LINUX_TIME_TYPES_H 1
19
+ #endif
20
+ #ifdef HAVE_LINUX_TIME_TYPES_H
21
+ #include <linux/time_types.h>
22
+ #endif
13
23
 
14
24
  #ifdef __cplusplus
15
25
  extern "C" {
@@ -26,6 +36,10 @@ struct io_uring_sqe {
26
36
  union {
27
37
  __u64 off; /* offset into file */
28
38
  __u64 addr2;
39
+ struct {
40
+ __u32 cmd_op;
41
+ __u32 __pad1;
42
+ };
29
43
  };
30
44
  union {
31
45
  __u64 addr; /* pointer to buffer or iovecs */
@@ -49,6 +63,9 @@ struct io_uring_sqe {
49
63
  __u32 rename_flags;
50
64
  __u32 unlink_flags;
51
65
  __u32 hardlink_flags;
66
+ __u32 xattr_flags;
67
+ __u32 msg_ring_flags;
68
+ __u32 uring_cmd_flags;
52
69
  };
53
70
  __u64 user_data; /* data to be passed back at completion time */
54
71
  /* pack this to avoid bogus arm OABI complaints */
@@ -63,10 +80,33 @@ struct io_uring_sqe {
63
80
  union {
64
81
  __s32 splice_fd_in;
65
82
  __u32 file_index;
83
+ struct {
84
+ __u16 addr_len;
85
+ __u16 __pad3[1];
86
+ };
87
+ };
88
+ union {
89
+ struct {
90
+ __u64 addr3;
91
+ __u64 __pad2[1];
92
+ };
93
+ /*
94
+ * If the ring is initialized with IORING_SETUP_SQE128, then
95
+ * this field is used for 80 bytes of arbitrary command data
96
+ */
97
+ __u8 cmd[0];
66
98
  };
67
- __u64 __pad2[2];
68
99
  };
69
100
 
101
+ /*
102
+ * If sqe->file_index is set to this for opcodes that instantiate a new
103
+ * direct descriptor (like openat/openat2/accept), then io_uring will allocate
104
+ * an available direct descriptor instead of having the application pass one
105
+ * in. The picked direct descriptor will be returned in cqe->res, or -ENFILE
106
+ * if the space is full.
107
+ */
108
+ #define IORING_FILE_INDEX_ALLOC (~0U)
109
+
70
110
  enum {
71
111
  IOSQE_FIXED_FILE_BIT,
72
112
  IOSQE_IO_DRAIN_BIT,
@@ -106,8 +146,35 @@ enum {
106
146
  #define IORING_SETUP_ATTACH_WQ (1U << 5) /* attach to existing wq */
107
147
  #define IORING_SETUP_R_DISABLED (1U << 6) /* start with ring disabled */
108
148
  #define IORING_SETUP_SUBMIT_ALL (1U << 7) /* continue submit on error */
149
+ /*
150
+ * Cooperative task running. When requests complete, they often require
151
+ * forcing the submitter to transition to the kernel to complete. If this
152
+ * flag is set, work will be done when the task transitions anyway, rather
153
+ * than force an inter-processor interrupt reschedule. This avoids interrupting
154
+ * a task running in userspace, and saves an IPI.
155
+ */
156
+ #define IORING_SETUP_COOP_TASKRUN (1U << 8)
157
+ /*
158
+ * If COOP_TASKRUN is set, get notified if task work is available for
159
+ * running and a kernel transition would be needed to run it. This sets
160
+ * IORING_SQ_TASKRUN in the sq ring flags. Not valid with COOP_TASKRUN.
161
+ */
162
+ #define IORING_SETUP_TASKRUN_FLAG (1U << 9)
163
+ #define IORING_SETUP_SQE128 (1U << 10) /* SQEs are 128 byte */
164
+ #define IORING_SETUP_CQE32 (1U << 11) /* CQEs are 32 byte */
165
+ /*
166
+ * Only one task is allowed to submit requests
167
+ */
168
+ #define IORING_SETUP_SINGLE_ISSUER (1U << 12)
109
169
 
110
- enum {
170
+ /*
171
+ * Defer running task work to get events.
172
+ * Rather than running bits of task work whenever the task transitions
173
+ * try to do it just before it is needed.
174
+ */
175
+ #define IORING_SETUP_DEFER_TASKRUN (1U << 13)
176
+
177
+ enum io_uring_op {
111
178
  IORING_OP_NOP,
112
179
  IORING_OP_READV,
113
180
  IORING_OP_WRITEV,
@@ -149,11 +216,27 @@ enum {
149
216
  IORING_OP_SYMLINKAT,
150
217
  IORING_OP_LINKAT,
151
218
  IORING_OP_MSG_RING,
219
+ IORING_OP_FSETXATTR,
220
+ IORING_OP_SETXATTR,
221
+ IORING_OP_FGETXATTR,
222
+ IORING_OP_GETXATTR,
223
+ IORING_OP_SOCKET,
224
+ IORING_OP_URING_CMD,
225
+ IORING_OP_SEND_ZC,
226
+ IORING_OP_SENDMSG_ZC,
152
227
 
153
228
  /* this goes last, obviously */
154
229
  IORING_OP_LAST,
155
230
  };
156
231
 
232
+ /*
233
+ * sqe->uring_cmd_flags
234
+ * IORING_URING_CMD_FIXED use registered buffer; pass thig flag
235
+ * along with setting sqe->buf_index.
236
+ */
237
+ #define IORING_URING_CMD_FIXED (1U << 0)
238
+
239
+
157
240
  /*
158
241
  * sqe->fsync_flags
159
242
  */
@@ -186,10 +269,67 @@ enum {
186
269
  *
187
270
  * IORING_POLL_UPDATE Update existing poll request, matching
188
271
  * sqe->addr as the old user_data field.
272
+ *
273
+ * IORING_POLL_LEVEL Level triggered poll.
189
274
  */
190
275
  #define IORING_POLL_ADD_MULTI (1U << 0)
191
276
  #define IORING_POLL_UPDATE_EVENTS (1U << 1)
192
277
  #define IORING_POLL_UPDATE_USER_DATA (1U << 2)
278
+ #define IORING_POLL_ADD_LEVEL (1U << 3)
279
+
280
+ /*
281
+ * ASYNC_CANCEL flags.
282
+ *
283
+ * IORING_ASYNC_CANCEL_ALL Cancel all requests that match the given key
284
+ * IORING_ASYNC_CANCEL_FD Key off 'fd' for cancelation rather than the
285
+ * request 'user_data'
286
+ * IORING_ASYNC_CANCEL_ANY Match any request
287
+ * IORING_ASYNC_CANCEL_FD_FIXED 'fd' passed in is a fixed descriptor
288
+ */
289
+ #define IORING_ASYNC_CANCEL_ALL (1U << 0)
290
+ #define IORING_ASYNC_CANCEL_FD (1U << 1)
291
+ #define IORING_ASYNC_CANCEL_ANY (1U << 2)
292
+ #define IORING_ASYNC_CANCEL_FD_FIXED (1U << 3)
293
+
294
+ /*
295
+ * send/sendmsg and recv/recvmsg flags (sqe->ioprio)
296
+ *
297
+ * IORING_RECVSEND_POLL_FIRST If set, instead of first attempting to send
298
+ * or receive and arm poll if that yields an
299
+ * -EAGAIN result, arm poll upfront and skip
300
+ * the initial transfer attempt.
301
+ *
302
+ * IORING_RECV_MULTISHOT Multishot recv. Sets IORING_CQE_F_MORE if
303
+ * the handler will continue to report
304
+ * CQEs on behalf of the same SQE.
305
+ *
306
+ * IORING_RECVSEND_FIXED_BUF Use registered buffers, the index is stored in
307
+ * the buf_index field.
308
+ */
309
+ #define IORING_RECVSEND_POLL_FIRST (1U << 0)
310
+ #define IORING_RECV_MULTISHOT (1U << 1)
311
+ #define IORING_RECVSEND_FIXED_BUF (1U << 2)
312
+
313
+ /*
314
+ * accept flags stored in sqe->ioprio
315
+ */
316
+ #define IORING_ACCEPT_MULTISHOT (1U << 0)
317
+
318
+ /*
319
+ * IORING_OP_MSG_RING command types, stored in sqe->addr
320
+ */
321
+ enum {
322
+ IORING_MSG_DATA, /* pass sqe->len as 'res' and off as user_data */
323
+ IORING_MSG_SEND_FD, /* send a registered fd to another ring */
324
+ };
325
+
326
+ /*
327
+ * IORING_OP_MSG_RING flags (sqe->msg_ring_flags)
328
+ *
329
+ * IORING_MSG_RING_CQE_SKIP Don't post a CQE to the target ring. Not
330
+ * applicable for IORING_MSG_DATA, obviously.
331
+ */
332
+ #define IORING_MSG_RING_CQE_SKIP (1U << 0)
193
333
 
194
334
  /*
195
335
  * IO completion data structure (Completion Queue Entry)
@@ -198,6 +338,12 @@ struct io_uring_cqe {
198
338
  __u64 user_data; /* sqe->data submission passed back */
199
339
  __s32 res; /* result code for this event */
200
340
  __u32 flags;
341
+
342
+ /*
343
+ * If the ring is initialized with IORING_SETUP_CQE32, then this field
344
+ * contains 16-bytes of padding, doubling the size of the CQE.
345
+ */
346
+ __u64 big_cqe[];
201
347
  };
202
348
 
203
349
  /*
@@ -205,11 +351,14 @@ struct io_uring_cqe {
205
351
  *
206
352
  * IORING_CQE_F_BUFFER If set, the upper 16 bits are the buffer ID
207
353
  * IORING_CQE_F_MORE If set, parent SQE will generate more CQE entries
208
- * IORING_CQE_F_MSG If set, CQE was generated with IORING_OP_MSG_RING
354
+ * IORING_CQE_F_SOCK_NONEMPTY If set, more data to read after socket recv
355
+ * IORING_CQE_F_NOTIF Set for notification CQEs. Can be used to distinct
356
+ * them from sends.
209
357
  */
210
358
  #define IORING_CQE_F_BUFFER (1U << 0)
211
359
  #define IORING_CQE_F_MORE (1U << 1)
212
- #define IORING_CQE_F_MSG (1U << 2)
360
+ #define IORING_CQE_F_SOCK_NONEMPTY (1U << 2)
361
+ #define IORING_CQE_F_NOTIF (1U << 3)
213
362
 
214
363
  enum {
215
364
  IORING_CQE_BUFFER_SHIFT = 16,
@@ -242,6 +391,7 @@ struct io_sqring_offsets {
242
391
  */
243
392
  #define IORING_SQ_NEED_WAKEUP (1U << 0) /* needs io_uring_enter wakeup */
244
393
  #define IORING_SQ_CQ_OVERFLOW (1U << 1) /* CQ ring is overflown */
394
+ #define IORING_SQ_TASKRUN (1U << 2) /* task should enter the kernel */
245
395
 
246
396
  struct io_cqring_offsets {
247
397
  __u32 head;
@@ -302,6 +452,7 @@ struct io_uring_params {
302
452
  #define IORING_FEAT_NATIVE_WORKERS (1U << 9)
303
453
  #define IORING_FEAT_RSRC_TAGS (1U << 10)
304
454
  #define IORING_FEAT_CQE_SKIP (1U << 11)
455
+ #define IORING_FEAT_LINKED_FILE (1U << 12)
305
456
 
306
457
  /*
307
458
  * io_uring_register(2) opcodes and arguments
@@ -338,6 +489,16 @@ enum {
338
489
  IORING_REGISTER_RING_FDS = 20,
339
490
  IORING_UNREGISTER_RING_FDS = 21,
340
491
 
492
+ /* register ring based provide buffer group */
493
+ IORING_REGISTER_PBUF_RING = 22,
494
+ IORING_UNREGISTER_PBUF_RING = 23,
495
+
496
+ /* sync cancelation API */
497
+ IORING_REGISTER_SYNC_CANCEL = 24,
498
+
499
+ /* register a range of fixed file slots for automatic slot allocation */
500
+ IORING_REGISTER_FILE_ALLOC_RANGE = 25,
501
+
341
502
  /* this goes last */
342
503
  IORING_REGISTER_LAST
343
504
  };
@@ -355,9 +516,15 @@ struct io_uring_files_update {
355
516
  __aligned_u64 /* __s32 * */ fds;
356
517
  };
357
518
 
519
+ /*
520
+ * Register a fully sparse file space, rather than pass in an array of all
521
+ * -1 file descriptors.
522
+ */
523
+ #define IORING_RSRC_REGISTER_SPARSE (1U << 0)
524
+
358
525
  struct io_uring_rsrc_register {
359
526
  __u32 nr;
360
- __u32 resv;
527
+ __u32 flags;
361
528
  __u64 resv2;
362
529
  __aligned_u64 data;
363
530
  __aligned_u64 tags;
@@ -378,6 +545,19 @@ struct io_uring_rsrc_update2 {
378
545
  __u32 resv2;
379
546
  };
380
547
 
548
+ struct io_uring_notification_slot {
549
+ __u64 tag;
550
+ __u64 resv[3];
551
+ };
552
+
553
+ struct io_uring_notification_register {
554
+ __u32 nr_slots;
555
+ __u32 resv;
556
+ __u64 resv2;
557
+ __u64 data;
558
+ __u64 resv3;
559
+ };
560
+
381
561
  /* Skip updating fd indexes set to this value in the fd table */
382
562
  #define IORING_REGISTER_FILES_SKIP (-2)
383
563
 
@@ -409,6 +589,38 @@ struct io_uring_restriction {
409
589
  __u32 resv2[3];
410
590
  };
411
591
 
592
+ struct io_uring_buf {
593
+ __u64 addr;
594
+ __u32 len;
595
+ __u16 bid;
596
+ __u16 resv;
597
+ };
598
+
599
+ struct io_uring_buf_ring {
600
+ union {
601
+ /*
602
+ * To avoid spilling into more pages than we need to, the
603
+ * ring tail is overlaid with the io_uring_buf->resv field.
604
+ */
605
+ struct {
606
+ __u64 resv1;
607
+ __u32 resv2;
608
+ __u16 resv3;
609
+ __u16 tail;
610
+ };
611
+ struct io_uring_buf bufs[0];
612
+ };
613
+ };
614
+
615
+ /* argument for IORING_(UN)REGISTER_PBUF_RING */
616
+ struct io_uring_buf_reg {
617
+ __u64 ring_addr;
618
+ __u32 ring_entries;
619
+ __u16 bgid;
620
+ __u16 pad;
621
+ __u64 resv[3];
622
+ };
623
+
412
624
  /*
413
625
  * io_uring_restriction->opcode values
414
626
  */
@@ -435,6 +647,34 @@ struct io_uring_getevents_arg {
435
647
  __u64 ts;
436
648
  };
437
649
 
650
+ /*
651
+ * Argument for IORING_REGISTER_SYNC_CANCEL
652
+ */
653
+ struct io_uring_sync_cancel_reg {
654
+ __u64 addr;
655
+ __s32 fd;
656
+ __u32 flags;
657
+ struct __kernel_timespec timeout;
658
+ __u64 pad[4];
659
+ };
660
+
661
+ /*
662
+ * Argument for IORING_REGISTER_FILE_ALLOC_RANGE
663
+ * The range is specified as [off, off + len)
664
+ */
665
+ struct io_uring_file_index_range {
666
+ __u32 off;
667
+ __u32 len;
668
+ __u64 resv;
669
+ };
670
+
671
+ struct io_uring_recvmsg_out {
672
+ __u32 namelen;
673
+ __u32 controllen;
674
+ __u32 payloadlen;
675
+ __u32 flags;
676
+ };
677
+
438
678
  #ifdef __cplusplus
439
679
  }
440
680
  #endif