mirror of
https://github.com/corda/corda.git
synced 2025-05-21 17:57:43 +00:00
Merge branch 'master' of dice:git/vm
This commit is contained in:
commit
12fe480f1c
2
makefile
2
makefile
@ -82,7 +82,7 @@ endif
|
|||||||
ifeq ($(platform),darwin)
|
ifeq ($(platform),darwin)
|
||||||
build-cflags = $(common-cflags) -fPIC -fvisibility=hidden \
|
build-cflags = $(common-cflags) -fPIC -fvisibility=hidden \
|
||||||
-I$(JAVA_HOME)/include/linux -I$(src)
|
-I$(JAVA_HOME)/include/linux -I$(src)
|
||||||
lflags = $(common-lflags) -ldl
|
lflags = $(common-lflags) -ldl -framework CoreFoundation
|
||||||
strip-all = -S -x
|
strip-all = -S -x
|
||||||
binaryToMacho = $(native-build)/binaryToMacho
|
binaryToMacho = $(native-build)/binaryToMacho
|
||||||
endif
|
endif
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
#ifdef __APPLE__
|
||||||
|
#include "CoreFoundation/CoreFoundation.h"
|
||||||
|
#undef assert
|
||||||
|
#endif
|
||||||
#include "sys/mman.h"
|
#include "sys/mman.h"
|
||||||
#include "sys/types.h"
|
#include "sys/types.h"
|
||||||
#include "sys/stat.h"
|
#include "sys/stat.h"
|
||||||
@ -116,6 +120,28 @@ allocate(System* s, unsigned size)
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
pathOfExecutable(System* s, const char** retBuf, unsigned* size)
|
||||||
|
{
|
||||||
|
#ifdef __APPLE__
|
||||||
|
CFBundleRef bundle = CFBundleGetMainBundle();
|
||||||
|
CFURLRef url = CFBundleCopyExecutableURL(bundle);
|
||||||
|
CFStringRef path = CFURLCopyPath(url);
|
||||||
|
CFIndex pathSize = CFStringGetMaximumSizeOfFileSystemRepresentation(path);
|
||||||
|
char* buffer = reinterpret_cast<char*>(allocate(s, pathSize));
|
||||||
|
if (CFStringGetFileSystemRepresentation(path, buffer, pathSize)) {
|
||||||
|
*size = pathSize;
|
||||||
|
*retBuf = buffer;
|
||||||
|
} else {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
if (s)
|
||||||
|
*size = 0;
|
||||||
|
*retBuf = NULL;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
const bool Verbose = false;
|
const bool Verbose = false;
|
||||||
|
|
||||||
const unsigned Waiting = 1 << 0;
|
const unsigned Waiting = 1 << 0;
|
||||||
@ -646,6 +672,7 @@ class MySystem: public System {
|
|||||||
bool mapName)
|
bool mapName)
|
||||||
{
|
{
|
||||||
void* p;
|
void* p;
|
||||||
|
bool alreadyAllocated = false;
|
||||||
unsigned nameLength = (name ? strlen(name) : 0);
|
unsigned nameLength = (name ? strlen(name) : 0);
|
||||||
if (mapName) {
|
if (mapName) {
|
||||||
unsigned size = nameLength + 3 + sizeof(SO_SUFFIX);
|
unsigned size = nameLength + 3 + sizeof(SO_SUFFIX);
|
||||||
@ -653,6 +680,10 @@ class MySystem: public System {
|
|||||||
snprintf(buffer, size, "lib%s" SO_SUFFIX, name);
|
snprintf(buffer, size, "lib%s" SO_SUFFIX, name);
|
||||||
p = dlopen(buffer, RTLD_LAZY);
|
p = dlopen(buffer, RTLD_LAZY);
|
||||||
} else {
|
} else {
|
||||||
|
if (!name) {
|
||||||
|
pathOfExecutable(this, &name, &nameLength);
|
||||||
|
alreadyAllocated = true;
|
||||||
|
}
|
||||||
p = dlopen(name, RTLD_LAZY);
|
p = dlopen(name, RTLD_LAZY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -665,6 +696,9 @@ class MySystem: public System {
|
|||||||
if (name) {
|
if (name) {
|
||||||
n = static_cast<char*>(allocate(this, nameLength + 1));
|
n = static_cast<char*>(allocate(this, nameLength + 1));
|
||||||
memcpy(n, name, nameLength + 1);
|
memcpy(n, name, nameLength + 1);
|
||||||
|
if (alreadyAllocated) {
|
||||||
|
free(name, nameLength, false);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
n = 0;
|
n = 0;
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,7 @@ resolveNativeMethod2(Thread* t, object method)
|
|||||||
snprintf(decorated + decoratedSize - 1, 5, "@%d",
|
snprintf(decorated + decoratedSize - 1, 5, "@%d",
|
||||||
footprint * BytesPerWord);
|
footprint * BytesPerWord);
|
||||||
|
|
||||||
p = resolveNativeMethod(t, undecorated, decorated);
|
p = ::resolveNativeMethod(t, undecorated, decorated);
|
||||||
if (p) {
|
if (p) {
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user