-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Static linking of native libs #44505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
1c0b32b
4adfaa6
0facc65
a2ab07c
2b2f800
8c4e514
6e584b4
ba71464
4563d69
51281d6
25369f4
e6fca93
c11612f
d3f4abe
79453c7
becda0e
932b5fe
3f5cea9
8d2b6b9
9b7476f
8a02254
f22e9fd
e539a1a
06dad00
ac026ba
eb62c4a
2f45a47
7b2bdef
7ab3211
7bf0a63
d3a15fa
6c55b68
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| /***************************************************************************** | ||
| ** ** | ||
| ** pinvokeoverride.h - PInvoke binding override ** | ||
| ** ** | ||
| *****************************************************************************/ | ||
|
|
||
| #ifndef _PINVOKEOVERRIDE_H_ | ||
| #define _PINVOKEOVERRIDE_H_ | ||
|
|
||
| typedef const void* (__stdcall PInvokeOverrideFn)(const char* libraryName, const char* entrypointName); | ||
VSadov marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| class PInvokeOverride | ||
| { | ||
| private: | ||
| static PInvokeOverrideFn* s_overrideImpl; | ||
VSadov marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| public: | ||
| static void SetPInvokeOverride(PInvokeOverrideFn* overrideImpl); | ||
| static const void* TryGetMethodImpl(const char* libraryName, const char* entrypointName); | ||
| }; | ||
|
|
||
| #endif // _PINVOKEOVERRIDE_H_ | ||
| // EOF ======================================================================= | ||
VSadov marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // | ||
|
|
||
| // | ||
| // REVIEW: THE IMPLEMENTATION FOR THE OVERRIDER WILL BE MOVED TO HOST | ||
| // | ||
|
|
||
| namespace SuperHost | ||
| { | ||
| const void* ResolveDllImport(const char* libraryName, const char* entrypointName); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| //***************************************************************************** | ||
| // pinvokeoverride.cpp | ||
| // | ||
| // Helpers to implement PInvoke overriding | ||
| // | ||
| //***************************************************************************** | ||
|
|
||
| #include "pinvokeoverride.h" | ||
|
|
||
| PInvokeOverrideFn* PInvokeOverride::s_overrideImpl = nullptr; | ||
|
|
||
| void PInvokeOverride::SetPInvokeOverride(PInvokeOverrideFn* overrideImpl) | ||
| { | ||
| s_overrideImpl = overrideImpl; | ||
| } | ||
|
|
||
| const void* PInvokeOverride::TryGetMethodImpl(const char* libraryName, const char* entrypointName) | ||
| { | ||
| return s_overrideImpl ? | ||
| s_overrideImpl(libraryName, entrypointName) : | ||
| nullptr; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // | ||
|
|
||
| // | ||
| // REVIEW: THE IMPLEMENTATION FOR THE OVERRIDER WILL BE MOVED TO HOST | ||
| // | ||
|
|
||
| #include "common.h" | ||
| #include "pinvokeoverrideimpl.h" | ||
|
|
||
| extern "C" const void* GlobalizationResolveDllImport(const char* name); | ||
| extern "C" const void* CompressionResolveDllImport(const char* name); | ||
|
|
||
| const void* SuperHost::ResolveDllImport(const char* libraryName, const char* entrypointName) | ||
| { | ||
| if (strcmp(libraryName, "libSystem.Globalization.Native") == 0) | ||
| { | ||
| return GlobalizationResolveDllImport(entrypointName); | ||
| } | ||
|
|
||
| #if defined(_WIN32) | ||
| if (strcmp(libraryName, "clrcompression") == 0) | ||
| #else | ||
| if (strcmp(libraryName, "libSystem.IO.Compression.Native") == 0) | ||
| #endif | ||
| { | ||
| return CompressionResolveDllImport(entrypointName); | ||
| } | ||
|
|
||
| return nullptr; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| #include <stdint.h> | ||
| #include <string.h> | ||
|
|
||
| typedef uint16_t UChar; | ||
|
|
||
|
|
@@ -60,3 +61,64 @@ FCFuncStart(gPalGlobalizationNative) | |
| QCFuncElement("ToAscii", GlobalizationNative_ToAscii) | ||
| QCFuncElement("ToUnicode", GlobalizationNative_ToUnicode) | ||
| FCFuncEnd() | ||
|
|
||
| #ifndef lengthof | ||
|
||
| #define lengthof(rg) (sizeof(rg)/sizeof(rg[0])) | ||
| #endif | ||
|
|
||
| typedef struct | ||
| { | ||
| const char* name; | ||
| const void* method; | ||
| } Entry; | ||
|
|
||
| static Entry s_globalizationNative[] = | ||
|
||
| { | ||
| {"GlobalizationNative_ChangeCase", GlobalizationNative_ChangeCase}, | ||
| {"GlobalizationNative_ChangeCaseInvariant", GlobalizationNative_ChangeCaseInvariant}, | ||
| {"GlobalizationNative_ChangeCaseTurkish", GlobalizationNative_ChangeCaseTurkish}, | ||
| {"GlobalizationNative_CloseSortHandle", GlobalizationNative_CloseSortHandle}, | ||
| {"GlobalizationNative_CompareString", GlobalizationNative_CompareString}, | ||
| {"GlobalizationNative_EndsWith", GlobalizationNative_EndsWith}, | ||
| {"GlobalizationNative_EnumCalendarInfo", GlobalizationNative_EnumCalendarInfo}, | ||
| {"GlobalizationNative_GetCalendarInfo", GlobalizationNative_GetCalendarInfo}, | ||
| {"GlobalizationNative_GetCalendars", GlobalizationNative_GetCalendars}, | ||
| {"GlobalizationNative_GetDefaultLocaleName", GlobalizationNative_GetDefaultLocaleName}, | ||
| {"GlobalizationNative_GetICUVersion", GlobalizationNative_GetICUVersion}, | ||
| {"GlobalizationNative_GetJapaneseEraStartDate", GlobalizationNative_GetJapaneseEraStartDate}, | ||
| {"GlobalizationNative_GetLatestJapaneseEra", GlobalizationNative_GetLatestJapaneseEra}, | ||
| {"GlobalizationNative_GetLocaleInfoGroupingSizes", GlobalizationNative_GetLocaleInfoGroupingSizes}, | ||
| {"GlobalizationNative_GetLocaleInfoInt", GlobalizationNative_GetLocaleInfoInt}, | ||
| {"GlobalizationNative_GetLocaleInfoString", GlobalizationNative_GetLocaleInfoString}, | ||
| {"GlobalizationNative_GetLocaleName", GlobalizationNative_GetLocaleName}, | ||
| {"GlobalizationNative_GetLocales", GlobalizationNative_GetLocales}, | ||
| {"GlobalizationNative_GetLocaleTimeFormat", GlobalizationNative_GetLocaleTimeFormat}, | ||
| {"GlobalizationNative_GetSortHandle", GlobalizationNative_GetSortHandle}, | ||
| {"GlobalizationNative_GetSortKey", GlobalizationNative_GetSortKey}, | ||
| {"GlobalizationNative_GetSortVersion", GlobalizationNative_GetSortVersion}, | ||
| {"GlobalizationNative_GetTimeZoneDisplayName", GlobalizationNative_GetTimeZoneDisplayName}, | ||
| {"GlobalizationNative_IndexOf", GlobalizationNative_IndexOf}, | ||
| {"GlobalizationNative_InitICUFunctions", GlobalizationNative_InitICUFunctions}, | ||
| {"GlobalizationNative_InitOrdinalCasingPage", GlobalizationNative_InitOrdinalCasingPage}, | ||
| {"GlobalizationNative_IsNormalized", GlobalizationNative_IsNormalized}, | ||
| {"GlobalizationNative_IsPredefinedLocale", GlobalizationNative_IsPredefinedLocale}, | ||
| {"GlobalizationNative_LastIndexOf", GlobalizationNative_LastIndexOf}, | ||
| {"GlobalizationNative_LoadICU", GlobalizationNative_LoadICU}, | ||
| {"GlobalizationNative_NormalizeString", GlobalizationNative_NormalizeString}, | ||
| {"GlobalizationNative_StartsWith", GlobalizationNative_StartsWith}, | ||
| {"GlobalizationNative_ToAscii", GlobalizationNative_ToAscii}, | ||
| {"GlobalizationNative_ToUnicode", GlobalizationNative_ToUnicode}, | ||
| }; | ||
|
|
||
| extern "C" const void* GlobalizationResolveDllImport(const char* name) | ||
| { | ||
| for (int i = 0; i < lengthof(s_globalizationNative); i++) | ||
| { | ||
| if (strcmp(name, s_globalizationNative[i].name) == 0) | ||
| { | ||
| return s_globalizationNative[i].method; | ||
| } | ||
| } | ||
|
|
||
| return NULL; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.