Skip to content

Commit

Permalink
Further fixes for compilation with Visual C
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Rogers committed Apr 1, 2009
1 parent 511d014 commit 9db39bf
Show file tree
Hide file tree
Showing 10 changed files with 180 additions and 106 deletions.
6 changes: 3 additions & 3 deletions tools/bootloader/harmony.c
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ vmiError JNICALL GetSystemProperty (VMInterface * vmi, char *key, char **valuePt
jboolean isCopy;
SYS_START();
TRACE_PRINTF("%s: VMI call GetSystemProperty %s\n", Me, key);
if (sysJavaVM.functions->GetEnv (&sysJavaVM, (void **) &env, JNI_VERSION_1_2) != JNI_OK)
if (sysJavaVM.functions->GetEnv ((JavaVM*)&sysJavaVM, (void **) &env, JNI_VERSION_1_2) != JNI_OK)
return VMI_ERROR_UNKNOWN;
jkey = (*env)->NewStringUTF(env, key);
systemClass = (*env)->FindClass (env, "java/lang/System");
Expand All @@ -133,7 +133,7 @@ vmiError JNICALL GetSystemProperty (VMInterface * vmi, char *key, char **valuePt
if (!mid)
return VMI_ERROR_UNKNOWN;
jvalue = (*env)->CallStaticObjectMethod(env, systemClass, mid, jkey);
*valuePtr = (*env)->GetStringUTFChars(env, jvalue, &isCopy);
*valuePtr = (char*)(*env)->GetStringUTFChars(env, jvalue, &isCopy);
/* TODO: release this string */
TRACE_PRINTF("%s: VMI call GetSystemProperty %s = %s\n", Me, key, *valuePtr);
return VMI_ERROR_NONE;
Expand All @@ -148,7 +148,7 @@ vmiError JNICALL SetSystemProperty (VMInterface * vmi, char *key, char *value)
jboolean isCopy;
SYS_START();
TRACE_PRINTF("%s: VMI call SetSystemProperty %s = %s\n", Me, key, value);
if (sysJavaVM.functions->GetEnv (&sysJavaVM, (void **) &env, JNI_VERSION_1_2) != JNI_OK)
if (sysJavaVM.functions->GetEnv ((JavaVM*)&sysJavaVM, (void **) &env, JNI_VERSION_1_2) != JNI_OK)
return VMI_ERROR_UNKNOWN;
jkey = (*env)->NewStringUTF(env, key);
jvalue = (*env)->NewStringUTF(env, key);
Expand Down
Empty file modified tools/bootloader/jni/org_jikesrvm_runtime_DynamicLibrary.c
100644 → 100755
Empty file.
82 changes: 44 additions & 38 deletions tools/bootloader/jvm.c
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,18 @@ FILE *SysTraceFile;
/** Verbose command line option */
int verbose=0;

// Fish out an address stored in an instance field of an object.
/**
* Fish out an address stored in an instance field of an object.
*/
static void *getFieldAsAddress(void *objPtr, int fieldOffset)
{
char *fieldAddress = ((char*) objPtr) + fieldOffset;
return *((void**) fieldAddress);
}

// Get the JNI environment object from the Processor.
/**
* Get the JNI environment object from the VM thread.
*/
static JNIEnv * getJniEnvFromVmThread(void *vmThreadPtr)
{
void *jniEnvironment;
Expand All @@ -73,18 +77,17 @@ static JNIEnv * getJniEnvFromVmThread(void *vmThreadPtr)

/**
* Destroying the Java VM only makes sense if programs can create a VM
* on-the-fly. Further, as of Sun's Java 1.2, it sitll didn't support
* on-the-fly. Further, as of Sun's Java 1.2, it still didn't support
* unloading virtual machine instances. It is supposed to block until all
* other user threads are gone, and then return an error code.
*
* TODO: Implement.
*/
static
jint
DestroyJavaVM(JavaVM UNUSED * vm)
static jint DestroyJavaVM(JavaVM UNUSED * vm)
{
fprintf(stderr, "JikesRVM: Unimplemented JNI call DestroyJavaVM\n");
return JNI_ERR;
SYS_START();
ERROR_PRINTF("JikesRVM: Unimplemented JNI call DestroyJavaVM\n");
return JNI_ERR;
}

/**
Expand All @@ -97,41 +100,43 @@ DestroyJavaVM(JavaVM UNUSED * vm)
*/
static jint AttachCurrentThread(JavaVM UNUSED * vm, /* JNIEnv */ void ** penv, /* JavaVMAttachArgs */ void *args)
{
JavaVMAttachArgs *aargs = (JavaVMAttachArgs *) args;
jint version;
jint retval;
if (args == NULL) {
version = JNI_VERSION_1_1;
} else {
version = aargs->version ;
/* We'd like to handle aargs->name and aargs->group */
}

// Handled for us by GetEnv(). We do it here anyway so that we avoid
// printing an error message further along in this function.
if (version > JNI_VERSION_1_4)
return JNI_EVERSION;

/* If we're already attached, we're gold. */
retval = GetEnv(vm, penv, version);
if (retval == JNI_OK)
return retval;
else if (retval == JNI_EDETACHED) {
fprintf(stderr, "JikesRVM: JNI call AttachCurrentThread Unimplemented for threads not already attached to the VM\n");
} else {
fprintf(stderr, "JikesRVM: JNI call AttachCurrentThread failed; returning UNEXPECTED error code %d\n", (int) retval);
}

// Upon failure:
*penv = NULL; // Make sure we don't yield a bogus one to use.
SYS_START();
JavaVMAttachArgs *aargs = (JavaVMAttachArgs *) args;
jint version;
jint retval;
if (args == NULL) {
version = JNI_VERSION_1_1;
} else {
version = aargs->version ;
/* We'd like to handle aargs->name and aargs->group */
}

// Handled for us by GetEnv(). We do it here anyway so that we avoid
// printing an error message further along in this function.
if (version > JNI_VERSION_1_4)
return JNI_EVERSION;

/* If we're already attached, we're gold. */
retval = GetEnv(vm, penv, version);
if (retval == JNI_OK)
return retval;
else if (retval == JNI_EDETACHED) {
ERROR_PRINTF("JikesRVM: JNI call AttachCurrentThread Unimplemented for threads not already attached to the VM\n");
} else {
ERROR_PRINTF("JikesRVM: JNI call AttachCurrentThread failed; returning UNEXPECTED error code %d\n", (int) retval);
}

// Upon failure:
*penv = NULL; // Make sure we don't yield a bogus one to use.
return retval;
}

/* TODO: Implement */
static jint DetachCurrentThread(JavaVM UNUSED *vm)
{
fprintf(stderr, "UNIMPLEMENTED JNI call DetachCurrentThread\n");
return JNI_ERR;
SYS_START();
ERROR_PRINTF("UNIMPLEMENTED JNI call DetachCurrentThread\n");
return JNI_ERR;
}

jint GetEnv(JavaVM UNUSED *vm, void **penv, jint version)
Expand All @@ -151,7 +156,7 @@ jint GetEnv(JavaVM UNUSED *vm, void **penv, jint version)
// Get the JNIEnv from the RVMThread object
env = getJniEnvFromVmThread(vmThread);

*penv = env;
*((JNIEnv**)penv) = env;

return JNI_OK;
}
Expand Down Expand Up @@ -184,3 +189,4 @@ const struct JavaVM_ sysJavaVM = {
NULL, // threadIDTable
NULL, // jniEnvTable
};

File renamed without changes.
Loading

0 comments on commit 9db39bf

Please sign in to comment.