/* A generic FIFO queue.
 * Define your own struct q_item which has room for a
 * next pointer at the beginning. That can be passed to the
 * macros. You pass values in order of struct definition to add
 * an item to the queue (we use vararg macro expansion for struct
 * literals).
 */
#include "mytypes.h"
#pragma once

struct queue
{
    int   length;
    void* head;
    void* tail;
};

#define q_nq(queue, ...)                                                                           \
    {                                                                                              \
        q_item* it = calloc(1, sizeof(q_item));                                                    \
        *it        = (q_item){ NULL, __VA_ARGS__ };                                                \
        _q_nq(queue, it);                                                                          \
    }

int q_length(struct queue* queue);

void _q_nq(struct queue* queue, void* item);

void* q_dq(struct queue* queue);

void q_clean(struct queue* queue);

struct queue* q_init();