Minor changes to compile the unbounded SPSC queue code

This commit is contained in:
Umar Farooq 2016-09-09 14:39:50 +02:00
parent 3a62bcdff5
commit 5cdd1c286f
6 changed files with 24 additions and 10 deletions

View file

@ -1,4 +1,5 @@
TARGETS = spsc_ub_test mpmc_test spsc_test
#TARGETS = spsc_ub_test mpmc_test spsc_test
TARGETS = spsc_ub_test
CFLAGS = -Wall -std=c11
DEBUG ?= 1
@ -16,11 +17,11 @@ all: $(TARGETS)
spsc_ub_test: spsc_ub_test.o spsc_ub_queue.o memory.o
$(CC) $^ -Wall $(LIBS) -o $@
mpmc_test: mpmc_test.o mpmc_queue.o memory.o
$(CC) $^ -Wall $(LIBS) -o $@
#mpmc_test: mpmc_test.o mpmc_queue.o memory.o
# $(CC) $^ -Wall $(LIBS) -o $@
spsc_test: spsc_test.o spsc_queue.o memory.o
$(CC) $^ -Wall $(LIBS) -o $@
#spsc_test: spsc_test.o spsc_queue.o memory.o
# $(CC) $^ -Wall $(LIBS) -o $@
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@

View file

@ -1,9 +1,13 @@
/**
*
*/
#ifdef __linux__
#define _GNU_SOURCE
#endif
#include <stdlib.h>
#include <sys/mman.h>
#include <stdio.h> //DELETEME
/* Required to allocate hugepages on Apple OS X */
#ifdef __MACH__

View file

@ -5,6 +5,11 @@
#ifndef _MEMORY_H_
#define _MEMORY_H_
#ifdef __linux__
#include <stdint.h>
#include <stddef.h>
#endif
typedef void *(*memzone_allocator_t)(size_t);
typedef int (*memzone_deallocator_t)(void *, size_t);

View file

@ -35,9 +35,8 @@
void spsc_ub_queue_init(struct spsc_ub_queue* q, size_t size, const struct memtype *mem)
{
struct node* n = memory_alloc(q->mem, sizeof(struct node) * size);
q->mem = mem;
struct node* n = memory_alloc(q->mem, sizeof(struct node) * size);
n->_next = NULL;
q->_tail = q->_head = q->_first= q->_tailcopy = n;

View file

@ -38,8 +38,9 @@
#include "memory.h"
static size_t const cacheline_size = 64;
typedef char cacheline_pad_t[cacheline_size];
//static size_t const cacheline_size = 64;
#define CACHELINE_SIZE 64
typedef char cacheline_pad_t[CACHELINE_SIZE];
struct node {
struct node * _Atomic _next; /**> Single linked list of nodes */

View file

@ -1,3 +1,7 @@
#ifdef __linux__
#define _GNU_SOURCE
#endif
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>