Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
QueryR
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
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
Julien Lopez
QueryR
Commits
65d50ff9
Commit
65d50ff9
authored
8 years ago
by
Mick Jordan
Browse files
Options
Downloads
Patches
Plain Diff
jniboot: capture dlerror as a jstring immediately
parent
1ab953d1
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
com.oracle.truffle.r.native/fficall/src/jniboot/jniboot.c
+20
-9
20 additions, 9 deletions
com.oracle.truffle.r.native/fficall/src/jniboot/jniboot.c
with
20 additions
and
9 deletions
com.oracle.truffle.r.native/fficall/src/jniboot/jniboot.c
+
20
−
9
View file @
65d50ff9
...
...
@@ -31,14 +31,30 @@
// (probably resolving the JNI dlerror symbol, so we capture it here (N.B. depends on single
// threaded limitation).
static
char
*
last_dlerror
;
static
jobject
last_dlerror
=
NULL
;
static
void
create_dlerror_string
(
JNIEnv
*
env
)
{
if
(
last_dlerror
!=
NULL
)
{
(
*
env
)
->
DeleteGlobalRef
(
env
,
last_dlerror
);
last_dlerror
=
NULL
;
}
char
*
err
=
dlerror
();
if
(
err
==
NULL
)
{
last_dlerror
=
NULL
;
}
else
{
// printf("dlerror: %s\n", err);
last_dlerror
=
(
*
env
)
->
NewGlobalRef
(
env
,
(
*
env
)
->
NewStringUTF
(
env
,
err
));
}
}
JNIEXPORT
jlong
JNICALL
Java_com_oracle_truffle_r_runtime_ffi_jni_JNI_1Base_native_1dlopen
(
JNIEnv
*
env
,
jclass
c
,
jstring
jpath
,
jboolean
local
,
jboolean
now
)
{
const
char
*
path
=
(
*
env
)
->
GetStringUTFChars
(
env
,
jpath
,
NULL
);
int
flags
=
(
local
?
RTLD_LOCAL
:
RTLD_GLOBAL
)
|
(
now
?
RTLD_NOW
:
RTLD_LAZY
);
void
*
handle
=
dlopen
(
path
,
flags
);
last_dlerror
=
dlerror
();
if
(
handle
==
NULL
)
{
create_dlerror_string
(
env
);
}
(
*
env
)
->
ReleaseStringUTFChars
(
env
,
jpath
,
path
);
return
(
jlong
)
handle
;
}
...
...
@@ -47,7 +63,7 @@ JNIEXPORT jlong JNICALL
Java_com_oracle_truffle_r_runtime_ffi_jni_JNI_1Base_native_1dlsym
(
JNIEnv
*
env
,
jclass
c
,
jlong
handle
,
jstring
jsymbol
)
{
const
char
*
symbol
=
(
*
env
)
->
GetStringUTFChars
(
env
,
jsymbol
,
NULL
);
void
*
address
=
dlsym
((
void
*
)
handle
,
symbol
);
last_dlerror
=
dlerror
(
);
create_dlerror_string
(
env
);
(
*
env
)
->
ReleaseStringUTFChars
(
env
,
jsymbol
,
symbol
);
return
(
jlong
)
address
;
}
...
...
@@ -60,11 +76,6 @@ Java_com_oracle_truffle_r_runtime_ffi_jni_JNI_1Base_native_1dlclose(JNIEnv *env,
JNIEXPORT
jobject
JNICALL
Java_com_oracle_truffle_r_runtime_ffi_jni_JNI_1Base_native_1dlerror
(
JNIEnv
*
env
,
jclass
c
)
{
char
*
err
=
last_dlerror
;
if
(
err
==
NULL
)
{
return
NULL
;
}
else
{
return
(
*
env
)
->
NewStringUTF
(
env
,
err
);
}
return
last_dlerror
;
}
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