Merge pull request #316 from bigfatbrowncat/fixing-windows-build

Fixed Android build on Windows
This commit is contained in:
Joel Dice 2014-07-29 08:43:39 -06:00
commit 9f182d4613
4 changed files with 23 additions and 17 deletions

View File

@ -79,6 +79,11 @@
#endif #endif
#endif // WINAPI_FAMILY #endif // WINAPI_FAMILY
#ifndef M_E
// in new C++-11 standard math.h doesn't have M_E, at least on MinGW, so define it manually
#define M_E 2.7182818284590452354
#endif // M_E
namespace { namespace {
void add(JNIEnv* e, jobjectArray array, unsigned index, const char* format, ...) void add(JNIEnv* e, jobjectArray array, unsigned index, const char* format, ...)

View File

@ -251,9 +251,9 @@ ifneq ($(android),)
android-cflags += -D__STDC_CONSTANT_MACROS android-cflags += -D__STDC_CONSTANT_MACROS
blacklist = $(luni-native)/java_io_Console.cpp \ blacklist = $(luni-native)/java_io_Console.cpp \
$(luni-native)/java_lang_ProcessManager.cpp \ $(luni-native)/java_lang_ProcessManager.cpp \
$(luni-native)/java_math_NativeBN.cpp \
$(luni-native)/libcore_net_RawSocket.cpp $(luni-native)/libcore_net_RawSocket.cpp
luni-cpps := $(filter-out $(blacklist),$(luni-cpps))
icu-libs := $(android)/external/icu4c/lib/sicuin.a \ icu-libs := $(android)/external/icu4c/lib/sicuin.a \
$(android)/external/icu4c/lib/sicuuc.a \ $(android)/external/icu4c/lib/sicuuc.a \
$(android)/external/icu4c/lib/sicudt.a $(android)/external/icu4c/lib/sicudt.a
@ -262,11 +262,11 @@ ifneq ($(android),)
android-cflags += -fPIC -DHAVE_SYS_UIO_H android-cflags += -fPIC -DHAVE_SYS_UIO_H
blacklist = $(luni-native)/java_math_NativeBN.cpp blacklist = $(luni-native)/java_math_NativeBN.cpp
luni-cpps := $(filter-out $(blacklist),$(luni-cpps))
icu-libs := $(android)/external/icu4c/lib/libicui18n.a \ icu-libs := $(android)/external/icu4c/lib/libicui18n.a \
$(android)/external/icu4c/lib/libicuuc.a \ $(android)/external/icu4c/lib/libicuuc.a \
$(android)/external/icu4c/lib/libicudata.a $(android)/external/icu4c/lib/libicudata.a
endif endif
luni-cpps := $(filter-out $(blacklist),$(luni-cpps))
classpath-lflags := \ classpath-lflags := \
$(icu-libs) \ $(icu-libs) \

View File

@ -2565,13 +2565,14 @@ void register_libcore_net_RawSocket(_JNIEnv*)
extern "C" AVIAN_EXPORT void JNICALL extern "C" AVIAN_EXPORT void JNICALL
Avian_libcore_io_OsConstants_initConstants(Thread* t, Avian_libcore_io_OsConstants_initConstants(Thread* t,
object method, object m,
uintptr_t*) uintptr_t*)
{ {
object c = method->class_(); GcMethod* method = cast<GcMethod>(t, m);
GcClass* c = method->class_();
PROTECT(t, c); PROTECT(t, c);
object table = classStaticTable(t, c); object table = c->staticTable();
PROTECT(t, table); PROTECT(t, table);
GcField* field = resolveField(t, c, "STDIN_FILENO", "I"); GcField* field = resolveField(t, c, "STDIN_FILENO", "I");
@ -2587,7 +2588,7 @@ extern "C" AVIAN_EXPORT void JNICALL
extern "C" AVIAN_EXPORT int64_t JNICALL extern "C" AVIAN_EXPORT int64_t JNICALL
Avian_libcore_io_Posix_getenv(Thread* t, object, uintptr_t* arguments) Avian_libcore_io_Posix_getenv(Thread* t, object, uintptr_t* arguments)
{ {
object name = reinterpret_cast<object>(arguments[1]); GcString* name = cast<GcString>(t, reinterpret_cast<object>(arguments[1]));
THREAD_RUNTIME_ARRAY(t, uint16_t, chars, name->length(t) + 1); THREAD_RUNTIME_ARRAY(t, uint16_t, chars, name->length(t) + 1);
stringChars(t, name, RUNTIME_ARRAY_BODY(chars)); stringChars(t, name, RUNTIME_ARRAY_BODY(chars));
@ -2598,9 +2599,9 @@ extern "C" AVIAN_EXPORT int64_t JNICALL
if (value) { if (value) {
unsigned size = wcslen(value); unsigned size = wcslen(value);
object a = makeCharArray(t, size); GcCharArray* a = makeCharArray(t, size);
if (size) { if (size) {
memcpy(&charArrayBody(t, a, 0), value, size * sizeof(jchar)); memcpy(a->body().begin(), value, size * sizeof(jchar));
} }
return reinterpret_cast<uintptr_t>( return reinterpret_cast<uintptr_t>(
@ -2630,23 +2631,23 @@ extern "C" AVIAN_EXPORT int64_t JNICALL
object arch = makeString(t, "unknown"); object arch = makeString(t, "unknown");
#endif #endif
set(t, setField(t,
instance, instance,
fieldOffset(t, resolveField(t, c, "machine", "Ljava/lang/String;")), resolveField(t, c, "machine", "Ljava/lang/String;")->offset(),
arch); arch);
object platform = makeString(t, "Windows"); object platform = makeString(t, "Windows");
set(t, setField(t,
instance, instance,
fieldOffset(t, resolveField(t, c, "sysname", "Ljava/lang/String;")), resolveField(t, c, "sysname", "Ljava/lang/String;")->offset(),
platform); platform);
object version = makeString(t, "unknown"); object version = makeString(t, "unknown");
set(t, setField(t,
instance, instance,
fieldOffset(t, resolveField(t, c, "release", "Ljava/lang/String;")), resolveField(t, c, "release", "Ljava/lang/String;")->offset(),
version); version);
return reinterpret_cast<uintptr_t>(instance); return reinterpret_cast<uintptr_t>(instance);
@ -2658,7 +2659,7 @@ extern "C" AVIAN_EXPORT int64_t JNICALL
object fd = reinterpret_cast<object>(arguments[1]); object fd = reinterpret_cast<object>(arguments[1]);
PROTECT(t, fd); PROTECT(t, fd);
object buffer = reinterpret_cast<object>(arguments[2]); GcByteArray* buffer = cast<GcByteArray>(t, reinterpret_cast<object>(arguments[2]));
PROTECT(t, buffer); PROTECT(t, buffer);
int offset = arguments[3]; int offset = arguments[3];
@ -2669,7 +2670,7 @@ extern "C" AVIAN_EXPORT int64_t JNICALL
int r; int r;
if (objectClass(t, buffer) == type(t, GcByteArray::Type)) { if (objectClass(t, buffer) == type(t, GcByteArray::Type)) {
void* tmp = t->m->heap->allocate(count); void* tmp = t->m->heap->allocate(count);
memcpy(tmp, &byteArrayBody(t, buffer, offset), count); memcpy(tmp, &buffer->body()[offset], count);
{ {
ENTER(t, Thread::IdleState); ENTER(t, Thread::IdleState);
r = _write(d, tmp, count); r = _write(d, tmp, count);

View File

@ -14,7 +14,7 @@
#include <string.h> #include <string.h>
#include <sys/stat.h> #include <sys/stat.h>
#ifdef WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>
#else #else
#include <sys/mman.h> #include <sys/mman.h>