Commit 86bab810 authored by Anders Blomdell's avatar Anders Blomdell
Browse files

More C cleanups

parent 9056ba1e
......@@ -23,7 +23,7 @@ OBJS=labcomm$(VERSION).o \
labcomm$(VERSION)_fd_writer.o \
labcomm$(VERSION)_pthread_scheduler.o
LABCOMM_JAR=../../../compiler/labcomm$(VERSION)_compiler.jar
LABCOMM_JAR=../../../compiler/labcomm$(LIBVERSION)_compiler.jar
LABCOMM=java -jar $(LABCOMM_JAR)
TESTS=test_labcomm_basic_type_encoding \
......@@ -36,8 +36,6 @@ TESTS=test_labcomm_basic_type_encoding \
TEST_DIR=test
#VPATH=$(TEST_DIR)
## Targets
.PHONY: all
......@@ -57,9 +55,6 @@ clean:
$(RM) test/testdata/gen/*.[cho]
$(RM) test/gen/*.[cho]
$(RM) -rf test/gen
for x in $(TESTS); do \
$(RM) $(TEST_DIR)/$$x ; \
done
.PHONY: distclean
distclean: clean
......@@ -80,35 +75,46 @@ distclean: clean
%.o: %.c %.h
$(CC) $(CFLAGS) -c -o $@ $<
# rules invoked by 'test'
.PHONY: run-test-%
run-test-%: $(TEST_DIR)/gen/% | $(TEST_DIR)/gen
$<
.PRECIOUS: $(TEST_DIR)/gen/%
$(TEST_DIR)/gen/%: $(TEST_DIR)/gen/%.o | $(TEST_DIR)/gen
$(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS)
$(TEST_DIR)/gen/%.o: $(TEST_DIR)/%.c | $(TEST_DIR)/gen
$(CC) $(CFLAGS_TEST) -o $@ -c $<
# Extra compilation dependencies
labcomm_fd_reader.o: \
labcomm_private.h
labcomm_fd_writer.o: \
labcomm_private.h
labcomm_dynamic_buffer_writer.o: \
labcomm_private.h
$(TEST_DIR)/gen/%.c $(TEST_DIR)/gen/%.h: $(TEST_DIR)/%.lc | $(TEST_DIR)/gen
$(LABCOMM) \
--c=$(TEST_DIR)/gen/$*.c \
--h=$(TEST_DIR)/gen/$*.h \
$<
$(LABCOMM_JAR):
@echo "======Building LabComm compiler======"
cd $(shell dirname $(LABCOMM_JAR)); ant jar
@echo "======End building LabComm compiler======"
$(TEST_DIR)/gen:
mkdir -p $@
# Extra compilation dependencies
labcomm$(VERSION).o: \
labcomm$(VERSION).c \
labcomm$(VERSION).h \
labcomm$(VERSION)_private.h
labcomm$(VERSION)_fd_reader_writer.o: \
labcomm$(VERSION)_fd_reader_writer.c \
labcomm$(VERSION)_fd_reader_writer.h \
labcomm$(VERSION).h \
labcomm$(VERSION)_fd_reader.o: \
labcomm$(VERSION)_private.h
labcomm$(VERSION)_fd_writer.o: \
labcomm$(VERSION)_private.h
labcomm$(VERSION)_dynamic_buffer_writer.o: \
labcomm$(VERSION)_private.h
$(TEST_DIR)/gen/test_labcomm_basic_type_encoding.o: \
......@@ -136,34 +142,3 @@ $(TEST_DIR)/gen/test_labcomm_copy: \
$(TEST_DIR)/gen/generated_encoding.o \
$(TEST_DIR)/gen/test_sample.o \
$(TEST_DIR)/gen/more_types.o
#$(TEST_DIR)/labcomm_mem_reader.o: labcomm_fd_reader_writer.c labcomm_fd_reader_writer.h
#$(TEST_DIR)/labcomm_mem_writer.o: labcomm_mem_writer.c labcomm_mem_writer.h cppmacros.h
ethaddr.o: ethaddr.c
.PRECIOUS: $(TEST_DIR)/%
$(TEST_DIR)/gen:
mkdir -p $@
.PRECIOUS: $(TEST_DIR)/gen/%.c
.PRECIOUS: $(TEST_DIR)/gen/%.h
$(TEST_DIR)/gen/%.c $(TEST_DIR)/gen/%.h: $(TEST_DIR)/%.lc | $(TEST_DIR)/gen
$(LABCOMM) \
--c=$(TEST_DIR)/gen/$*.c \
--h=$(TEST_DIR)/gen/$*.h \
$<
$(TEST_GEN_DIR)/%.c $(TEST_GEN_DIR)/%.h: $(TESTDATA_DIR)/%.lc \
$(LABCOMM_JAR) | $(TEST_GEN_DIR)
$(LABCOMM) \
--c=$(patsubst %.h,%.c,$@) --h=$(patsubst %.c,%.h,$@) $<
$(LABCOMM_JAR):
@echo "======Building LabComm compiler======"
cd $(shell dirname $(LABCOMM_JAR)); ant jar
@echo "======End building LabComm compiler======"
......@@ -15,6 +15,7 @@
#ifdef __INT64_MAX__
#undef INT64_MAX
#define INT64_MAX __INT64_MAX__
#endif
#if (CPU == PPC603)
#undef _LITTLE_ENDIAN
......
......@@ -23,42 +23,39 @@ OBJS=labcomm$(VERSION).o \
labcomm$(VERSION)_fd_writer.o \
labcomm$(VERSION)_pthread_scheduler.o
#FIXME: labcomm_mem_reader.o labcomm_mem_writer.o
LABCOMM_JAR=../../../compiler/labcomm_compiler.jar
# Enable experimental objects by `make LABCOMM_EXPERIMENTAL=true`
ifeq ($(LABCOMM_EXPERIMENTAL),true)
OBJS += experimental/udp_hack.o experimental/ethaddr.o \
experimental/labcomm_thr_reader_writer.o \
experimental/ThrottleDrv/ethernet_drv.o \
experimental/ThrottleDrv/throttle_drv.o \
experimental/labcomm_udp_reader_writer.o\
experimental/labcomm_sig_parser.o
endif
LABCOMM_JAR=../../../compiler/labcomm$(LIBVERSION)_compiler.jar
LABCOMM=java -jar $(LABCOMM_JAR)
TESTS=test_labcomm_basic_type_encoding test_labcomm_generated_encoding \
TESTS=test_labcomm_basic_type_encoding \
test_labcomm_generated_encoding \
test_signature_numbers \
test_labcomm \
test_labcomm_pthread_scheduler \
test_labcomm_copy
#
#FIXME: test_labcomm test_labcomm_errors
TEST_DIR=test
#FIXME: test_labcomm_errors
VPATH=$(TEST_DIR)
# Enable experimental objects by invoking make like `make LABCOMM_EXPERIMENTAL=true`
ifeq ($(LABCOMM_EXPERIMENTAL),true)
OBJS += experimental/udp_hack.o experimental/ethaddr.o \
experimental/labcomm_thr_reader_writer.o \
experimental/ThrottleDrv/ethernet_drv.o \
experimental/ThrottleDrv/throttle_drv.o \
experimental/labcomm_udp_reader_writer.o\
experimental/labcomm_sig_parser.o
TEST_DIR=test
experimental/test_sig_parser : experimental/labcomm_sig_parser.o experimental/test_sig_parser.c
endif
## Targets
.PHONY: all run-test clean distclean
.PHONY: all
all: $(ALL_DEPS)
.PHONY: test
test: all $(TESTS:%=run-test-%)
.PHONY: clean
clean:
$(RM) *.o
$(RM) experimental/*.o
......@@ -68,102 +65,96 @@ clean:
$(RM) test/test_labcomm_errors
$(RM) test/testdata/gen/*.[cho]
$(RM) test/gen/*.[cho]
-rmdir test/gen
for x in $(TESTS); do \
$(RM) $(TEST_DIR)/$$x ; \
done
$(RM) -rf test/gen
.PHONY: distclean
distclean: clean
$(RM) ../liblabcomm$(LIBVERSION).so.1
$(RM) ../liblabcomm$(LIBVERSION).a
# rules invoked by 'all'
../liblabcomm$(LIBVERSION).so.1: $(OBJS:%.o=%.pic.o)
$(call MAKESHARED,$@,$@,$^)
../liblabcomm$(LIBVERSION).a: $(OBJS)
ar -r $@ $^
../liblabcomm$(LIBVERSION).so.1: $(OBJS:%.o=%.pic.o)
$(call MAKESHARED,$@,$@,$^)
# Enable experimental objects by `make LABCOMM_EXPERIMENTAL=true`
ifeq ($(LABCOMM_EXPERIMENTAL),true)
experimental/test_sig_parser : experimental/labcomm_sig_parser.o experimental/test_sig_parser.c
endif
# compilation rules
%.pic.o: %.c
$(CC) -fPIC $(CFLAGS) -c -o $@ $<
%.o: %.c %.h
$(CC) $(CFLAGS) -c -o $@ $<
# rules invoked by 'test'
# Extra compilation dependencies
labcomm$(VERSION).o: \
labcomm$(VERSION).c \
labcomm$(VERSION).h \
labcomm$(VERSION)_private.h
labcomm$(VERSION)_fd_reader_writer.o: \
labcomm$(VERSION)_fd_reader_writer.c \
labcomm$(VERSION)_fd_reader_writer.h \
labcomm$(VERSION).h \
labcomm$(VERSION)_private.h
labcomm.o : labcomm.c labcomm.h labcomm_private.h
labcomm_fd_reader_writer.o : labcomm_fd_reader_writer.c labcomm_fd_reader_writer.h labcomm.h labcomm_private.h
2006/labcomm2006.o : 2006/labcomm2006.c 2006/labcomm2006.h 2006/labcomm2006_private.h
2006/labcomm2006_fd_reader_writer.o : 2006/labcomm2006_fd_reader_writer.c 2006/labcomm2006_fd_reader_writer.h labcomm.h 2006/labcomm2006_private.h
#$(TEST_DIR)/labcomm_mem_reader.o: labcomm_fd_reader_writer.c labcomm_fd_reader_writer.h
#$(TEST_DIR)/labcomm_mem_writer.o: labcomm_mem_writer.c labcomm_mem_writer.h cppmacros.h
ethaddr.o: ethaddr.c
run-test-%: $(TEST_DIR)/% | $(TEST_DIR)
.PHONY: run-test-%
run-test-%: $(TEST_DIR)/gen/% | $(TEST_DIR)/gen
$<
$(TEST_DIR)/%.o: $(TEST_DIR)/%.c
$(CC) $(CFLAGS) -o $@ -c $<
.PRECIOUS: $(TEST_DIR)/gen/%
.PRECIOUS: $(TEST_DIR)/%
$(TEST_DIR)/%: $(TEST_DIR)/%.o
$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
$(TEST_DIR)/gen/%: $(TEST_DIR)/gen/%.o | $(TEST_DIR)/gen
$(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS)
$(TEST_DIR)/gen:
mkdir -p $@
$(TEST_DIR)/gen/%.o: $(TEST_DIR)/%.c | $(TEST_DIR)/gen
$(CC) $(CFLAGS_TEST) -o $@ -c $<
.PRECIOUS: $(TEST_DIR)/gen/%.c
.PRECIOUS: $(TEST_DIR)/gen/%.h
$(TEST_DIR)/gen/%.c $(TEST_DIR)/gen/%.h: $(TEST_DIR)/%.lc | $(TEST_DIR)/gen
$(LABCOMM) \
--c=$(TEST_DIR)/gen/$*.c \
--h=$(TEST_DIR)/gen/$*.h \
$<
$(TEST_GEN_DIR)/%.c $(TEST_GEN_DIR)/%.h: $(TESTDATA_DIR)/%.lc \
$(LABCOMM_JAR) | $(TEST_GEN_DIR)
$(LABCOMM) \
--c=$(patsubst %.h,%.c,$@) --h=$(patsubst %.c,%.h,$@) $<
$(LABCOMM_JAR):
@echo "======Building LabComm compiler======"
cd $(shell dirname $(LABCOMM_JAR)); ant jar
@echo "======End building LabComm compiler======"
$(TEST_DIR)/gen:
mkdir -p $@
# Extra compilation dependencies
labcomm$(VERSION).o: \
labcomm$(VERSION).c \
labcomm$(VERSION).h \
labcomm$(VERSION)_private.h
labcomm$(VERSION)_fd_reader.o: \
labcomm$(VERSION)_private.h
labcomm$(VERSION)_fd_writer.o: \
labcomm$(VERSION)_private.h
labcomm$(VERSION)_dynamic_buffer_writer.o: \
labcomm$(VERSION)_private.h
$(TEST_DIR)/gen/test_labcomm_basic_type_encoding.o: \
labcomm$(VERSION)_private.h
$(TEST_DIR)/gen/test_labcomm_generated_encoding.o: \
labcomm$(VERSION)_private.h \
$(TEST_DIR)/gen/generated_encoding.h
$(TEST_DIR)/gen/test_labcomm_generated_encoding: \
$(TEST_DIR)/gen/generated_encoding.o
$(TEST_DIR)/gen/test_signature_numbers.c: \
$(TEST_DIR)/gen/another_encoding.h \
$(TEST_DIR)/gen/generated_encoding.h
# Extra dependencies
$(TEST_DIR)/test_labcomm_basic_type_encoding.o: labcomm_private.h
$(TEST_DIR)/gen/test_signature_numbers: \
$(TEST_DIR)/gen/another_encoding.o \
$(TEST_DIR)/gen/generated_encoding.o
$(TEST_DIR)/test_labcomm_generated_encoding.o: labcomm_private.h
$(TEST_DIR)/test_labcomm_generated_encoding.o: $(TEST_DIR)/gen/generated_encoding.h
$(TEST_DIR)/test_labcomm_generated_encoding : $(TEST_DIR)/gen/generated_encoding.o
$(TEST_DIR)/gen/test_labcomm: \
$(TEST_DIR)/gen/test_sample.o
$(TEST_DIR)/test_labcomm: $(TEST_DIR)/gen/test_sample.o
$(TEST_DIR)/test_signature_numbers.c: $(TEST_DIR)/gen/another_encoding.h
$(TEST_DIR)/test_signature_numbers.c: $(TEST_DIR)/gen/generated_encoding.h
$(TEST_DIR)/test_signature_numbers: $(TEST_DIR)/gen/another_encoding.o
$(TEST_DIR)/test_signature_numbers: $(TEST_DIR)/gen/generated_encoding.o
$(TEST_DIR)/test_labcomm_copy: $(TEST_DIR)/gen/generated_encoding.o $(TEST_DIR)/gen/test_sample.o $(TEST_DIR)/gen/more_types.o
labcomm_fd_reader.o: labcomm_private.h
labcomm_fd_writer.o: labcomm_private.h
labcomm_dynamic_buffer_writer.o: labcomm_private.h
$(TEST_DIR)/gen/test_labcomm_copy: \
$(TEST_DIR)/gen/generated_encoding.o \
$(TEST_DIR)/gen/test_sample.o \
$(TEST_DIR)/gen/more_types.o
......@@ -186,6 +186,8 @@ int main(void)
labcomm_default_error_handler,
labcomm_default_memory,
labcomm_pthread_scheduler_new(labcomm_default_memory));
EXPECT({ 0x01, 0x0c, 0x0b,
'L', 'a', 'b', 'C', 'o', 'm', 'm', '2','0', '1', '4' });
labcomm_encoder_ioctl(encoder, IOCTL_WRITER_RESET);
/* Register twice to make sure that only one registration gets encoded */
......
......@@ -48,8 +48,12 @@ if __name__ == '__main__':
print "Only in %s:" %sys.argv[4], b.path
b = B.next()
else:
print a.path, b.path
print ''.join(difflib.unified_diff(a.lines, b.lines,
a.path, b.path))
equal = True
for l in difflib.unified_diff(a.lines, b.lines, a.path, b.path):
print l,
equal = False
if equal:
print "Identical", a.path, b.path
a = A.next()
b = B.next()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment