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

Function init_buffers

examples/send-zerocopy.c:638–659  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

636}
637
638static void init_buffers(void)
639{
640 unsigned map_flags = MAP_PRIVATE | MAP_ANONYMOUS;
641 int i;
642
643 alloc_size = cfg_payload_len + PATTERN_SIZE;
644 alloc_size = (alloc_size + page_size - 1) / page_size * page_size;
645
646 if (cfg_hugetlb) {
647 size_t huge_size = 1 << 21;
648
649 alloc_size = (alloc_size + huge_size - 1) / huge_size * huge_size;
650 map_flags |= MAP_HUGETLB | MAP_HUGE_2MB;
651 }
652
653 payload = mmap(NULL, alloc_size, PROT_READ | PROT_WRITE, map_flags, -1, 0);
654 if (payload == MAP_FAILED)
655 t_error(0, 1, "buffer alloc failed (size %zu)\n", alloc_size);
656
657 for (i = 0; i < alloc_size; i++)
658 payload[i] = 'a' + (i % PATTERN_SIZE);
659}
660
661int main(int argc, char **argv)
662{

Callers 1

mainFunction · 0.70

Calls 1

t_errorFunction · 0.70

Tested by

no test coverage detected