Skip to content

Commit

Permalink
adding a new unified C file build target
Browse files Browse the repository at this point in the history
  • Loading branch information
kavon committed Feb 1, 2018
1 parent 3113ae6 commit c3fb431
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 deletions.
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ dist/llvm-statepoint-tablegen.a: $(C_DEPS)
# $< gives first prereq
$(BUILD_ROOT)/%.o: $(SRC_ROOT)/%.c $(HEADERS)
$(CC) $(FLAGS) -c $< -o $@

unified:
# roll together the headers. api.h needs to come first so we sort the headers.
cat $(sort $(HEADERS)) >> $(BUILD_ROOT)/statepoint.h
# make the C file
echo "#include \"statepoint.h\"" > $(BUILD_ROOT)/statepoint.c
sed -E -e "s:[[:space:]]*#include[[:space:]]+\"include/.+\":// include auto-removed:g" $(C_SRCS) >> $(BUILD_ROOT)/statepoint.c
# ensure that it compiles
$(CC) -c $(BUILD_ROOT)/statepoint.c -o $(BUILD_ROOT)/statepoint.o

clean:
rm -f build/*
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ The currently supported [Stackmap Format](http://llvm.org/docs/StackMaps.html#st

<a name="caveat">\*</a> *almost*... we rely on the [packed attribute](https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html#Common-Type-Attributes)
supported by popular C compilers (*i.e.,* clang and gcc).

#### including these utils in your project

You can generate a single `.c` and corresponding `.h` file for inclusion in your own
build system. To do this, run `make unified`, and the output code will be placed under `build/`.

#### a fancier implementation

Expand Down
1 change: 1 addition & 0 deletions src/generate.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "include/stackmap.h"
#include "include/api.h"
#include "include/hash_table.h"

bool isBasePointer(value_location_t* first, value_location_t* second) {
Expand Down
2 changes: 2 additions & 0 deletions src/hash_table.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "include/api.h"
#include "include/hash_table.h"


/**
* The hash function used to distribute keys uniformly across the table.
* The implementation is one round of the xorshift64* algorithm.
Expand Down
2 changes: 0 additions & 2 deletions src/include/hash_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
#include <stdlib.h>
#include <string.h>

#include "api.h"

/** Functions **/

statepoint_table_t* new_table(float loadFactor, uint64_t expectedElms);
Expand Down

0 comments on commit c3fb431

Please sign in to comment.