From 9ac6d9fbfe07d3627a4e727fdff78aa67ec6a4c1 Mon Sep 17 00:00:00 2001 From: zenon Date: Wed, 30 May 2018 17:10:53 +0200 Subject: [PATCH] Boilerplate for shared memory --- Makefile | 5 +++-- common.h | 9 ++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index c39d318..2ffd0de 100644 --- a/Makefile +++ b/Makefile @@ -7,16 +7,17 @@ CC = gcc CFLAGS = -std=c99 -pedantic -Wall -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE -D_POSIX_C_SOURCE=200809L -g -c +LDFLAGS = -lrt -lpthread .PHONY: all clean docs docs_clean all: supervisor generator supervisor: supervisor.o - $(CC) $^ -o $@ + $(CC) $(LDFLAGS) $^ -o $@ generator: generator.o - $(CC) $^ -o $@ + $(CC) $(LDFLAGS) $^ -o $@ %.o: %.c common.h $(CC) $(CFLAGS) $^ diff --git a/common.h b/common.h index 1d2228a..3065459 100644 --- a/common.h +++ b/common.h @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -33,8 +34,14 @@ #define SEM_USED_SPACE "/sem_used_space_01527193" #define SEM_WRITE_END "/sem_write_end_01527193" +#define MAX_ITEMS 32 + struct circ_buf { - int id; + int quit; + int head; + int tail; + int validItems; + int data[MAX_ITEMS]; }; #endif /* ifndef COMMON_H */