Skip to content

Commit a869fe5

Browse files
committed
[GR-47778] Truffle attach rewritten to C 11.
PullRequest: graal/15180
2 parents 231d362 + 2e404e8 commit a869fe5

File tree

2 files changed

+16
-28
lines changed

2 files changed

+16
-28
lines changed

truffle/mx.truffle/suite.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,18 +1118,18 @@
11181118
"os_arch" : {
11191119
"windows" : {
11201120
"<others>" : {
1121-
"cflags" : ["--std=c++11"]
1121+
"cflags" : []
11221122
}
11231123
},
11241124
"linux" : {
11251125
"<others>" : {
1126-
"cflags" : ["--std=c++11", "-g", "-Wall", "-Werror", "-D_GNU_SOURCE"],
1126+
"cflags" : ["-g", "-Wall", "-Werror", "-D_GNU_SOURCE"],
11271127
"ldlibs" : ["-ldl"],
11281128
},
11291129
},
11301130
"<others>" : {
11311131
"<others>" : {
1132-
"cflags" : ["--std=c++11", "-g", "-Wall", "-Werror"],
1132+
"cflags" : ["-g", "-Wall", "-Werror"],
11331133
"ldlibs" : ["-ldl"],
11341134
},
11351135
},

truffle/src/com.oracle.truffle.runtime.attach/src/truffle_attach.cc renamed to truffle/src/com.oracle.truffle.runtime.attach/src/truffle_attach.c

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,36 +23,24 @@
2323
* questions.
2424
*/
2525

26-
#include<jni.h>
26+
#include <jni.h>
2727

28-
#define EXCEPTION_CHECK_VOID(env) if (env->ExceptionCheck()) { \
29-
return; \
30-
}
28+
#define EXCEPTION_CHECK_VOID(env) \
29+
if ((*env)->ExceptionCheck(env)) { \
30+
return; \
31+
}
32+
33+
// Library entry points
3134

32-
static void addExports(JNIEnv* jniEnv, jobject m1, jobject pn, jobject m2) {
33-
jclass modulesClass = jniEnv->FindClass("jdk/internal/module/Modules");
35+
JNIEXPORT void JNICALL Java_com_oracle_truffle_runtime_ModulesSupport_addExports0(JNIEnv *jniEnv, jclass clz, jobject m1, jobject pn, jobject m2) {
36+
jclass modulesClass = (*jniEnv)->FindClass(jniEnv, "jdk/internal/module/Modules");
3437
EXCEPTION_CHECK_VOID(jniEnv)
35-
jmethodID addExports = jniEnv->GetStaticMethodID(modulesClass, "addExports", "(Ljava/lang/Module;Ljava/lang/String;Ljava/lang/Module;)V");
38+
jmethodID addExports =
39+
(*jniEnv)->GetStaticMethodID(jniEnv, modulesClass, "addExports", "(Ljava/lang/Module;Ljava/lang/String;Ljava/lang/Module;)V");
3640
EXCEPTION_CHECK_VOID(jniEnv)
37-
jvalue args[4] {};
41+
jvalue args[3];
3842
args[0].l = m1;
3943
args[1].l = pn;
4044
args[2].l = m2;
41-
jniEnv->CallStaticVoidMethodA(modulesClass, addExports, args);
42-
}
43-
44-
// Library entry points
45-
46-
#ifdef __cplusplus
47-
extern "C" {
48-
#endif
49-
50-
JNIEXPORT void JNICALL Java_com_oracle_truffle_runtime_ModulesSupport_addExports0(JNIEnv *env, jclass clz, jobject m1, jobject pn, jobject m2) {
51-
addExports(env, m1, pn, m2);
52-
}
53-
54-
55-
#ifdef __cplusplus
45+
(*jniEnv)->CallStaticVoidMethodA(jniEnv, modulesClass, addExports, args);
5646
}
57-
#endif
58-

0 commit comments

Comments
 (0)