diff options
author | Jan Vorlicek <janvorli@microsoft.com> | 2016-03-23 18:01:31 +0100 |
---|---|---|
committer | Jan Vorlicek <janvorli@microsoft.com> | 2016-04-06 12:40:53 +0200 |
commit | a9abb7b987b648cac9ab3d16ddd6ecc4e960177a (patch) | |
tree | 344aa81c630023d2c04ef227f9a473043a39ff10 /src/coreclr | |
parent | 930a13c8afc2e4709d7c243be44340e4b61bfdfc (diff) | |
download | coreclr-a9abb7b987b648cac9ab3d16ddd6ecc4e960177a.tar.gz coreclr-a9abb7b987b648cac9ab3d16ddd6ecc4e960177a.tar.bz2 coreclr-a9abb7b987b648cac9ab3d16ddd6ecc4e960177a.zip |
Add header file for the hosting API
Add the header file and also modify coreruncommon.cpp to use it.
Diffstat (limited to 'src/coreclr')
-rw-r--r-- | src/coreclr/CMakeLists.txt | 5 | ||||
-rw-r--r-- | src/coreclr/hosts/CMakeLists.txt | 14 | ||||
-rw-r--r-- | src/coreclr/hosts/inc/coreclrhost.h | 50 | ||||
-rw-r--r-- | src/coreclr/hosts/unixcoreruncommon/coreruncommon.cpp | 31 |
4 files changed, 69 insertions, 31 deletions
diff --git a/src/coreclr/CMakeLists.txt b/src/coreclr/CMakeLists.txt index e40df6cab1..c1bed7b2bb 100644 --- a/src/coreclr/CMakeLists.txt +++ b/src/coreclr/CMakeLists.txt @@ -1,5 +1,6 @@ # Add the Merge flag here is needed. Not needed for RyuJIT if building as a DLL. add_definitions(-DFEATURE_MERGE_JIT_AND_ENGINE) - -add_subdirectory(hosts) +if(WIN32) + add_subdirectory(hosts) +endif(WIN32) diff --git a/src/coreclr/hosts/CMakeLists.txt b/src/coreclr/hosts/CMakeLists.txt index cc990add10..bb425b908a 100644 --- a/src/coreclr/hosts/CMakeLists.txt +++ b/src/coreclr/hosts/CMakeLists.txt @@ -1,3 +1,13 @@ -add_subdirectory(corerun) -add_subdirectory(coreconsole) +include_directories(inc) +if(WIN32) + add_subdirectory(corerun) + add_subdirectory(coreconsole) +else(WIN32) + add_subdirectory(unixcoreruncommon) + add_subdirectory(unixcorerun) + add_subdirectory(unixcoreconsole) + if(CLR_CMAKE_PLATFORM_DARWIN) + add_subdirectory(osxbundlerun) + endif(CLR_CMAKE_PLATFORM_DARWIN) +endif(WIN32) diff --git a/src/coreclr/hosts/inc/coreclrhost.h b/src/coreclr/hosts/inc/coreclrhost.h new file mode 100644 index 0000000000..f0d7952aa6 --- /dev/null +++ b/src/coreclr/hosts/inc/coreclrhost.h @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +// +// APIs for hosting CoreCLR +// + +#ifndef __CORECLR_HOST_H__ +#define __CORECLR_HOST_H__ + +// For each hosting API, we define a function prototype and a function pointer +// The prototype is useful for implicit linking against the dynamic coreclr +// library and the pointer for explicit dynamic loading (dlopen, LoadLibrary) +#define CORECLR_HOSTING_API(function, ...) \ + extern "C" int function(__VA_ARGS__); \ + typedef int (*function##_ptr)(__VA_ARGS__) + +CORECLR_HOSTING_API(coreclr_initialize, + const char* exePath, + const char* appDomainFriendlyName, + int propertyCount, + const char** propertyKeys, + const char** propertyValues, + void** hostHandle, + unsigned int* domainId); + +CORECLR_HOSTING_API(coreclr_shutdown, + void* hostHandle, + unsigned int domainId); + +CORECLR_HOSTING_API(coreclr_create_delegate, + void* hostHandle, + unsigned int domainId, + const char* entryPointAssemblyName, + const char* entryPointTypeName, + const char* entryPointMethodName, + void** delegate); + +CORECLR_HOSTING_API(coreclr_execute_assembly, + void* hostHandle, + unsigned int domainId, + int argc, + const char** argv, + const char* managedAssemblyPath, + unsigned int* exitCode); + +#undef CORECLR_HOSTING_API + +#endif // __CORECLR_HOST_H__ diff --git a/src/coreclr/hosts/unixcoreruncommon/coreruncommon.cpp b/src/coreclr/hosts/unixcoreruncommon/coreruncommon.cpp index bc795fd948..6a2ee48a75 100644 --- a/src/coreclr/hosts/unixcoreruncommon/coreruncommon.cpp +++ b/src/coreclr/hosts/unixcoreruncommon/coreruncommon.cpp @@ -16,6 +16,7 @@ #include <string.h> #include <sys/stat.h> #include "coreruncommon.h" +#include "coreclrhost.h" #include <unistd.h> #define SUCCEEDED(Status) ((Status) >= 0) @@ -29,30 +30,6 @@ static const char* serverGcVar = "CORECLR_SERVER_GC"; // used in the same way as serverGcVar. Concurrent GC is on by default. static const char* concurrentGcVar = "CORECLR_CONCURRENT_GC"; -// Prototype of the coreclr_initialize function from the libcoreclr.so -typedef int (*InitializeCoreCLRFunction)( - const char* exePath, - const char* appDomainFriendlyName, - int propertyCount, - const char** propertyKeys, - const char** propertyValues, - void** hostHandle, - unsigned int* domainId); - -// Prototype of the coreclr_shutdown function from the libcoreclr.so -typedef int (*ShutdownCoreCLRFunction)( - void* hostHandle, - unsigned int domainId); - -// Prototype of the coreclr_execute_assembly function from the libcoreclr.so -typedef int (*ExecuteAssemblyFunction)( - void* hostHandle, - unsigned int domainId, - int argc, - const char** argv, - const char* managedAssemblyPath, - unsigned int* exitCode); - #if defined(__linux__) #define symlinkEntrypointExecutable "/proc/self/exe" #elif !defined(__APPLE__) @@ -306,9 +283,9 @@ int ExecuteManagedAssembly( void* coreclrLib = dlopen(coreClrDllPath.c_str(), RTLD_NOW | RTLD_LOCAL); if (coreclrLib != nullptr) { - InitializeCoreCLRFunction initializeCoreCLR = (InitializeCoreCLRFunction)dlsym(coreclrLib, "coreclr_initialize"); - ExecuteAssemblyFunction executeAssembly = (ExecuteAssemblyFunction)dlsym(coreclrLib, "coreclr_execute_assembly"); - ShutdownCoreCLRFunction shutdownCoreCLR = (ShutdownCoreCLRFunction)dlsym(coreclrLib, "coreclr_shutdown"); + coreclr_initialize_ptr initializeCoreCLR = (coreclr_initialize_ptr)dlsym(coreclrLib, "coreclr_initialize"); + coreclr_execute_assembly_ptr executeAssembly = (coreclr_execute_assembly_ptr)dlsym(coreclrLib, "coreclr_execute_assembly"); + coreclr_shutdown_ptr shutdownCoreCLR = (coreclr_shutdown_ptr)dlsym(coreclrLib, "coreclr_shutdown"); if (initializeCoreCLR == nullptr) { |