diff --git a/Makefile b/Makefile index 1cadff1..e9568c2 100644 --- a/Makefile +++ b/Makefile @@ -3,12 +3,15 @@ MonetDB_LIB = MonetDB_INC = Threading = CXXFLAGS = --std=c++1z -OPTFLAGS = -O3 +OPTFLAGS = -O3 -fno-semantic-interposition LINKFLAGS = -flto -SHAREDFLAGS = -shared -fPIC -LIBTOOL = $(shell $(CXX) --version | grep -q 'clang' && echo "libtool -static -o"|| echo "ar rcs") -USELIB_FLAG = $(shell $(CXX) --version | grep -q 'clang' && echo "-Wl,-force_load"|| echo "-Wl,--whole-archive") +SHAREDFLAGS = -shared +FPIC = -fPIC +COMPILER = $(shell $(CXX) --version | grep -q 'clang' && echo "clang"|| echo "gcc") +LIBTOOL = +USELIB_FLAG = -Wl,--whole-archive,libaquery.a -Wl,-no-whole-archive LIBAQ_SRC = server/server.cpp server/monetdb_conn.cpp server/io.cpp + ifeq ($(PCH), 1) PCHFLAGS = -include server/pch.hpp else @@ -20,14 +23,20 @@ ifeq ($(OS),Windows_NT) OS_SUPPORT += server/winhelper.cpp MonetDB_LIB += msc-plugin/monetdbe.dll MonetDB_INC += -Imonetdb/msvc + LIBTOOL = gcc-ar rcs else UNAME_S = $(shell uname -s) UNAME_M = $(shell uname -m) NULL_DEVICE = /dev/null MonetDB_LIB = + LIBTOOL = ar rcs ifeq ($(UNAME_S),Darwin) + USELIB_FLAG = -Wl,-force_load MonetDB_LIB += -L$(shell brew --prefix monetdb)/lib MonetDB_INC += -I$(shell brew --prefix monetdb)/include/monetdb + ifeq ($(COMPILER), clang) + LIBTOOL = libtool -static -o + endif ifneq ($(UNAME_M),arm64) OPTFLAGS += -march=native endif @@ -43,6 +52,8 @@ ifeq ($(THREADING),1) Threading += -DTHREADING endif +SHAREDFLAGS += $(FPIC) + info: $(info $(OS_SUPPORT)) $(info $(OS)) @@ -52,9 +63,9 @@ info: $(info $(MonetDB_INC)) $(info $(CXX)) pch: - $(CXX) -x c++-header server/pch.hpp $(MonetDB_INC) $(OPTFLAGS) $(CXXFLAGS) $(Threading) + $(CXX) -x c++-header server/pch.hpp $(FPIC) $(MonetDB_INC) $(OPTFLAGS) $(CXXFLAGS) $(Threading) libaquery.a: - $(CXX) -c $(PCHFLAGS) $(LIBAQ_SRC) $(MonetDB_INC) $(MonetDB_LIB) $(OS_SUPPORT) $(Threading) $(OPTFLAGS) $(LINKFLAGS) $(CXXFLAGS) &&\ + $(CXX) -c $(FPIC) $(PCHFLAGS) $(LIBAQ_SRC) $(MonetDB_INC) $(MonetDB_LIB) $(OS_SUPPORT) $(Threading) $(OPTFLAGS) $(LINKFLAGS) $(CXXFLAGS) &&\ $(LIBTOOL) libaquery.a *.o &&\ ranlib libaquery.a @@ -77,6 +88,6 @@ docker: docker build -t aquery . clean: - rm *.shm *.o dll.so server.so server.bin -rf 2> $(NULL_DEVICE) || true + rm *.shm *.o dll.so server.so server.bin libaquery.a .cached -rf 2> $(NULL_DEVICE) || true diff --git a/prompt.py b/prompt.py index 71d9201..522b2d8 100644 --- a/prompt.py +++ b/prompt.py @@ -320,7 +320,7 @@ def save(q:str, cxt: xengine.Context): savefile('udf', 'udf', '.hpp') savefile('sql', 'sql') -def prompt(running = lambda:True, next = input, state = None): +def prompt(running = lambda:True, next = lambda:input('> '), state = None): if state is None: state = init_prompt() q = '' @@ -333,7 +333,6 @@ def prompt(running = lambda:True, next = input, state = None): state.init() while state.get_ready(): time.sleep(.00001) - print("> ", end="") og_q : str = next() q = og_q.lower().strip() if q == 'exec': # generate build and run (AQuery Engine) diff --git a/sdk/aquery.h b/sdk/aquery.h index e5da083..46bc91a 100644 --- a/sdk/aquery.h +++ b/sdk/aquery.h @@ -71,7 +71,8 @@ typedef void (*deallocator_t) (void*); extern void* Aalloc(unsigned long long sz); extern void Afree(void * mem); extern void register_memory(void* ptr, deallocator_t deallocator); -extern void init_session(Context* cxt); + +__AQEXPORT__(void) init_session(Context* cxt); #define __AQ_NO_SESSION__ __AQEXPORT__(void) init_session(Context*) {} #endif \ No newline at end of file diff --git a/sdk/sdk:Makefile b/sdk/sdk:Makefile new file mode 100644 index 0000000..668d667 --- /dev/null +++ b/sdk/sdk:Makefile @@ -0,0 +1,4 @@ +example: + g++-9 -shared -fPIC example.cpp aquery_mem.cpp -fno-semantic-interposition -Ofast -march=native -flto --std=c++1z -o ../test.so + +all: example diff --git a/server/io.cpp b/server/io.cpp index c4b7c69..ac6842e 100644 --- a/server/io.cpp +++ b/server/io.cpp @@ -51,8 +51,6 @@ namespace types { using namespace chrono; string date_t::toString() const { uint32_t curr_v = val; - tm; - time_t; return string() + string("/") + string() + string("/") + string(); } string time_t::toString() const { @@ -71,7 +69,7 @@ string base62uuid(int l = 8) { static mt19937_64 engine(chrono::system_clock::now().time_since_epoch().count()); static uniform_int_distribution u(0x10000, 0xfffff); uint64_t uuid = (u(engine) << 32ull) + (chrono::system_clock::now().time_since_epoch().count() & 0xffffffff); - printf("%p\n", uuid); + printf("%llu\n", uuid); string ret; while (uuid && l-- >= 0) { ret = string("") + base62alp[uuid % 62] + ret; diff --git a/server/pch.hpp b/server/pch.hpp index c285204..993ce3a 100644 --- a/server/pch.hpp +++ b/server/pch.hpp @@ -1,4 +1,5 @@ -#pragma once +#ifndef __AQ_PCH_H__ +#define __AQ_PCH_H__ #include "libaquery.h" #include "aggregations.h" @@ -15,3 +16,5 @@ #include #include #endif + +#endif diff --git a/server/server.cpp b/server/server.cpp index 87b0f87..e77b45b 100644 --- a/server/server.cpp +++ b/server/server.cpp @@ -227,12 +227,25 @@ int dll_main(int argc, char** argv, Context* cxt){ } int launcher(int argc, char** argv){ +#ifdef _WIN32 + constexpr char sep = '\\'; +#else + constexpr char sep = '/'; +#endif std::string str = " "; + std::string pwd = ""; + if (argc > 0) + pwd = argv[0]; + + auto pos = pwd.find_last_of(sep); + if (pos == std::string::npos) + pos = 0; + pwd = pwd.substr(0, pos); for (int i = 1; i < argc; i++){ str += argv[i]; str += " "; } - str = std::string("python3 prompt.py ") + str; + str = std::string("cd ") + pwd + std::string("&& python3 ./prompt.py ") + str; return system(str.c_str()); } diff --git a/server/threading.cpp b/server/threading.cpp index eb2784e..3f641fc 100644 --- a/server/threading.cpp +++ b/server/threading.cpp @@ -105,7 +105,7 @@ ThreadPool::ThreadPool(uint32_t n_threads) current_payload = new payload_t[n_threads]; for (uint32_t i = 0; i < n_threads; ++i){ - atomic_init(tf + i, 0b10); + atomic_init(tf + i, static_cast(0b10)); th[i] = thread(&ThreadPool::daemon_proc, this, i); }