Initial commit

This commit is contained in:
flamingcow
2019-05-10 20:59:58 -07:00
commit 187585d02c
4 changed files with 62 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
*.a
*.o
*.so

35
Makefile Normal file
View File

@@ -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

9
usage.cc Normal file
View File

@@ -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

15
usage.h Normal file
View File

@@ -0,0 +1,15 @@
#pragma once
#include <string>
namespace fireusage {
class UsageTracker {
public:
UsageTracker(const std::string_view& plural_resource_name);
private:
const std::string plural_resource_name_;
};
} // namespace fireusage