SGX specific ifdefs

This commit is contained in:
Andras Slemmer 2017-01-19 16:55:54 +00:00 committed by exfalso
parent 539af98836
commit 8a03bcee6a
8 changed files with 41 additions and 4 deletions

View File

@ -232,6 +232,8 @@ static inline void releaseChars(JNIEnv* e, jstring path, string_t chars)
e->RELEASE_CHARS(path, chars);
}
#ifndef SGX
extern "C" JNIEXPORT jstring JNICALL
Java_java_io_File_toCanonicalPath(JNIEnv* /*e*/, jclass, jstring path)
{
@ -802,6 +804,8 @@ extern "C" JNIEXPORT jint JNICALL
}
}
#endif // !SGX
extern "C" JNIEXPORT void JNICALL
Java_java_io_FileOutputStream_write__II(JNIEnv* e, jclass, jint fd, jint c)
{
@ -838,6 +842,8 @@ extern "C" JNIEXPORT void JNICALL
doClose(e, fd);
}
#ifndef SGX
extern "C" JNIEXPORT void JNICALL
Java_java_io_RandomAccessFile_open(JNIEnv* e,
jclass,
@ -1005,3 +1011,5 @@ extern "C" JNIEXPORT void JNICALL
CloseHandle(hFile);
#endif
}
#endif // !SGX

View File

@ -8,6 +8,8 @@
There is NO WARRANTY for this software. See license.txt for
details. */
#ifndef SGX
#include "jni.h"
#include "avian/machine.h"
#include "sockets.h"
@ -139,3 +141,5 @@ extern "C" JNIEXPORT jint JNICALL
return 0;
}
}
#endif // !SGX

View File

@ -8,6 +8,8 @@
There is NO WARRANTY for this software. See license.txt for
details. */
#ifndef SGX
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
@ -1096,3 +1098,5 @@ extern "C" JNIEXPORT jboolean JNICALL
return JNI_TRUE;
return JNI_FALSE;
}
#endif // !SGX

View File

@ -13,6 +13,8 @@
* It is used from different classes of the default Avian classpath
*/
#ifndef SGX
#include "sockets.h"
namespace avian {
@ -199,3 +201,5 @@ void close_output(JNIEnv* e, SOCKET sock)
}
}
}
#endif

View File

@ -524,6 +524,10 @@ build-system = posix
system = posix
asm = x86
ifeq ($(system),sgx)
cflags += -DSGX
endif
pointer-size = 8
so-prefix = lib

View File

@ -1831,6 +1831,15 @@ inline uint64_t runThread(Thread* t, uintptr_t*)
inline bool startThread(Thread* t, Thread* p)
{
p->setFlag(Thread::JoinFlag);
#ifdef SGX
static const char16_t *nameToSkip = u"Reference Handler";
if (p->javaThread->name()->length(t) == 17) {
if (!memcmp(nameToSkip, cast<GcCharArray>(t, p->javaThread->name()->data())->body().begin(), 17 * 2)) {
printf("Skipping start of reference handler thread\n");
return true;
}
}
#endif
return t->m->system->success(t->m->system->start(&(p->runnable)));
}

View File

@ -70,6 +70,7 @@ jint JNICALL DetachCurrentThread(Machine* m)
uint64_t destroyJavaVM(Thread* t, uintptr_t*)
{
#ifndef SGX
// wait for other non-daemon threads to exit
{
ACQUIRE(t, t->m->stateLock);
@ -77,13 +78,13 @@ uint64_t destroyJavaVM(Thread* t, uintptr_t*)
t->m->stateLock->wait(t->systemThread, 0);
}
}
#endif
{
ENTER(t, Thread::ActiveState);
t->m->classpath->shutDown(t);
}
#ifndef SGX
// wait again in case the Classpath::shutDown process started new
// threads:
{
@ -94,7 +95,7 @@ uint64_t destroyJavaVM(Thread* t, uintptr_t*)
enter(t, Thread::ExclusiveState);
}
#endif
shutDown(t);
return 1;
@ -3349,11 +3350,12 @@ uint64_t boot(Thread* t, uintptr_t*)
t->javaThread->peer() = reinterpret_cast<jlong>(t);
#ifndef SGX
GcThread* jthread = t->m->classpath->makeThread(t, t);
// sequence point, for gc (don't recombine statements)
roots(t)->setFinalizerThread(t, jthread);
roots(t)->finalizerThread()->daemon() = true;
#endif
t->m->classpath->boot(t);

View File

@ -3541,6 +3541,7 @@ void doCollect(Thread* t, Heap::CollectionType type, int pendingAllocation)
function(t, finalizeQueue->target());
}
#ifndef SGX
if ((roots(t)->objectsToFinalize() or roots(t)->objectsToClean())
and m->finalizeThread == 0 and t->state != Thread::ExitState) {
m->finalizeThread = m->processor->makeThread(
@ -3553,6 +3554,7 @@ void doCollect(Thread* t, Heap::CollectionType type, int pendingAllocation)
m->finalizeThread = 0;
}
}
#endif
}
uint64_t invokeLoadClass(Thread* t, uintptr_t* arguments)