Fixed error in SDK and test

dev
Bill Sun 2 years ago
parent bc66663491
commit 8f3b648c53

3
.gitignore vendored

@ -1,3 +1,6 @@
test.lib
test.exp
*.pdb
libaquery.a libaquery.a
libaquery.lib libaquery.lib
server.lib server.lib

@ -3,7 +3,7 @@ MonetDB_LIB =
MonetDB_INC = MonetDB_INC =
Threading = Threading =
CXXFLAGS = --std=c++1z CXXFLAGS = --std=c++1z
OPTFLAGS = -O3 -fno-semantic-interposition OPTFLAGS = -g3 #-O3 -fno-semantic-interposition
LINKFLAGS = -flto LINKFLAGS = -flto
SHAREDFLAGS = -shared SHAREDFLAGS = -shared
FPIC = -fPIC FPIC = -fPIC

@ -89,7 +89,7 @@ class build_manager:
os.environ['CXX'] = mgr.cxx if mgr.cxx else 'c++' os.environ['CXX'] = mgr.cxx if mgr.cxx else 'c++'
def libaquery_a(self): def libaquery_a(self):
self.build_cmd = [['rm', 'libaquery.lib'],['make', 'libaquery.a']] self.build_cmd = [['rm', 'libaquery.a'],['make', 'libaquery.a']]
return self.build() return self.build()
def pch(self): def pch(self):
self.build_cmd = [['rm', 'server/pch.hpp.gch'], ['make', 'pch']] self.build_cmd = [['rm', 'server/pch.hpp.gch'], ['make', 'pch']]

@ -0,0 +1,167 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{f954797b-c148-4cbf-9fb4-a9a450efec38}</ProjectGuid>
<RootNamespace>Project1</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(SolutionDir)..\</OutDir>
<TargetName>test</TargetName>
<TargetExt>.so</TargetExt>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir)..\</OutDir>
<TargetName>test</TargetName>
<TargetExt>.so</TargetExt>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutDir>$(SolutionDir)..\</OutDir>
<TargetName>test</TargetName>
<TargetExt>.so</TargetExt>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>$(SolutionDir)..\</OutDir>
<TargetName>test</TargetName>
<TargetExt>.so</TargetExt>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpplatest</LanguageStandard>
<LanguageStandard_C>stdc17</LanguageStandard_C>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpplatest</LanguageStandard>
<LanguageStandard_C>stdc17</LanguageStandard_C>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpplatest</LanguageStandard>
<LanguageStandard_C>stdc17</LanguageStandard_C>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpplatest</LanguageStandard>
<LanguageStandard_C>stdc17</LanguageStandard_C>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\sdk\aquery.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\sdk\aquery_mem.cpp" />
<ClCompile Include="..\sdk\example.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

@ -16,6 +16,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libaquery", "libaquery.vcxp
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "launcher", "launcher.vcxproj", "{C8E25628-0B46-4CBE-90DF-5228F79A5A64}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "launcher", "launcher.vcxproj", "{C8E25628-0B46-4CBE-90DF-5228F79A5A64}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sdk_example", "sdk_example.vcxproj", "{F954797B-C148-4CBF-9FB4-A9A450EFEC38}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64 Debug|x64 = Debug|x64
@ -98,6 +100,22 @@ Global
{C8E25628-0B46-4CBE-90DF-5228F79A5A64}.sharedlib|x64.Build.0 = sharedlib|x64 {C8E25628-0B46-4CBE-90DF-5228F79A5A64}.sharedlib|x64.Build.0 = sharedlib|x64
{C8E25628-0B46-4CBE-90DF-5228F79A5A64}.sharedlib|x86.ActiveCfg = sharedlib|Win32 {C8E25628-0B46-4CBE-90DF-5228F79A5A64}.sharedlib|x86.ActiveCfg = sharedlib|Win32
{C8E25628-0B46-4CBE-90DF-5228F79A5A64}.sharedlib|x86.Build.0 = sharedlib|Win32 {C8E25628-0B46-4CBE-90DF-5228F79A5A64}.sharedlib|x86.Build.0 = sharedlib|Win32
{F954797B-C148-4CBF-9FB4-A9A450EFEC38}.Debug|x64.ActiveCfg = Debug|x64
{F954797B-C148-4CBF-9FB4-A9A450EFEC38}.Debug|x64.Build.0 = Debug|x64
{F954797B-C148-4CBF-9FB4-A9A450EFEC38}.Debug|x86.ActiveCfg = Debug|Win32
{F954797B-C148-4CBF-9FB4-A9A450EFEC38}.Debug|x86.Build.0 = Debug|Win32
{F954797B-C148-4CBF-9FB4-A9A450EFEC38}.Release|x64.ActiveCfg = Release|x64
{F954797B-C148-4CBF-9FB4-A9A450EFEC38}.Release|x64.Build.0 = Release|x64
{F954797B-C148-4CBF-9FB4-A9A450EFEC38}.Release|x86.ActiveCfg = Release|Win32
{F954797B-C148-4CBF-9FB4-A9A450EFEC38}.Release|x86.Build.0 = Release|Win32
{F954797B-C148-4CBF-9FB4-A9A450EFEC38}.shared|x64.ActiveCfg = Debug|x64
{F954797B-C148-4CBF-9FB4-A9A450EFEC38}.shared|x64.Build.0 = Debug|x64
{F954797B-C148-4CBF-9FB4-A9A450EFEC38}.shared|x86.ActiveCfg = Debug|Win32
{F954797B-C148-4CBF-9FB4-A9A450EFEC38}.shared|x86.Build.0 = Debug|Win32
{F954797B-C148-4CBF-9FB4-A9A450EFEC38}.sharedlib|x64.ActiveCfg = Debug|x64
{F954797B-C148-4CBF-9FB4-A9A450EFEC38}.sharedlib|x64.Build.0 = Debug|x64
{F954797B-C148-4CBF-9FB4-A9A450EFEC38}.sharedlib|x86.ActiveCfg = Debug|Win32
{F954797B-C148-4CBF-9FB4-A9A450EFEC38}.sharedlib|x86.Build.0 = Debug|Win32
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

@ -357,7 +357,7 @@ def prompt(running = lambda:True, next = lambda:input('> '), state = None):
cxt = xengine.exec(state.stmts, cxt, keep) cxt = xengine.exec(state.stmts, cxt, keep)
this_udf = cxt.finalize_udf() this_udf = cxt.finalize_udf()
if this_udf: if False and this_udf:
with open('udf.hpp', 'wb') as outfile: with open('udf.hpp', 'wb') as outfile:
outfile.write(this_udf.encode('utf-8')) outfile.write(this_udf.encode('utf-8'))

@ -75,4 +75,15 @@ extern void register_memory(void* ptr, deallocator_t deallocator);
__AQEXPORT__(void) init_session(Context* cxt); __AQEXPORT__(void) init_session(Context* cxt);
#define __AQ_NO_SESSION__ __AQEXPORT__(void) init_session(Context*) {} #define __AQ_NO_SESSION__ __AQEXPORT__(void) init_session(Context*) {}
void* memcpy(void*, void*, unsigned long long);
struct ColRef_storage {
void* container;
unsigned int capacity, size;
const char* name;
int ty; // what if enum is not int?
template <class Ty, template <typename> class VT>
ColRef_storage(const VT<Ty>& vt) {
memcpy(this, &vt, sizeof(ColRef_storage));
}
};
#endif #endif

@ -2,6 +2,7 @@
#include <memory> #include <memory>
#include <cstdlib> #include <cstdlib>
#include <cstring>
#include <unordered_map> #include <unordered_map>
Session* session; Session* session;

@ -2,10 +2,13 @@
// __AQ_NO_SESSION__ // __AQ_NO_SESSION__
#include "../server/table.h" #include "../server/table.h"
__AQEXPORT__(ColRef<float>) mulvec(int a, ColRef<float> b){ __AQEXPORT__(ColRef_storage) mulvec(int a, ColRef<float> b){
return a * b; return a * b;
} }
__AQEXPORT__(double) mydiv(int a, int b){ __AQEXPORT__(double) mydiv(int a, int b){
return a / (double)b; printf("%d, %d\n", a, b);
double d = a/(double)b;
printf("%lf", d);
return d;
} }

@ -100,10 +100,10 @@ void Context::end_session(){
void* Context::get_module_function(const char* fname){ void* Context::get_module_function(const char* fname){
auto fmap = static_cast<std::unordered_map<std::string, void*>*> auto fmap = static_cast<std::unordered_map<std::string, void*>*>
(this->module_function_maps); (this->module_function_maps);
//printf("%p\n", fmap->find("mydiv")->second); printf("%p\n", fmap->find("mydiv")->second);
// for (const auto& [key, value] : *fmap){ for (const auto& [key, value] : *fmap){
// printf("%s %p\n", key.c_str(), value); printf("%s %p\n", key.c_str(), value);
// } }
auto ret = fmap->find(fname); auto ret = fmap->find(fname);
return ret == fmap->end() ? nullptr : ret->second; return ret == fmap->end() ? nullptr : ret->second;
} }
@ -173,6 +173,12 @@ int dll_main(int argc, char** argv, Context* cxt){
{ {
auto mname = n_recvd[i] + 1; auto mname = n_recvd[i] + 1;
user_module_handle = dlopen(mname, RTLD_LAZY); user_module_handle = dlopen(mname, RTLD_LAZY);
//getlasterror
#ifndef _MSC_VER
if (!user_module_handle)
puts(dlerror());
#endif
user_module_map[mname] = user_module_handle; user_module_map[mname] = user_module_handle;
initialize_module(mname, user_module_handle, cxt); initialize_module(mname, user_module_handle, cxt);
} }
@ -180,9 +186,9 @@ int dll_main(int argc, char** argv, Context* cxt){
case 'F': // Register Function in Module case 'F': // Register Function in Module
{ {
auto fname = n_recvd[i] + 1; auto fname = n_recvd[i] + 1;
//printf("%s: %p, %p\n", fname, user_module_handle, dlsym(user_module_handle, fname)); printf("F:: %s: %p, %p\n", fname, user_module_handle, dlsym(user_module_handle, fname));
module_fn_map->insert_or_assign(fname, dlsym(user_module_handle, fname)); module_fn_map->insert_or_assign(fname, dlsym(user_module_handle, fname));
//printf("%p\n", module_fn_map->find("mydiv") != module_fn_map->end() ? module_fn_map->find("mydiv")->second : nullptr); printf("F::: %p\n", module_fn_map->find("mydiv") != module_fn_map->end() ? module_fn_map->find("mydiv")->second : nullptr);
} }
break; break;
case 'U': // Unload Module case 'U': // Unload Module

@ -1,4 +1,4 @@
LOAD MODULE FROM "test.so" LOAD MODULE FROM "./test.so"
FUNCTIONS ( FUNCTIONS (
mydiv(a:int, b:int) -> double, mydiv(a:int, b:int) -> double,
mulvec(a:int, b:vecfloat) -> vecfloat mulvec(a:int, b:vecfloat) -> vecfloat

Loading…
Cancel
Save