Skip to content

Commit

Permalink
Add sample code illustration API usage via the MEMCPY AFU
Browse files Browse the repository at this point in the history
Signed-off-by: Alastair D'Silva <[email protected]>
  • Loading branch information
deece committed Apr 10, 2018
1 parent 2a7ad14 commit 3dfa896
Show file tree
Hide file tree
Showing 5 changed files with 560 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
.*.swp
obj/*
testobj/*
sampleobj/*
docs
cppcheck.xml
kernel/include/misc/ocxl.h
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ SONAMEOPT = -Wl,-soname,$(LIBSONAME)

DOCDIR = docs

all: check_ocxl_header obj/$(LIBSONAME) obj/libocxl.so obj/libocxl.a
all: check_ocxl_header obj/$(LIBSONAME) obj/libocxl.so obj/libocxl.a sampleobj/memcpy

HAS_WGET = $(shell /bin/which wget > /dev/null 2>&1 && echo y || echo n)
HAS_CURL = $(shell /bin/which curl > /dev/null 2>&1 && echo y || echo n)
Expand Down Expand Up @@ -48,9 +48,15 @@ obj/$(LIBNAME): $(OBJS) symver.map
obj/libocxl.a: $(OBJS)
$(call Q,AR, $(AR) rcs obj/libocxl.a $(OBJS), obj/libocxl.a)

sampleobj/memcpy: sampleobj/memcpy.o-memcpy
$(call Q,CC, $(CC) $(CFLAGS) $(LDFLAGS) -o sampleobj/memcpy sampleobj/memcpy.o-memcpy obj/libocxl.a, sampleobj/memcpy)

testobj:
mkdir testobj

sampleobj:
mkdir sampleobj

testobj/libocxl.a: $(TEST_OBJS)
$(call Q,AR, $(AR) rcs testobj/libocxl-temp.a $(TEST_OBJS), testobj/libocxl-temp.a)
$(call Q,STATIC_SYMS, $(NM) testobj/libocxl-temp.a | grep ' t ' | grep -v __ | cut -d ' ' -f 3 > testobj/static-syms)
Expand All @@ -75,7 +81,7 @@ cppcheck-xml:
cppcheck --enable=all -j 4 -q src/*.c src/include/libocxl.h --xml-version=2 2>cppcheck.xml

precommit: clean all docs cppcheck
astyle --style=linux --indent=tab=8 --max-code-length=120 src/*.c src/*.h src/include/*.h
astyle --style=linux --indent=tab=8 --max-code-length=120 src/*.c src/*.h src/include/*.h samples/*/*.c
$(call Q, SYMVER-CHECK, nm obj/$(LIBNAME) | grep ' t ocxl' && (echo "Symbols are missing from symver.map" && exit 1) || true)

docs:
Expand Down
5 changes: 4 additions & 1 deletion Makefile.rules
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ obj/%.o : src/%.c src/include/libocxl.h src/libocxl_internal.h | obj
testobj/%.o : src/%.c src/include/libocxl.h src/libocxl_internal.h | testobj
$(call Q,CC, $(CC) $(CPPFLAGS) $(TESTCFLAGS) -c -o $@ $<, $@)

testobj/%.o-test : unittests/%.c testobj/libocxl.a
testobj/%.o-test : unittests/%.c testobj/libocxl.a | testobj
$(call Q,CC, $(CC) $(CPPFLAGS) $(TESTCFLAGS) -c -o $@ $<, $@)

sampleobj/%.o-memcpy : samples/memcpy/%.c obj/libocxl.a | sampleobj
$(call Q,CC, $(CC) $(CPPFLAGS) $(TESTCFLAGS) -c -o $@ $<, $@)

datadir ?= $(PREFIX)/share
Expand Down
2 changes: 1 addition & 1 deletion Makefile.vars
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ LD = $(CROSS_COMPILE)ld
CC = $(CROSS_COMPILE)gcc
NM = $(CROSS_COMPILE)nm
OBJCOPY = $(CROSS_COMPILE)objcopy
CFLAGS ?= -g -Wall -Wextra -O2 -m64 -std=gnu99
CFLAGS ?= -g -Wall -Wextra -O2 -m64 -std=gnu11
TESTCFLAGS += $(CFLAGS) -O0 -DTEST_ENVIRONMENT=1 -I src -I testobj -pthread
Loading

0 comments on commit 3dfa896

Please sign in to comment.