Boilerplate for shared memory
This commit is contained in:
parent
93303f19e1
commit
9ac6d9fbfe
5
Makefile
5
Makefile
@ -7,16 +7,17 @@
|
|||||||
|
|
||||||
CC = gcc
|
CC = gcc
|
||||||
CFLAGS = -std=c99 -pedantic -Wall -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE -D_POSIX_C_SOURCE=200809L -g -c
|
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
|
.PHONY: all clean docs docs_clean
|
||||||
|
|
||||||
all: supervisor generator
|
all: supervisor generator
|
||||||
|
|
||||||
supervisor: supervisor.o
|
supervisor: supervisor.o
|
||||||
$(CC) $^ -o $@
|
$(CC) $(LDFLAGS) $^ -o $@
|
||||||
|
|
||||||
generator: generator.o
|
generator: generator.o
|
||||||
$(CC) $^ -o $@
|
$(CC) $(LDFLAGS) $^ -o $@
|
||||||
|
|
||||||
%.o: %.c common.h
|
%.o: %.c common.h
|
||||||
$(CC) $(CFLAGS) $^
|
$(CC) $(CFLAGS) $^
|
||||||
|
|||||||
9
common.h
9
common.h
@ -14,6 +14,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
@ -33,8 +34,14 @@
|
|||||||
#define SEM_USED_SPACE "/sem_used_space_01527193"
|
#define SEM_USED_SPACE "/sem_used_space_01527193"
|
||||||
#define SEM_WRITE_END "/sem_write_end_01527193"
|
#define SEM_WRITE_END "/sem_write_end_01527193"
|
||||||
|
|
||||||
|
#define MAX_ITEMS 32
|
||||||
|
|
||||||
struct circ_buf {
|
struct circ_buf {
|
||||||
int id;
|
int quit;
|
||||||
|
int head;
|
||||||
|
int tail;
|
||||||
|
int validItems;
|
||||||
|
int data[MAX_ITEMS];
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* ifndef COMMON_H */
|
#endif /* ifndef COMMON_H */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user