t/axmap: print explicit overlap ranges tested
[fio.git] / io_u_queue.c
... / ...
CommitLineData
1#include <stdlib.h>
2#include "io_u_queue.h"
3
4bool io_u_qinit(struct io_u_queue *q, unsigned int nr)
5{
6 q->io_us = calloc(nr, sizeof(struct io_u *));
7 if (!q->io_us)
8 return false;
9
10 q->nr = 0;
11 q->max = nr;
12 return true;
13}
14
15void io_u_qexit(struct io_u_queue *q)
16{
17 free(q->io_us);
18}
19
20bool io_u_rinit(struct io_u_ring *ring, unsigned int nr)
21{
22 ring->max = nr + 1;
23 if (ring->max & (ring->max - 1)) {
24 ring->max--;
25 ring->max |= ring->max >> 1;
26 ring->max |= ring->max >> 2;
27 ring->max |= ring->max >> 4;
28 ring->max |= ring->max >> 8;
29 ring->max |= ring->max >> 16;
30 ring->max++;
31 }
32
33 ring->ring = calloc(ring->max, sizeof(struct io_u *));
34 if (!ring->ring)
35 return false;
36
37 ring->head = ring->tail = 0;
38 return true;
39}
40
41void io_u_rexit(struct io_u_ring *ring)
42{
43 free(ring->ring);
44}