sq-full-cpp.cc 739 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include "../config-host.h"
  2. /* SPDX-License-Identifier: MIT */
  3. /*
  4. * Description: test SQ queue full condition
  5. *
  6. */
  7. #include <errno.h>
  8. #include <stdio.h>
  9. #include <unistd.h>
  10. #include <stdlib.h>
  11. #include <string.h>
  12. #include <fcntl.h>
  13. #include "liburing.h"
  14. int main(int argc, char *argv[])
  15. {
  16. struct io_uring_sqe *sqe;
  17. struct io_uring ring;
  18. int ret, i;
  19. if (argc > 1)
  20. return 0;
  21. ret = io_uring_queue_init(8, &ring, 0);
  22. if (ret) {
  23. fprintf(stderr, "ring setup failed: %d\n", ret);
  24. return 1;
  25. }
  26. i = 0;
  27. while ((sqe = io_uring_get_sqe(&ring)) != NULL)
  28. i++;
  29. if (i != 8) {
  30. fprintf(stderr, "Got %d SQEs, wanted 8\n", i);
  31. goto err;
  32. }
  33. io_uring_queue_exit(&ring);
  34. return 0;
  35. err:
  36. io_uring_queue_exit(&ring);
  37. return 1;
  38. }