diff --git a/Makefile b/Makefile index 04c6dd3..cf67ffa 100644 --- a/Makefile +++ b/Makefile @@ -8,8 +8,6 @@ SRC_DIR ?= src TEST_DIR ?= test INC_DIRS ?= include -LIB := $(BUILD_DIR)/$(LIB_FILENAME) - SRCS != find '$(SRC_DIR)' -iname '*.c' SRCS_H != find $(INC_DIRS) -iname '*.h' SRCS_TEST != find '$(TEST_DIR)' -iname '*.c' @@ -42,7 +40,7 @@ all: vieter objs: $(OBJS) .PHONY: vieter -vieter: $(LIB) +vieter: $(BUILD_DIR)/$(LIB_FILENAME) $(BUILD_DIR)/$(LIB_FILENAME): $(OBJS) ar -rcs $@ $(OBJS) @@ -71,11 +69,10 @@ build-test: $(BINS_TEST) # For simplicity, we link every object file to each of the test files. This # might be changed later if this starts to become too slow. -$(BINS_TEST): %: %.c.o $(LIB) - $(CC) \ - $^ -o $@ +$(BINS_TEST): %: %.c.o $(OBJS) + $(CC) $^ -o $@ -# Along with the include directory, each test includes $(TEST_DIR) (which +# Allow with the include directory, each test includes $(TEST_DIR) (which # contains the acutest.h header file), and the src directory of the module it's # testing. This allows tests to access internal methods, which aren't publicly # exposed. diff --git a/README.md b/README.md index d1fef1a..0c33ab0 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ be implemented in C (or just parts I want to implement in C because it's fun). The goal of this library is to be as self-contained as possible; data structures should be implemented manually if possible. -See the [source code](src) for the list of modules. +See the [source code](/src) for the list of modules. ## Development @@ -43,7 +43,7 @@ only used in a .c file, the import should be placed in the .c file instead. This library uses [Acutest](https://github.com/mity/acutest) for its tests. Tests should be placed in the `test` subdirectory, further divided into -directories that correspond to those in `src`. Test files should begin with +directories that correspond those in `src`. Test files should begin with `test_`, and their format should follow the expected format for Acutest. Each `test_` is compiled separately into a binary, linked with libvieter. A diff --git a/include/vieter_cron.h b/include/vieter_cron.h index 459a49f..81a2630 100644 --- a/include/vieter_cron.h +++ b/include/vieter_cron.h @@ -37,7 +37,7 @@ typedef struct vieter_cron_simple_time { /* * Allocate and initialize a new empty cron expression. */ -vieter_cron_expression *vieter_cron_expr_init(); +vieter_cron_expression *ce_init(); /* * Deallocate a cron expression. diff --git a/include/vieter_heap.h b/include/vieter_heap.h index ce6f3a4..5d08ebc 100644 --- a/include/vieter_heap.h +++ b/include/vieter_heap.h @@ -11,7 +11,7 @@ typedef enum vieter_heap_error { } vieter_heap_error; /* - * Allocate and initialize an empty heap. + * Allocate and initalize an empty heap. */ vieter_heap *vieter_heap_init(); @@ -41,22 +41,4 @@ vieter_heap_error vieter_heap_pop(void **out, vieter_heap *heap); */ vieter_heap_error vieter_heap_peek(void **out, vieter_heap *heap); -/* - * Acquire a read lock on the heap. Return value is the result of - * pthread_rwlock_rdlock. - */ -int vieter_heap_rlock(vieter_heap *heap); - -/* - * Acquire a write lock on the heap. Return value is the result of - * pthread_rwlock_wrlock. - */ -int vieter_heap_wlock(vieter_heap *heap); - -/* - * Unlock the lock after having acquired it. Return value is the result of - * pthread_rwlock_unlock. - */ -int vieter_heap_unlock(vieter_heap *heap); - #endif diff --git a/src/heap/vieter_heap.c b/src/heap/vieter_heap.c index b10d94c..9d4ef8e 100644 --- a/src/heap/vieter_heap.c +++ b/src/heap/vieter_heap.c @@ -2,13 +2,7 @@ #include -vieter_heap *vieter_heap_init() { - vieter_heap *heap = calloc(1, sizeof(vieter_heap)); - - pthread_rwlock_init(&heap->lock, NULL); - - return heap; -} +vieter_heap *vieter_heap_init() { return calloc(1, sizeof(vieter_heap)); } uint64_t vieter_heap_size(vieter_heap *heap) { uint64_t size = 0; @@ -82,15 +76,3 @@ vieter_heap_error vieter_heap_peek(void **out, vieter_heap *heap) { return vieter_heap_ok; } - -int vieter_heap_rlock(vieter_heap *heap) { - return pthread_rwlock_rdlock(&heap->lock); -} - -int vieter_heap_wlock(vieter_heap *heap) { - return pthread_rwlock_wrlock(&heap->lock); -} - -int vieter_heap_unlock(vieter_heap *heap) { - return pthread_rwlock_unlock(&heap->lock); -} diff --git a/src/heap/vieter_heap_internal.h b/src/heap/vieter_heap_internal.h index 41850e9..8aaed53 100644 --- a/src/heap/vieter_heap_internal.h +++ b/src/heap/vieter_heap_internal.h @@ -1,8 +1,6 @@ #include "vieter_heap.h" #include "vieter_heap_tree.h" -#include struct vieter_heap { vieter_heap_node *tree; - pthread_rwlock_t lock; }; diff --git a/src/heap/vieter_heap_tree.h b/src/heap/vieter_heap_tree.h index 0a299db..c3bc55d 100644 --- a/src/heap/vieter_heap_tree.h +++ b/src/heap/vieter_heap_tree.h @@ -18,7 +18,7 @@ typedef struct vieter_heap_node { } vieter_heap_node; /* - * Allocate and initialize a heap node object. + * Allocate an initialize a heap node object. */ vieter_heap_node *vieter_heap_node_init();