commit 187585d02c1b0e010a55d86fdb6e9a00e0f07ae7 Author: flamingcow Date: Fri May 10 20:59:58 2019 -0700 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d0bc775 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.a +*.o +*.so diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..cf5cc10 --- /dev/null +++ b/Makefile @@ -0,0 +1,35 @@ +FIRE_CXX ?= clang++ +FIRE_CXXFLAGS ?= -O3 -std=gnu++2a -Wall -Werror -Wextra -fPIE -fPIC -fstack-protector-strong -fsanitize=safe-stack -fsanitize=safe-stack +FIRE_LDFLAGS ?= -fuse-ld=gold -flto -Wl,-z,relro -Wl,-z,now +FIRE_LDLIBS ?= -lglog + +all: fireusage.a fireusage.o fireusage.so + +objects = usage.o + +fireusage.a: $(objects) + ar rcs $@ $^ + +fireusage.o: $(objects) + gold -z relro -z now -r --output=$@ $+ + +fireusage.so: $(objects) + $(FIRE_CXX) $(FIRE_CXXFLAGS) $(FIRE_LDFLAGS) -shared -o $@ $+ $(FIRE_LDFLIBS) + +%.o: %.cc *.h Makefile + $(FIRE_CXX) $(FIRE_CXXFLAGS) -c -o $@ $< + +clean: + rm --force *.so *.o *.a + +asan: + $(MAKE) clean + FIRE_CXXFLAGS="-O1 -g -fsanitize=address -fno-omit-frame-pointer -std=gnu++2a -fPIE -fPIC" $(MAKE) all + +tsan: + $(MAKE) clean + FIRE_CXXFLAGS="-O1 -g -fsanitize=thread -std=gnu++2a -fPIE -fPIC" $(MAKE) all + +ubsan: + $(MAKE) clean + FIRE_CXXFLAGS="-O1 -g -fsanitize=undefined -std=gnu++2a -fPIE -fPIC" $(MAKE) all diff --git a/usage.cc b/usage.cc new file mode 100644 index 0000000..4d218ef --- /dev/null +++ b/usage.cc @@ -0,0 +1,9 @@ +#include "usage.h" + +namespace fireusage { + +UsageTracker::UsageTracker(const std::string_view& plural_resource_name) + : plural_resource_name_(plural_resource_name) { +} + +} // namespace fireusage diff --git a/usage.h b/usage.h new file mode 100644 index 0000000..6291e3b --- /dev/null +++ b/usage.h @@ -0,0 +1,15 @@ +#pragma once + +#include + +namespace fireusage { + +class UsageTracker { + public: + UsageTracker(const std::string_view& plural_resource_name); + + private: + const std::string plural_resource_name_; +}; + +} // namespace fireusage