Some tweaks in makefile
This commit is contained in:
parent
c1c1970d04
commit
c12682dd2a
15
Makefile
15
Makefile
@ -2,21 +2,25 @@
|
|||||||
|
|
||||||
CC = g++
|
CC = g++
|
||||||
CFLAGS_DEFAULT = -march=native -std=c++23
|
CFLAGS_DEFAULT = -march=native -std=c++23
|
||||||
CFLAGS_DEBUG = -Wall -Werror -Wno-uninitialized -O0 -fanalyzer -ggdb -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment
|
CFLAGS_DEBUG = -Wall -Werror -Wno-uninitialized -Wno-analyzer-use-of-uninitialized-value -fanalyzer -ggdb
|
||||||
CFLAGS_RELEASE = -static-libgcc -static-libstdc++ -static -Ofast -fdevirtualize-speculatively -fdata-sections -ffunction-sections -Wl,-gc-sections -Wl,-strip-all -Wl,-strip-discarded -flto -s -D_FORTIFY_SOURCE=2
|
CFLAGS_DEBUG_S = -O0 -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow
|
||||||
|
CFLAGS_DEBUG_F = -O1 -D_FORTIFY_SOURCE=3
|
||||||
|
CFLAGS_RELEASE = -static-libgcc -static-libstdc++ -static -Ofast -fdevirtualize-speculatively -fdata-sections -ffunction-sections -Wl,-gc-sections -Wl,-strip-all -Wl,-strip-discarded -flto -s -D_FORTIFY_SOURCE=3
|
||||||
|
|
||||||
SOURCES = src/stadium.hpp src/stadium.cpp src/kldr.hpp
|
SOURCES = src/stadium.hpp src/stadium.cpp src/kldr.hpp
|
||||||
SOURCES_TEST = src/test.cpp
|
SOURCES_TEST = src/test.cpp
|
||||||
#LINKED_LIBS = -l
|
#LINKED_LIBS = -l
|
||||||
OUTPUT_LIB = libstadium.so
|
OUTPUT_LIB = libstadium.so
|
||||||
OUTPUT_TEST_BIN = libstadiumtest
|
OUTPUT_TEST_BIN_S = libstadiumtest_sanitizer
|
||||||
|
OUTPUT_TEST_BIN_F = libstadiumtest_fortified
|
||||||
|
|
||||||
|
|
||||||
default: clean release_test
|
default: clean release_test
|
||||||
|
|
||||||
|
|
||||||
debug_test: $(SOURCES) $(SOURCES_TEST)
|
debug_test: $(SOURCES) $(SOURCES_TEST)
|
||||||
$(CC) $(CFLAGS_DEFAULT) $(CFLAGS_DEBUG) $(SOURCES) $(SOURCES_TEST) -o $(OUTPUT_TEST_BIN)
|
$(CC) $(CFLAGS_DEFAULT) $(CFLAGS_DEBUG) $(CFLAGS_DEBUG_S) $(SOURCES) $(SOURCES_TEST) -o $(OUTPUT_TEST_BIN_S)
|
||||||
|
$(CC) $(CFLAGS_DEFAULT) $(CFLAGS_DEBUG) $(CFLAGS_DEBUG_F) $(SOURCES) $(SOURCES_TEST) -o $(OUTPUT_TEST_BIN_F)
|
||||||
#$(LINKED_LIBS)
|
#$(LINKED_LIBS)
|
||||||
|
|
||||||
debug: $(SOURCES)
|
debug: $(SOURCES)
|
||||||
@ -30,5 +34,4 @@ release: $(SOURCES)
|
|||||||
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(OUTPUT_LIB)
|
rm -f $(OUTPUT_LIB) $(OUTPUT_TEST_BIN_S) $(OUTPUT_TEST_BIN_F)
|
||||||
rm -f $(OUTPUT_TEST_BIN)
|
|
BIN
libstadiumtest
BIN
libstadiumtest
Binary file not shown.
10
src/kldr.hpp
10
src/kldr.hpp
@ -166,22 +166,20 @@ class KLDRArray {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add new cell to array, fast version without keys check
|
// Add new cell to array, fast version without key checks
|
||||||
void AddF (KeyT key, LengthT length, void* data) {
|
void AddF (KeyT key, LengthT length, void* data) {
|
||||||
this->Keys.push_back(key);
|
this->Keys.push_back(key);
|
||||||
this->Lengths.push_back(length);
|
this->Lengths.push_back(length);
|
||||||
void* newData = operator new(length); // Yes, allocating memory for void pointer really looks like this
|
void* newData = operator new(length); // Yes, allocating memory for void pointer really looks like this
|
||||||
std::copy((uint8_t*)data, (uint8_t*)data + length, (uint8_t*)newData); // Dirty hacks, YES!
|
std::copy((char*)data, (char*)data + length, (char*)newData); // Dirty hacks, YES!
|
||||||
this->Values.push_back(newData);
|
this->Values.push_back(newData);
|
||||||
// NOTICE: there is `std::is_pod<SomeType>()`, so may be we can use one more template to make this a little more safe (may be)
|
// NOTICE: there is `std::is_pod<SomeType>()`, so may be we can use one more template to make this a little more safe (may be)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add new cell to array, but only if key is unique
|
||||||
void Add (KeyT key, LengthT length, void* data) {
|
void Add (KeyT key, LengthT length, void* data) {
|
||||||
for (size_t i = 0; i < this->CellsAmount(); i++) {
|
if (this->KeyExists(key))
|
||||||
if (this->Keys[i] == key) {
|
|
||||||
throw std::invalid_argument("supplied key already exist");
|
throw std::invalid_argument("supplied key already exist");
|
||||||
}
|
|
||||||
}
|
|
||||||
this->AddF(key, length, data);
|
this->AddF(key, length, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user