Minor changes to compile the unbounded SPSC queue code
This commit is contained in:
parent
3a62bcdff5
commit
5cdd1c286f
6 changed files with 24 additions and 10 deletions
11
Makefile
11
Makefile
|
@ -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 $@
|
||||
|
|
6
memory.c
6
memory.c
|
@ -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__
|
||||
|
|
5
memory.h
5
memory.h
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
#ifdef __linux__
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
|
Loading…
Add table
Reference in a new issue