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
@@ -13,8 +13,9 @@
13
13
  #include <sys/eventfd.h>
14
14
 
15
15
  #include "liburing.h"
16
+ #include "helpers.h"
16
17
 
17
- int main(int argc, char *argv[])
18
+ static int test(bool defer)
18
19
  {
19
20
  struct io_uring_params p = {};
20
21
  struct io_uring_sqe *sqe;
@@ -27,36 +28,37 @@ int main(int argc, char *argv[])
27
28
  };
28
29
  int ret, evfd, i;
29
30
 
30
- if (argc > 1)
31
- return 0;
31
+ if (defer)
32
+ p.flags |= IORING_SETUP_SINGLE_ISSUER |
33
+ IORING_SETUP_DEFER_TASKRUN;
32
34
 
33
35
  ret = io_uring_queue_init_params(64, &ring, &p);
34
36
  if (ret) {
35
37
  fprintf(stderr, "ring setup failed: %d\n", ret);
36
- return 1;
38
+ return T_EXIT_FAIL;
37
39
  }
38
40
 
39
41
  evfd = eventfd(0, EFD_CLOEXEC);
40
42
  if (evfd < 0) {
41
43
  perror("eventfd");
42
- return 1;
44
+ return T_EXIT_FAIL;
43
45
  }
44
46
 
45
47
  ret = io_uring_register_eventfd(&ring, evfd);
46
48
  if (ret) {
47
49
  fprintf(stderr, "failed to register evfd: %d\n", ret);
48
- return 1;
50
+ return T_EXIT_FAIL;
49
51
  }
50
52
 
51
53
  if (!io_uring_cq_eventfd_enabled(&ring)) {
52
54
  fprintf(stderr, "eventfd disabled\n");
53
- return 1;
55
+ return T_EXIT_FAIL;
54
56
  }
55
57
 
56
58
  ret = io_uring_cq_eventfd_toggle(&ring, false);
57
59
  if (ret) {
58
60
  fprintf(stdout, "Skipping, CQ flags not available!\n");
59
- return 0;
61
+ return T_EXIT_SKIP;
60
62
  }
61
63
 
62
64
  sqe = io_uring_get_sqe(&ring);
@@ -66,7 +68,7 @@ int main(int argc, char *argv[])
66
68
  ret = io_uring_submit(&ring);
67
69
  if (ret != 1) {
68
70
  fprintf(stderr, "submit: %d\n", ret);
69
- return 1;
71
+ return T_EXIT_FAIL;
70
72
  }
71
73
 
72
74
  for (i = 0; i < 63; i++) {
@@ -78,24 +80,24 @@ int main(int argc, char *argv[])
78
80
  ret = io_uring_submit(&ring);
79
81
  if (ret != 63) {
80
82
  fprintf(stderr, "submit: %d\n", ret);
81
- return 1;
83
+ return T_EXIT_FAIL;
82
84
  }
83
85
 
84
86
  for (i = 0; i < 63; i++) {
85
87
  ret = io_uring_wait_cqe(&ring, &cqe);
86
88
  if (ret) {
87
89
  fprintf(stderr, "wait: %d\n", ret);
88
- return 1;
90
+ return T_EXIT_FAIL;
89
91
  }
90
92
 
91
93
  switch (cqe->user_data) {
92
94
  case 1: /* eventfd */
93
95
  fprintf(stderr, "eventfd unexpected: %d\n", (int)ptr);
94
- return 1;
96
+ return T_EXIT_FAIL;
95
97
  case 2:
96
98
  if (cqe->res) {
97
99
  fprintf(stderr, "nop: %d\n", cqe->res);
98
- return 1;
100
+ return T_EXIT_FAIL;
99
101
  }
100
102
  break;
101
103
  }
@@ -105,7 +107,7 @@ int main(int argc, char *argv[])
105
107
  ret = io_uring_cq_eventfd_toggle(&ring, true);
106
108
  if (ret) {
107
109
  fprintf(stderr, "io_uring_cq_eventfd_toggle: %d\n", ret);
108
- return 1;
110
+ return T_EXIT_FAIL;
109
111
  }
110
112
 
111
113
  sqe = io_uring_get_sqe(&ring);
@@ -115,37 +117,63 @@ int main(int argc, char *argv[])
115
117
  ret = io_uring_submit(&ring);
116
118
  if (ret != 1) {
117
119
  fprintf(stderr, "submit: %d\n", ret);
118
- return 1;
120
+ return T_EXIT_FAIL;
119
121
  }
120
122
 
121
123
  for (i = 0; i < 2; i++) {
122
124
  ret = io_uring_wait_cqe(&ring, &cqe);
123
125
  if (ret) {
124
126
  fprintf(stderr, "wait: %d\n", ret);
125
- return 1;
127
+ return T_EXIT_FAIL;
126
128
  }
127
129
 
128
130
  switch (cqe->user_data) {
129
131
  case 1: /* eventfd */
130
132
  if (cqe->res != sizeof(ptr)) {
131
133
  fprintf(stderr, "read res: %d\n", cqe->res);
132
- return 1;
134
+ return T_EXIT_FAIL;
133
135
  }
134
136
 
135
137
  if (ptr != 1) {
136
138
  fprintf(stderr, "eventfd: %d\n", (int)ptr);
137
- return 1;
139
+ return T_EXIT_FAIL;
138
140
  }
139
141
  break;
140
142
  case 2:
141
143
  if (cqe->res) {
142
144
  fprintf(stderr, "nop: %d\n", cqe->res);
143
- return 1;
145
+ return T_EXIT_FAIL;
144
146
  }
145
147
  break;
146
148
  }
147
149
  io_uring_cqe_seen(&ring, cqe);
148
150
  }
149
151
 
150
- return 0;
152
+ io_uring_queue_exit(&ring);
153
+ close(evfd);
154
+ return T_EXIT_PASS;
155
+ }
156
+
157
+ int main(int argc, char *argv[])
158
+ {
159
+ int ret;
160
+
161
+ if (argc > 1)
162
+ return T_EXIT_SKIP;
163
+
164
+ ret = test(false);
165
+ if (ret != T_EXIT_PASS) {
166
+ fprintf(stderr, "%s: test(false) failed\n", argv[0]);
167
+ return ret;
168
+ }
169
+
170
+ if (t_probe_defer_taskrun()) {
171
+ ret = test(true);
172
+ if (ret != T_EXIT_PASS) {
173
+ fprintf(stderr, "%s: test(true) failed\n", argv[0]);
174
+ return ret;
175
+ }
176
+ }
177
+
178
+ return ret;
151
179
  }
@@ -13,6 +13,7 @@
13
13
  #include <sys/eventfd.h>
14
14
 
15
15
  #include "liburing.h"
16
+ #include "helpers.h"
16
17
 
17
18
  int main(int argc, char *argv[])
18
19
  {
@@ -21,39 +22,39 @@ int main(int argc, char *argv[])
21
22
  int ret, evfd[2], i;
22
23
 
23
24
  if (argc > 1)
24
- return 0;
25
+ return T_EXIT_SKIP;
25
26
 
26
27
  ret = io_uring_queue_init_params(8, &ring, &p);
27
28
  if (ret) {
28
29
  fprintf(stderr, "ring setup failed: %d\n", ret);
29
- return 1;
30
+ return T_EXIT_FAIL;
30
31
  }
31
32
 
32
33
  evfd[0] = eventfd(0, EFD_CLOEXEC);
33
34
  evfd[1] = eventfd(0, EFD_CLOEXEC);
34
35
  if (evfd[0] < 0 || evfd[1] < 0) {
35
36
  perror("eventfd");
36
- return 1;
37
+ return T_EXIT_FAIL;
37
38
  }
38
39
 
39
40
  ret = io_uring_register_eventfd(&ring, evfd[0]);
40
41
  if (ret) {
41
42
  fprintf(stderr, "failed to register evfd: %d\n", ret);
42
- return 1;
43
+ return T_EXIT_FAIL;
43
44
  }
44
45
 
45
46
  /* Check that registrering again will get -EBUSY */
46
47
  ret = io_uring_register_eventfd(&ring, evfd[1]);
47
48
  if (ret != -EBUSY) {
48
49
  fprintf(stderr, "unexpected 2nd register: %d\n", ret);
49
- return 1;
50
+ return T_EXIT_FAIL;
50
51
  }
51
52
  close(evfd[1]);
52
53
 
53
54
  ret = io_uring_unregister_eventfd(&ring);
54
55
  if (ret) {
55
56
  fprintf(stderr, "unexpected unregister: %d\n", ret);
56
- return 1;
57
+ return T_EXIT_FAIL;
57
58
  }
58
59
 
59
60
  /* loop 100 registers/unregister */
@@ -61,16 +62,16 @@ int main(int argc, char *argv[])
61
62
  ret = io_uring_register_eventfd(&ring, evfd[0]);
62
63
  if (ret) {
63
64
  fprintf(stderr, "failed to register evfd: %d\n", ret);
64
- return 1;
65
+ return T_EXIT_FAIL;
65
66
  }
66
67
 
67
68
  ret = io_uring_unregister_eventfd(&ring);
68
69
  if (ret) {
69
70
  fprintf(stderr, "unexpected unregister: %d\n", ret);
70
- return 1;
71
+ return T_EXIT_FAIL;
71
72
  }
72
73
  }
73
74
 
74
75
  close(evfd[0]);
75
- return 0;
76
+ return T_EXIT_PASS;
76
77
  }
@@ -13,6 +13,7 @@
13
13
  #include <sys/eventfd.h>
14
14
 
15
15
  #include "liburing.h"
16
+ #include "helpers.h"
16
17
 
17
18
  int main(int argc, char *argv[])
18
19
  {
@@ -22,45 +23,45 @@ int main(int argc, char *argv[])
22
23
  int ret, evfd1, evfd2;
23
24
 
24
25
  if (argc > 1)
25
- return 0;
26
+ return T_EXIT_SKIP;
26
27
 
27
28
  ret = io_uring_queue_init_params(8, &ring1, &p);
28
29
  if (ret) {
29
30
  fprintf(stderr, "ring setup failed: %d\n", ret);
30
- return 1;
31
+ return T_EXIT_FAIL;
31
32
  }
32
33
  if (!(p.features & IORING_FEAT_CUR_PERSONALITY)) {
33
34
  fprintf(stdout, "Skipping\n");
34
- return 0;
35
+ return T_EXIT_SKIP;
35
36
  }
36
37
  ret = io_uring_queue_init(8, &ring2, 0);
37
38
  if (ret) {
38
39
  fprintf(stderr, "ring setup failed: %d\n", ret);
39
- return 1;
40
+ return T_EXIT_FAIL;
40
41
  }
41
42
 
42
43
  evfd1 = eventfd(0, EFD_CLOEXEC);
43
44
  if (evfd1 < 0) {
44
45
  perror("eventfd");
45
- return 1;
46
+ return T_EXIT_FAIL;
46
47
  }
47
48
 
48
49
  evfd2 = eventfd(0, EFD_CLOEXEC);
49
50
  if (evfd2 < 0) {
50
51
  perror("eventfd");
51
- return 1;
52
+ return T_EXIT_FAIL;
52
53
  }
53
54
 
54
55
  ret = io_uring_register_eventfd(&ring1, evfd1);
55
56
  if (ret) {
56
57
  fprintf(stderr, "failed to register evfd: %d\n", ret);
57
- return 1;
58
+ return T_EXIT_FAIL;
58
59
  }
59
60
 
60
61
  ret = io_uring_register_eventfd(&ring2, evfd2);
61
62
  if (ret) {
62
63
  fprintf(stderr, "failed to register evfd: %d\n", ret);
63
- return 1;
64
+ return T_EXIT_FAIL;
64
65
  }
65
66
 
66
67
  sqe = io_uring_get_sqe(&ring1);
@@ -74,13 +75,13 @@ int main(int argc, char *argv[])
74
75
  ret = io_uring_submit(&ring1);
75
76
  if (ret != 1) {
76
77
  fprintf(stderr, "submit: %d\n", ret);
77
- return 1;
78
+ return T_EXIT_FAIL;
78
79
  }
79
80
 
80
81
  ret = io_uring_submit(&ring2);
81
82
  if (ret != 1) {
82
83
  fprintf(stderr, "submit: %d\n", ret);
83
- return 1;
84
+ return T_EXIT_FAIL;
84
85
  }
85
86
 
86
87
  sqe = io_uring_get_sqe(&ring1);
@@ -90,8 +91,8 @@ int main(int argc, char *argv[])
90
91
  ret = io_uring_submit(&ring1);
91
92
  if (ret != 1) {
92
93
  fprintf(stderr, "submit: %d\n", ret);
93
- return 1;
94
+ return T_EXIT_FAIL;
94
95
  }
95
96
 
96
- return 0;
97
+ return T_EXIT_PASS;
97
98
  }
@@ -13,6 +13,7 @@
13
13
  #include <sys/eventfd.h>
14
14
 
15
15
  #include "liburing.h"
16
+ #include "helpers.h"
16
17
 
17
18
  int main(int argc, char *argv[])
18
19
  {
@@ -28,28 +29,28 @@ int main(int argc, char *argv[])
28
29
  int ret, evfd, i;
29
30
 
30
31
  if (argc > 1)
31
- return 0;
32
+ return T_EXIT_SKIP;
32
33
 
33
34
  ret = io_uring_queue_init_params(8, &ring, &p);
34
35
  if (ret) {
35
36
  fprintf(stderr, "ring setup failed: %d\n", ret);
36
- return 1;
37
+ return T_EXIT_FAIL;
37
38
  }
38
39
  if (!(p.features & IORING_FEAT_CUR_PERSONALITY)) {
39
40
  fprintf(stdout, "Skipping\n");
40
- return 0;
41
+ return T_EXIT_SKIP;
41
42
  }
42
43
 
43
44
  evfd = eventfd(0, EFD_CLOEXEC);
44
45
  if (evfd < 0) {
45
46
  perror("eventfd");
46
- return 1;
47
+ return T_EXIT_FAIL;
47
48
  }
48
49
 
49
50
  ret = io_uring_register_eventfd(&ring, evfd);
50
51
  if (ret) {
51
52
  fprintf(stderr, "failed to register evfd: %d\n", ret);
52
- return 1;
53
+ return T_EXIT_FAIL;
53
54
  }
54
55
 
55
56
  sqe = io_uring_get_sqe(&ring);
@@ -65,7 +66,7 @@ int main(int argc, char *argv[])
65
66
  ret = io_uring_submit(&ring);
66
67
  if (ret != 2) {
67
68
  fprintf(stderr, "submit: %d\n", ret);
68
- return 1;
69
+ return T_EXIT_FAIL;
69
70
  }
70
71
 
71
72
  sqe = io_uring_get_sqe(&ring);
@@ -75,38 +76,38 @@ int main(int argc, char *argv[])
75
76
  ret = io_uring_submit(&ring);
76
77
  if (ret != 1) {
77
78
  fprintf(stderr, "submit: %d\n", ret);
78
- return 1;
79
+ return T_EXIT_FAIL;
79
80
  }
80
81
 
81
82
  for (i = 0; i < 3; i++) {
82
83
  ret = io_uring_wait_cqe(&ring, &cqe);
83
84
  if (ret) {
84
85
  fprintf(stderr, "wait: %d\n", ret);
85
- return 1;
86
+ return T_EXIT_FAIL;
86
87
  }
87
88
  switch (cqe->user_data) {
88
89
  case 1:
89
90
  /* POLLIN */
90
91
  if (cqe->res != 1) {
91
92
  fprintf(stderr, "poll: %d\n", cqe->res);
92
- return 1;
93
+ return T_EXIT_FAIL;
93
94
  }
94
95
  break;
95
96
  case 2:
96
97
  if (cqe->res != sizeof(ptr)) {
97
98
  fprintf(stderr, "read: %d\n", cqe->res);
98
- return 1;
99
+ return T_EXIT_FAIL;
99
100
  }
100
101
  break;
101
102
  case 3:
102
103
  if (cqe->res) {
103
104
  fprintf(stderr, "nop: %d\n", cqe->res);
104
- return 1;
105
+ return T_EXIT_FAIL;
105
106
  }
106
107
  break;
107
108
  }
108
109
  io_uring_cqe_seen(&ring, cqe);
109
110
  }
110
111
 
111
- return 0;
112
+ return T_EXIT_PASS;
112
113
  }
@@ -74,7 +74,7 @@ int main(int argc, char *argv[])
74
74
  const uint64_t n = 0x42;
75
75
 
76
76
  if (argc > 1)
77
- return 0;
77
+ return T_EXIT_SKIP;
78
78
 
79
79
  cpus = get_nprocs();
80
80
  res = pthread_barrier_init(&init_barrier, NULL, cpus);
@@ -73,7 +73,7 @@ static int do_fadvise(struct io_uring *ring, int fd, off_t offset, off_t len,
73
73
  if (ret == -EINVAL || ret == -EBADF) {
74
74
  fprintf(stdout, "Fadvise not supported, skipping\n");
75
75
  unlink(".fadvise.tmp");
76
- exit(0);
76
+ exit(T_EXIT_SKIP);
77
77
  } else if (ret) {
78
78
  fprintf(stderr, "cqe->res=%d\n", cqe->res);
79
79
  }
@@ -194,9 +194,9 @@ int main(int argc, char *argv[])
194
194
  if (fname != argv[1])
195
195
  unlink(fname);
196
196
  io_uring_queue_exit(&ring);
197
- return 0;
197
+ return T_EXIT_PASS;
198
198
  err:
199
199
  if (fname != argv[1])
200
200
  unlink(fname);
201
- return 1;
201
+ return T_EXIT_FAIL;
202
202
  }
@@ -14,6 +14,7 @@
14
14
  #include <fcntl.h>
15
15
 
16
16
  #include "liburing.h"
17
+ #include "helpers.h"
17
18
 
18
19
  static int no_fallocate;
19
20
 
@@ -66,14 +67,15 @@ static int test_fallocate_rlimit(struct io_uring *ring)
66
67
  if (cqe->res == -EINVAL) {
67
68
  fprintf(stdout, "Fallocate not supported, skipping\n");
68
69
  no_fallocate = 1;
69
- goto out;
70
+ goto skip;
70
71
  } else if (cqe->res != -EFBIG) {
71
72
  fprintf(stderr, "Expected -EFBIG: %d\n", cqe->res);
72
73
  goto err;
73
74
  }
74
75
  io_uring_cqe_seen(ring, cqe);
75
- out:
76
76
  return 0;
77
+ skip:
78
+ return T_EXIT_SKIP;
77
79
  err:
78
80
  return 1;
79
81
  }
@@ -116,7 +118,7 @@ static int test_fallocate(struct io_uring *ring)
116
118
  if (cqe->res == -EINVAL) {
117
119
  fprintf(stdout, "Fallocate not supported, skipping\n");
118
120
  no_fallocate = 1;
119
- goto out;
121
+ goto skip;
120
122
  }
121
123
  if (cqe->res) {
122
124
  fprintf(stderr, "cqe->res=%d\n", cqe->res);
@@ -135,8 +137,9 @@ static int test_fallocate(struct io_uring *ring)
135
137
  goto err;
136
138
  }
137
139
 
138
- out:
139
140
  return 0;
141
+ skip:
142
+ return T_EXIT_SKIP;
140
143
  err:
141
144
  return 1;
142
145
  }
@@ -219,17 +222,19 @@ int main(int argc, char *argv[])
219
222
  int ret;
220
223
 
221
224
  if (argc > 1)
222
- return 0;
225
+ return T_EXIT_SKIP;
223
226
 
224
227
  ret = io_uring_queue_init(8, &ring, 0);
225
228
  if (ret) {
226
229
  fprintf(stderr, "ring setup failed\n");
227
- return 1;
230
+ return T_EXIT_FAIL;
228
231
  }
229
232
 
230
233
  ret = test_fallocate(&ring);
231
234
  if (ret) {
232
- fprintf(stderr, "test_fallocate failed\n");
235
+ if (ret != T_EXIT_SKIP) {
236
+ fprintf(stderr, "test_fallocate failed\n");
237
+ }
233
238
  return ret;
234
239
  }
235
240
 
@@ -241,9 +246,11 @@ int main(int argc, char *argv[])
241
246
 
242
247
  ret = test_fallocate_rlimit(&ring);
243
248
  if (ret) {
244
- fprintf(stderr, "test_fallocate_rlimit failed\n");
249
+ if (ret != T_EXIT_SKIP) {
250
+ fprintf(stderr, "test_fallocate_rlimit failed\n");
251
+ }
245
252
  return ret;
246
253
  }
247
254
 
248
- return 0;
255
+ return T_EXIT_PASS;
249
256
  }
@@ -16,6 +16,7 @@
16
16
  #include <unistd.h>
17
17
 
18
18
  #include "liburing.h"
19
+ #include "helpers.h"
19
20
  #include "../src/syscall.h"
20
21
 
21
22
  static bool write_file(const char* file, const char* what, ...)
@@ -83,11 +84,11 @@ uint64_t r[2] = {0xffffffffffffffff, 0xffffffffffffffff};
83
84
  int main(int argc, char *argv[])
84
85
  {
85
86
  if (argc > 1)
86
- return 0;
87
+ return T_EXIT_SKIP;
87
88
  mmap((void *) 0x20000000ul, 0x1000000ul, 3ul, 0x32ul, -1, 0);
88
89
  if (setup_fault()) {
89
90
  printf("Test needs failslab/fail_futex/fail_page_alloc enabled, skipped\n");
90
- return 0;
91
+ return T_EXIT_SKIP;
91
92
  }
92
93
  intptr_t res = 0;
93
94
  *(uint32_t*)0x20000000 = 0;
@@ -127,5 +128,5 @@ int main(int argc, char *argv[])
127
128
  *(uint32_t*)0x20000080 = r[1];
128
129
  inject_fault(1);
129
130
  __sys_io_uring_register(r[0], 2ul, (const void *) 0x20000080ul, 1ul);
130
- return 0;
131
+ return T_EXIT_PASS;
131
132
  }