MCPcopy Create free account
hub / github.com/axboe/liburing / main

Function main

test/send-zerocopy.c:861–990  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

859}
860
861int main(int argc, char *argv[])
862{
863 size_t len;
864 int ret, i;
865
866 if (argc > 1)
867 return T_EXIT_SKIP;
868
869 ret = probe_zc_support();
870 if (ret) {
871 printf("probe failed\n");
872 return T_EXIT_FAIL;
873 }
874 if (!has_sendzc) {
875 printf("no IORING_OP_SEND_ZC support, skip\n");
876 return T_EXIT_SKIP;
877 }
878
879 page_sz = sysconf(_SC_PAGESIZE);
880
881 if (try_hugepages) {
882 len = LARGE_BUF_SIZE;
883 tx_buffer = t_aligned_alloc(page_sz, len);
884 rx_buffer = t_aligned_alloc(page_sz, len);
885
886 if (tx_buffer && rx_buffer) {
887 buffers_iov[BUF_T_LARGE].iov_base = tx_buffer;
888 buffers_iov[BUF_T_LARGE].iov_len = len;
889 } else {
890 printf("skip large buffer tests, can't alloc\n");
891 free_buffers();
892 }
893 }
894
895 if (!tx_buffer) {
896 len = 2 * page_sz;
897 tx_buffer = t_aligned_alloc(page_sz, len);
898 rx_buffer = t_aligned_alloc(page_sz, len);
899
900 if (!tx_buffer || !rx_buffer) {
901 fprintf(stderr, "can't allocate buffers\n");
902 return T_EXIT_FAIL;
903 }
904 }
905
906 srand((unsigned)time(NULL));
907 for (i = 0; i < len; i++)
908 tx_buffer[i] = i;
909 memset(rx_buffer, 0, len);
910
911 buffers_iov[BUF_T_NORMAL].iov_base = tx_buffer + page_sz;
912 buffers_iov[BUF_T_NORMAL].iov_len = page_sz;
913 buffers_iov[BUF_T_SMALL].iov_base = tx_buffer;
914 buffers_iov[BUF_T_SMALL].iov_len = 137;
915 buffers_iov[BUF_T_NONALIGNED].iov_base = tx_buffer + BUFFER_OFFSET;
916 buffers_iov[BUF_T_NONALIGNED].iov_len = 2 * page_sz - BUFFER_OFFSET - 13;
917
918 if (len == LARGE_BUF_SIZE) {

Callers

nothing calls this directly

Calls 8

probe_zc_supportFunction · 0.85
free_buffersFunction · 0.85
run_basic_testsFunction · 0.85
io_uring_queue_initFunction · 0.85
t_register_buffersFunction · 0.85
test_inet_sendFunction · 0.85
io_uring_queue_exitFunction · 0.85
t_aligned_allocFunction · 0.70

Tested by

no test coverage detected