Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
dd133c17
Commit
dd133c17
authored
9 years ago
by
Jan Tattermusch
Browse files
Options
Downloads
Patches
Plain Diff
Prevent the need to install libc6-dev on Linux
parent
0727180d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/csharp/Grpc.Core/Internal/PlatformApis.cs
+7
-0
7 additions, 0 deletions
src/csharp/Grpc.Core/Internal/PlatformApis.cs
src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs
+24
-0
24 additions, 0 deletions
src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs
with
31 additions
and
0 deletions
src/csharp/Grpc.Core/Internal/PlatformApis.cs
+
7
−
0
View file @
dd133c17
...
@@ -49,6 +49,7 @@ namespace Grpc.Core.Internal
...
@@ -49,6 +49,7 @@ namespace Grpc.Core.Internal
static
readonly
bool
isLinux
;
static
readonly
bool
isLinux
;
static
readonly
bool
isMacOSX
;
static
readonly
bool
isMacOSX
;
static
readonly
bool
isWindows
;
static
readonly
bool
isWindows
;
static
readonly
bool
isMono
;
static
PlatformApis
()
static
PlatformApis
()
{
{
...
@@ -58,6 +59,7 @@ namespace Grpc.Core.Internal
...
@@ -58,6 +59,7 @@ namespace Grpc.Core.Internal
isMacOSX
=
(
platform
==
PlatformID
.
Unix
&&
GetUname
()
==
"Darwin"
);
isMacOSX
=
(
platform
==
PlatformID
.
Unix
&&
GetUname
()
==
"Darwin"
);
isLinux
=
(
platform
==
PlatformID
.
Unix
&&
!
isMacOSX
);
isLinux
=
(
platform
==
PlatformID
.
Unix
&&
!
isMacOSX
);
isWindows
=
(
platform
==
PlatformID
.
Win32NT
||
platform
==
PlatformID
.
Win32S
||
platform
==
PlatformID
.
Win32Windows
);
isWindows
=
(
platform
==
PlatformID
.
Win32NT
||
platform
==
PlatformID
.
Win32S
||
platform
==
PlatformID
.
Win32Windows
);
isMono
=
Type
.
GetType
(
"Mono.Runtime"
)
!=
null
;
}
}
public
static
bool
IsLinux
public
static
bool
IsLinux
...
@@ -75,6 +77,11 @@ namespace Grpc.Core.Internal
...
@@ -75,6 +77,11 @@ namespace Grpc.Core.Internal
get
{
return
isWindows
;
}
get
{
return
isWindows
;
}
}
}
public
static
bool
IsMono
{
get
{
return
isMono
;
}
}
public
static
bool
Is64Bit
public
static
bool
Is64Bit
{
{
get
{
return
IntPtr
.
Size
==
8
;
}
get
{
return
IntPtr
.
Size
==
8
;
}
...
...
This diff is collapsed.
Click to expand it.
src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs
+
24
−
0
View file @
dd133c17
...
@@ -91,6 +91,10 @@ namespace Grpc.Core.Internal
...
@@ -91,6 +91,10 @@ namespace Grpc.Core.Internal
{
{
if
(
PlatformApis
.
IsLinux
)
if
(
PlatformApis
.
IsLinux
)
{
{
if
(
PlatformApis
.
IsMono
)
{
return
Mono
.
dlsym
(
this
.
handle
,
symbolName
);
}
return
Linux
.
dlsym
(
this
.
handle
,
symbolName
);
return
Linux
.
dlsym
(
this
.
handle
,
symbolName
);
}
}
if
(
PlatformApis
.
IsMacOSX
)
if
(
PlatformApis
.
IsMacOSX
)
...
@@ -122,6 +126,10 @@ namespace Grpc.Core.Internal
...
@@ -122,6 +126,10 @@ namespace Grpc.Core.Internal
}
}
if
(
PlatformApis
.
IsLinux
)
if
(
PlatformApis
.
IsLinux
)
{
{
if
(
PlatformApis
.
IsMono
)
{
return
Mono
.
dlopen
(
libraryPath
,
RTLD_GLOBAL
+
RTLD_LAZY
);
}
return
Linux
.
dlopen
(
libraryPath
,
RTLD_GLOBAL
+
RTLD_LAZY
);
return
Linux
.
dlopen
(
libraryPath
,
RTLD_GLOBAL
+
RTLD_LAZY
);
}
}
if
(
PlatformApis
.
IsMacOSX
)
if
(
PlatformApis
.
IsMacOSX
)
...
@@ -154,5 +162,21 @@ namespace Grpc.Core.Internal
...
@@ -154,5 +162,21 @@ namespace Grpc.Core.Internal
[
DllImport
(
"libSystem.dylib"
)]
[
DllImport
(
"libSystem.dylib"
)]
internal
static
extern
IntPtr
dlsym
(
IntPtr
handle
,
string
symbol
);
internal
static
extern
IntPtr
dlsym
(
IntPtr
handle
,
string
symbol
);
}
}
/// <summary>
/// On Linux systems, using using dlopen and dlsym results in
/// DllNotFoundException("libdl.so not found") if libc6-dev
/// is not installed. As a workaround, we load symbols for
/// dlopen and dlsym from the current process as on Linux
/// Mono sure is linked against these symbols.
/// </summary>
private
static
class
Mono
{
[
DllImport
(
"__Internal"
)]
internal
static
extern
IntPtr
dlopen
(
string
filename
,
int
flags
);
[
DllImport
(
"__Internal"
)]
internal
static
extern
IntPtr
dlsym
(
IntPtr
handle
,
string
symbol
);
}
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment