Clean up the Linux side of the build.
CLion on Windows missed a lot of stuff.
This commit is contained in:
parent
f727ce4b5a
commit
36af6ac1f8
22
Arena.cc
22
Arena.cc
|
@ -69,18 +69,18 @@ AllocNewArena(Arena & arena, size_t size)
|
|||
|
||||
#if defined(__linux__)
|
||||
int
|
||||
MMapArena(Arena &arena, int fd, size_t Size)
|
||||
MMapArena(Arena &arena, int fd, size_t size)
|
||||
{
|
||||
if (arena.Size > 0) {
|
||||
if (arena_destroy(arena) != 0) {
|
||||
if (DestroyArena(arena) != 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
arena.Type = ARENA_MMAP;
|
||||
arena.Size = Size;
|
||||
arena.store = (uint8_t *)mmap(NULL, Size, PROT_RW, MAP_SHARED, fd, 0);
|
||||
if ((void *)arena.store == MAP_FAILED) {
|
||||
arena.Size = size;
|
||||
arena.Store = (uint8_t *)mmap(NULL, size, PROT_RW, MAP_SHARED, fd, 0);
|
||||
if ((void *)arena.Store == MAP_FAILED) {
|
||||
return -1;
|
||||
}
|
||||
arena.fd = fd;
|
||||
|
@ -94,7 +94,7 @@ OpenArena(Arena &arena, const char *path)
|
|||
struct stat st;
|
||||
|
||||
if (arena.Size > 0) {
|
||||
if (arena_destroy(arena) != 0) {
|
||||
if (DestroyArena(arena) != 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -113,12 +113,12 @@ OpenArena(Arena &arena, const char *path)
|
|||
|
||||
|
||||
int
|
||||
CreateArena(Arena &arena, const char *path, size_t Size, mode_t mode)
|
||||
CreateArena(Arena &arena, const char *path, size_t size, mode_t mode)
|
||||
{
|
||||
int fd = 0;
|
||||
|
||||
if (arena.Size > 0) {
|
||||
if (arena_destroy(arena) != 0) {
|
||||
if (DestroyArena(arena) != 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ CreateArena(Arena &arena, const char *path, size_t Size, mode_t mode)
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (ftruncate(fd, Size) == -1) {
|
||||
if (ftruncate(fd, size) == -1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,7 @@ DestroyArena(Arena &arena)
|
|||
break;
|
||||
#if defined(__linux__)
|
||||
case ARENA_MMAP:
|
||||
if (munmap(arena.store, arena.Size) == -1) {
|
||||
if (munmap(arena.Store, arena.Size) == -1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -219,7 +219,7 @@ DisplayArena(const Arena &arena)
|
|||
break;
|
||||
#if defined(__linux__)
|
||||
case ARENA_MMAP:
|
||||
std::cout << "mmap/file"
|
||||
std::cout << "mmap/file";
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
|
|
3
Arena.h
3
Arena.h
|
@ -38,8 +38,7 @@ int DestroyArena(Arena &); /* dispose of any memory used by arena */
|
|||
* BACKING FILE! */
|
||||
int WriteArena(const Arena &arena, const char *path);
|
||||
|
||||
void
|
||||
DisplayArena(const Arena &arena);
|
||||
void DisplayArena(const Arena &arena);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -135,17 +135,17 @@ Dictionary::DumpKVPairs()
|
|||
}
|
||||
|
||||
}
|
||||
#else
|
||||
void
|
||||
Dictionary::DumpKVPairs()
|
||||
{
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void
|
||||
Dictionary::DumpToFile(const char *path)
|
||||
{
|
||||
WriteArena(this->arena, path);
|
||||
}
|
||||
|
||||
#else
|
||||
void
|
||||
Dictionary::dump_kvpairs()
|
||||
{
|
||||
|
||||
}
|
||||
#endif
|
||||
|
|
6
Makefile
6
Makefile
|
@ -5,7 +5,7 @@ SOURCES := $(wildcard *.cc)
|
|||
OBJS := Arena.o Dictionary.o TLV.o
|
||||
|
||||
CXX := clang++
|
||||
CXXFLAGS := -g -std=c++14 -Werror -Wall
|
||||
CXXFLAGS := -g -std=c++14 -Werror -Wall -DDESKTOP_BUILD
|
||||
|
||||
.PHONY: all
|
||||
all: $(TARGET) $(TESTS) tags run-tests
|
||||
|
@ -17,10 +17,10 @@ $(TARGET): $(OBJS)
|
|||
$(AR) rcs $@ $(OBJS)
|
||||
|
||||
tlv_test: tlvTest.o $(TARGET)
|
||||
$(CXX) -o $@ $(CXXFLAGS) $@.o $(TARGET)
|
||||
$(CXX) -o $@ $(CXXFLAGS) tlvTest.o $(TARGET)
|
||||
|
||||
dictionary_test: dictionaryTest.o $(TARGET)
|
||||
$(CXX) -o $@ $(CXXFLAGS) $@.o $(TARGET)
|
||||
$(CXX) -o $@ $(CXXFLAGS) dictionaryTest.o $(TARGET)
|
||||
|
||||
.PHONY: print-%
|
||||
print-%: ; @echo '$(subst ','\'',$*=$($*))'
|
||||
|
|
Binary file not shown.
|
@ -2,6 +2,9 @@
|
|||
#define KLIB_TESTFIXTURES_H
|
||||
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#define ARENA_SIZE 128
|
||||
#define ARENA_FILE "arena_test.bin"
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ main(int argc, const char *argv[])
|
|||
|
||||
if (-1 == CreateArena(arenaFile, ARENA_FILE, ARENA_SIZE, 0644)) {
|
||||
abort();
|
||||
} else if (!run_suite(arenaFile, "arenaFile")) {
|
||||
} else if (!runSuite(arenaFile, "arenaFile")) {
|
||||
abort();
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue