mirror of
https://github.com/corda/corda.git
synced 2025-01-31 16:35:43 +00:00
more windows port fixes
This commit is contained in:
parent
f2f453cf75
commit
eaf1d205cd
@ -8,11 +8,9 @@
|
|||||||
#include "jni.h"
|
#include "jni.h"
|
||||||
#include "jni-util.h"
|
#include "jni-util.h"
|
||||||
|
|
||||||
#undef JNIEXPORT
|
|
||||||
#define JNIEXPORT __attribute__ ((visibility("default")))
|
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
# include <io.h>
|
# include <io.h>
|
||||||
|
|
||||||
# define OPEN _open
|
# define OPEN _open
|
||||||
# define CLOSE _close
|
# define CLOSE _close
|
||||||
# define READ _read
|
# define READ _read
|
||||||
@ -25,6 +23,7 @@
|
|||||||
# define OPEN_MASK O_BINARY
|
# define OPEN_MASK O_BINARY
|
||||||
#else
|
#else
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
|
|
||||||
# define OPEN open
|
# define OPEN open
|
||||||
# define CLOSE close
|
# define CLOSE close
|
||||||
# define READ read
|
# define READ read
|
||||||
@ -35,6 +34,9 @@
|
|||||||
# define CREAT creat
|
# define CREAT creat
|
||||||
# define UNLINK unlink
|
# define UNLINK unlink
|
||||||
# define OPEN_MASK 0
|
# define OPEN_MASK 0
|
||||||
|
|
||||||
|
# undef JNIEXPORT
|
||||||
|
# define JNIEXPORT __attribute__ ((visibility("default")))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -11,9 +11,12 @@
|
|||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
# include "windows.h"
|
# include "windows.h"
|
||||||
|
#else
|
||||||
|
# undef JNIEXPORT
|
||||||
|
# define JNIEXPORT __attribute__ ((visibility("default")))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#ifdef WIN32
|
||||||
# define SO_PREFIX ""
|
# define SO_PREFIX ""
|
||||||
#else
|
#else
|
||||||
# define SO_PREFIX "lib"
|
# define SO_PREFIX "lib"
|
||||||
@ -27,9 +30,6 @@
|
|||||||
# define SO_SUFFIX ".so"
|
# define SO_SUFFIX ".so"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#undef JNIEXPORT
|
|
||||||
#define JNIEXPORT __attribute__ ((visibility("default")))
|
|
||||||
|
|
||||||
extern "C" JNIEXPORT jstring JNICALL
|
extern "C" JNIEXPORT jstring JNICALL
|
||||||
Java_java_lang_System_getProperty(JNIEnv* e, jclass, jint code)
|
Java_java_lang_System_getProperty(JNIEnv* e, jclass, jint code)
|
||||||
{
|
{
|
||||||
@ -55,7 +55,6 @@ Java_java_lang_System_getProperty(JNIEnv* e, jclass, jint code)
|
|||||||
case JavaIoTmpdir: {
|
case JavaIoTmpdir: {
|
||||||
TCHAR buffer[MAX_PATH];
|
TCHAR buffer[MAX_PATH];
|
||||||
GetTempPath(MAX_PATH, buffer);
|
GetTempPath(MAX_PATH, buffer);
|
||||||
fprintf(stderr, "tmpdir: %s\n", buffer);
|
|
||||||
return e->NewStringUTF(buffer);
|
return e->NewStringUTF(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,9 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "jni.h"
|
||||||
|
#include "jni-util.h"
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
# include <winsock2.h>
|
# include <winsock2.h>
|
||||||
# include <errno.h>
|
# include <errno.h>
|
||||||
@ -12,14 +15,11 @@
|
|||||||
# include <errno.h>
|
# include <errno.h>
|
||||||
# include <netdb.h>
|
# include <netdb.h>
|
||||||
# include <sys/select.h>
|
# include <sys/select.h>
|
||||||
|
|
||||||
|
# undef JNIEXPORT
|
||||||
|
# define JNIEXPORT __attribute__ ((visibility("default")))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "jni.h"
|
|
||||||
#include "jni-util.h"
|
|
||||||
|
|
||||||
#undef JNIEXPORT
|
|
||||||
#define JNIEXPORT __attribute__ ((visibility("default")))
|
|
||||||
|
|
||||||
#define java_nio_channels_SelectionKey_OP_READ 1L
|
#define java_nio_channels_SelectionKey_OP_READ 1L
|
||||||
#define java_nio_channels_SelectionKey_OP_WRITE 4L
|
#define java_nio_channels_SelectionKey_OP_WRITE 4L
|
||||||
#define java_nio_channels_SelectionKey_OP_ACCEPT 16L
|
#define java_nio_channels_SelectionKey_OP_ACCEPT 16L
|
||||||
|
@ -5,8 +5,10 @@
|
|||||||
#include "jni.h"
|
#include "jni.h"
|
||||||
#include "jni-util.h"
|
#include "jni-util.h"
|
||||||
|
|
||||||
#undef JNIEXPORT
|
#ifndef WIN32
|
||||||
#define JNIEXPORT __attribute__ ((visibility("default")))
|
# undef JNIEXPORT
|
||||||
|
# define JNIEXPORT __attribute__ ((visibility("default")))
|
||||||
|
#endif
|
||||||
|
|
||||||
extern "C" JNIEXPORT jlong JNICALL
|
extern "C" JNIEXPORT jlong JNICALL
|
||||||
Java_java_util_zip_Inflater_make
|
Java_java_util_zip_Inflater_make
|
||||||
|
4
makefile
4
makefile
@ -80,7 +80,7 @@ ifeq ($(platform),windows)
|
|||||||
ranlib = i586-mingw32msvc-ranlib
|
ranlib = i586-mingw32msvc-ranlib
|
||||||
|
|
||||||
rdynamic = -Wl,--export-dynamic
|
rdynamic = -Wl,--export-dynamic
|
||||||
lflags = -L$(lib) -lm -lz -lws2_32 -Wl,--kill-at
|
lflags = -L$(lib) -lm -lz -lws2_32 -Wl,--kill-at -mwindows -mconsole
|
||||||
cflags = $(common-cflags) -I$(inc)
|
cflags = $(common-cflags) -I$(inc)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -262,7 +262,7 @@ $(jni-objects): $(bld)/%.o: $(classpath)/%.cpp
|
|||||||
ifeq ($(platform),windows)
|
ifeq ($(platform),windows)
|
||||||
$(archive): $(interpreter-objects) $(jni-objects)
|
$(archive): $(interpreter-objects) $(jni-objects)
|
||||||
@echo "creating $(@)"
|
@echo "creating $(@)"
|
||||||
$(dlltool) --export-all-symbols -z $(@).def $(^)
|
$(dlltool) -z $(@).def $(^)
|
||||||
$(dlltool) -k -d $(@).def -e $(@).exp
|
$(dlltool) -k -d $(@).def -e $(@).exp
|
||||||
$(ar) cru $(@) $(@).exp $(^)
|
$(ar) cru $(@) $(@).exp $(^)
|
||||||
$(ranlib) $(@)
|
$(ranlib) $(@)
|
||||||
|
@ -2,8 +2,11 @@
|
|||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
#include "processor.h"
|
#include "processor.h"
|
||||||
|
|
||||||
#undef JNIEXPORT
|
#ifdef __MINGW32__
|
||||||
#define JNIEXPORT __attribute__ ((visibility("default")))
|
# define JNIEXPORT __declspec(dllexport)
|
||||||
|
#else
|
||||||
|
# define JNIEXPORT __attribute__ ((visibility("default")))
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace vm;
|
using namespace vm;
|
||||||
|
|
||||||
@ -520,8 +523,6 @@ Java_java_lang_Runtime_load(Thread* t, jclass, jstring name, jboolean mapName)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "load %s; map name: %d\n", n, mapName);
|
|
||||||
|
|
||||||
System::Library* lib;
|
System::Library* lib;
|
||||||
if (LIKELY(t->m->system->success
|
if (LIKELY(t->m->system->success
|
||||||
(t->m->system->load(&lib, n, mapName, t->m->libraries))))
|
(t->m->system->load(&lib, n, mapName, t->m->libraries))))
|
||||||
|
@ -7,7 +7,11 @@
|
|||||||
#include "finder.h"
|
#include "finder.h"
|
||||||
#include "processor.h"
|
#include "processor.h"
|
||||||
|
|
||||||
#define JNICALL
|
#ifdef __MINGW32__
|
||||||
|
# define JNICALL __stdcall
|
||||||
|
#else
|
||||||
|
# define JNICALL
|
||||||
|
#endif
|
||||||
|
|
||||||
#define PROTECT(thread, name) \
|
#define PROTECT(thread, name) \
|
||||||
Thread::SingleProtector MAKE_NAME(protector_) (thread, &name);
|
Thread::SingleProtector MAKE_NAME(protector_) (thread, &name);
|
||||||
|
@ -140,6 +140,28 @@ resolveNativeMethod(Thread* t, object method)
|
|||||||
if (p) {
|
if (p) {
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
else {
|
||||||
|
// on windows, we also try the _%s@%d variant, since the SWT
|
||||||
|
// libraries use it.
|
||||||
|
|
||||||
|
unsigned footprint = methodParameterFootprint(t, method) + 1;
|
||||||
|
if (methodFlags(t, method) & ACC_STATIC) {
|
||||||
|
++ footprint;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned size = byteArrayLength(t, methodCode(t, method)) + 5;
|
||||||
|
char buffer[size];
|
||||||
|
snprintf(buffer, size, "_%s@%d",
|
||||||
|
&byteArrayBody(t, methodCode(t, method), 0),
|
||||||
|
footprint * BytesPerWord);
|
||||||
|
|
||||||
|
p = lib->resolve(buffer);
|
||||||
|
if (p) {
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
24
src/x86.S
24
src/x86.S
@ -4,8 +4,8 @@
|
|||||||
|
|
||||||
#ifdef __x86_64__
|
#ifdef __x86_64__
|
||||||
|
|
||||||
.globl amd64Call
|
.globl vmNativeCall
|
||||||
amd64Call:
|
vmNativeCall:
|
||||||
pushq %rbp
|
pushq %rbp
|
||||||
|
|
||||||
// %rdi aka 0(%rbp): function
|
// %rdi aka 0(%rbp): function
|
||||||
@ -104,14 +104,14 @@ exit:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
#elif defined __i386__
|
#elif defined __i386__
|
||||||
|
|
||||||
#if defined __APPLE__ || defined __MINGW32__
|
# if defined __APPLE__ || defined __MINGW32__
|
||||||
.globl _cdeclCall
|
.globl _vmNativeCall
|
||||||
_cdeclCall:
|
_vmNativeCall:
|
||||||
#else
|
# else
|
||||||
.globl cdeclCall
|
.globl vmNativeCall
|
||||||
cdeclCall:
|
vmNativeCall:
|
||||||
#endif
|
# endif
|
||||||
pushl %ebp
|
pushl %ebp
|
||||||
movl %esp,%ebp
|
movl %esp,%ebp
|
||||||
|
|
||||||
@ -125,10 +125,10 @@ cdeclCall:
|
|||||||
|
|
||||||
subl %ecx,%esp
|
subl %ecx,%esp
|
||||||
|
|
||||||
#ifdef __APPLE__
|
# ifdef __APPLE__
|
||||||
// align to a 16 byte boundary on Darwin
|
// align to a 16 byte boundary on Darwin
|
||||||
andl $0xFFFFFFF0,%esp
|
andl $0xFFFFFFF0,%esp
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
// copy arguments into place
|
// copy arguments into place
|
||||||
movl $0,%ecx
|
movl $0,%ecx
|
||||||
|
15
src/x86.h
15
src/x86.h
@ -7,8 +7,8 @@
|
|||||||
#ifdef __i386__
|
#ifdef __i386__
|
||||||
|
|
||||||
extern "C" uint64_t
|
extern "C" uint64_t
|
||||||
cdeclCall(void* function, void* stack, unsigned stackSize,
|
vmNativeCall(void* function, void* stack, unsigned stackSize,
|
||||||
unsigned returnType);
|
unsigned returnType);
|
||||||
|
|
||||||
namespace vm {
|
namespace vm {
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ inline uint64_t
|
|||||||
dynamicCall(void* function, uintptr_t* arguments, uint8_t*,
|
dynamicCall(void* function, uintptr_t* arguments, uint8_t*,
|
||||||
unsigned, unsigned argumentsSize, unsigned returnType)
|
unsigned, unsigned argumentsSize, unsigned returnType)
|
||||||
{
|
{
|
||||||
return cdeclCall(function, arguments, argumentsSize, returnType);
|
return vmNativeCall(function, arguments, argumentsSize, returnType);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace vm
|
} // namespace vm
|
||||||
@ -24,8 +24,8 @@ dynamicCall(void* function, uintptr_t* arguments, uint8_t*,
|
|||||||
#elif defined __x86_64__
|
#elif defined __x86_64__
|
||||||
|
|
||||||
extern "C" uint64_t
|
extern "C" uint64_t
|
||||||
amd64Call(void* function, void* stack, unsigned stackSize,
|
vmNativeCall(void* function, void* stack, unsigned stackSize,
|
||||||
void* gprTable, void* sseTable, unsigned returnType);
|
void* gprTable, void* sseTable, unsigned returnType);
|
||||||
|
|
||||||
namespace vm {
|
namespace vm {
|
||||||
|
|
||||||
@ -65,8 +65,9 @@ dynamicCall(void* function, uint64_t* arguments, uint8_t* argumentTypes,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return amd64Call(function, stack, stackIndex * 8, (gprIndex ? gprTable : 0),
|
return vmNativeCall(function, stack, stackIndex * 8,
|
||||||
(sseIndex ? sseTable : 0), returnType);
|
(gprIndex ? gprTable : 0),
|
||||||
|
(sseIndex ? sseTable : 0), returnType);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace vm
|
} // namespace vm
|
||||||
|
Loading…
x
Reference in New Issue
Block a user