1
0
Fork 0
forked from len0rd/rockbox

Android: Partly revert r29569 and only call the new getJavaEnvironment() when needed.

The environment is fine to share in general, just not across OS threads, so it's only needed
for functions which are possibly called from multiple OS threads (only 1 currently).

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29601 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Thomas Martitz 2011-03-16 14:33:55 +00:00
parent efa9f13500
commit 046cec3aa7
10 changed files with 50 additions and 55 deletions

View file

@ -21,8 +21,6 @@
#ifndef __SYSTEM_TARGET_H__
#define __SYSTEM_TARGET_H__
#include <jni.h>
#define disable_irq()
#define enable_irq()
#define disable_irq_save() 0
@ -32,19 +30,15 @@ void power_off(void);
void wait_for_interrupt(void);
void interrupt(void);
/* A JNI environment is specific to its thread, so use the correct way to
* obtain it: share a pointer to the JavaVM structure and ask that the JNI
* environment attached to the current thread. */
static inline JNIEnv* getJavaEnvironment(void)
{
extern JavaVM *vm_ptr;
JNIEnv *env = NULL;
if (vm_ptr)
(*vm_ptr)->GetEnv(vm_ptr, (void**) &env, JNI_VERSION_1_2);
return env;
}
/* don't pull in jni.h for every user of this file, it should be only needed
* within the target tree (if at all)
* define this before #including system.h or system-target.h */
#ifdef _SYSTEM_WITH_JNI
#include <jni.h>
/*
* discover the JNIEnv for this the calling thread in case it's not known */
extern JNIEnv* getJavaEnvironment(void);
#endif /* _SYSTEM_WITH_JNI */
#endif /* __SYSTEM_TARGET_H__ */