< prev index next >
test/hotspot/jtreg/gc/g1/libTestPeriodicCollectionJNI.c
Print this page
rev 53920 : imported patch 8218880-g1-crashes-periodic-gc-gclocker
rev 53921 : [mq]: 8218880-shade-review
*** 25,45 ****
* Native support for TestPeriodicCollectionJNI test.
*/
#include "jni.h"
static volatile int release_critical = 0;
JNIEXPORT jboolean JNICALL
Java_gc_g1_TestPeriodicCollectionJNI_blockInNative(JNIEnv* env, jobject obj, jintArray dummy) {
void* native_array = (*env)->GetPrimitiveArrayCritical(env, dummy, 0);
if (native_array == NULL) {
return JNI_FALSE;
}
! while (!release_critical) /* empty */;
(*env)->ReleasePrimitiveArrayCritical(env, dummy, native_array, 0);
return JNI_TRUE;
}
--- 25,61 ----
* Native support for TestPeriodicCollectionJNI test.
*/
#include "jni.h"
+ #ifdef WINDOWS
+ #include <windows.h>
+ #else
+ #include <unistd.h>
+ #endif
+
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+
static volatile int release_critical = 0;
JNIEXPORT jboolean JNICALL
Java_gc_g1_TestPeriodicCollectionJNI_blockInNative(JNIEnv* env, jobject obj, jintArray dummy) {
void* native_array = (*env)->GetPrimitiveArrayCritical(env, dummy, 0);
if (native_array == NULL) {
return JNI_FALSE;
}
! while (!release_critical) {
! #ifdef WINDOWS
! Sleep(1);
! #else
! usleep(1000);
! #endif
! }
(*env)->ReleasePrimitiveArrayCritical(env, dummy, native_array, 0);
return JNI_TRUE;
}
*** 47,51 ****
--- 63,71 ----
JNIEXPORT void JNICALL Java_gc_g1_TestPeriodicCollectionJNI_unblock(JNIEnv *env, jobject obj)
{
release_critical = 1;
}
+ #ifdef __cplusplus
+ }
+ #endif
+
< prev index next >