fix native Windows GCC 3.4 OpenJDK build

This commit is contained in:
Joel Dice 2010-11-12 18:29:12 -07:00
parent 26a59612bb
commit 0ca6c3ed53
3 changed files with 40 additions and 18 deletions

View File

@ -54,6 +54,18 @@ test-executable = $(executable)
boot-classpath = $(classpath-build) boot-classpath = $(classpath-build)
embed-prefix = /avian-embedded embed-prefix = /avian-embedded
native-path = echo
ifeq ($(build-platform),cygwin)
native-path = cygpath -m
endif
path-separator = :
ifneq (,$(filter mingw32 cygwin,$(build-platform)))
path-separator = ;
endif
ifdef openjdk ifdef openjdk
ifdef openjdk-src ifdef openjdk-src
include openjdk-src.mk include openjdk-src.mk
@ -72,11 +84,11 @@ ifdef openjdk
options := $(options)-openjdk options := $(options)-openjdk
test-executable = $(executable-dynamic) test-executable = $(executable-dynamic)
library-path = LD_LIBRARY_PATH=$(build) library-path = LD_LIBRARY_PATH=$(build)
javahome = $(openjdk)/jre javahome = "$$($(native-path) "$(openjdk)/jre")"
endif endif
classpath = openjdk classpath = openjdk
boot-classpath := $(boot-classpath):$(openjdk)/jre/lib/rt.jar boot-classpath := "$(boot-classpath)$(path-separator)$$($(native-path) "$(openjdk)/jre/lib/rt.jar")"
build-javahome = $(openjdk)/jre build-javahome = $(openjdk)/jre
endif endif
@ -127,7 +139,7 @@ warnings = -Wall -Wextra -Werror -Wunused-parameter -Winit-self \
common-cflags = $(warnings) -fno-rtti -fno-exceptions -fno-omit-frame-pointer \ common-cflags = $(warnings) -fno-rtti -fno-exceptions -fno-omit-frame-pointer \
"-I$(JAVA_HOME)/include" -idirafter $(src) -I$(build) $(classpath-cflags) \ "-I$(JAVA_HOME)/include" -idirafter $(src) -I$(build) $(classpath-cflags) \
-D__STDC_LIMIT_MACROS -D_JNI_IMPLEMENTATION_ -DAVIAN_VERSION=\"$(version)\" \ -D__STDC_LIMIT_MACROS -D_JNI_IMPLEMENTATION_ -DAVIAN_VERSION=\"$(version)\" \
-DUSE_ATOMIC_OPERATIONS "-DAVIAN_JAVA_HOME=\"$(javahome)\"" \ -DUSE_ATOMIC_OPERATIONS -DAVIAN_JAVA_HOME=\"$(javahome)\" \
-DAVIAN_EMBED_PREFIX=\"$(embed-prefix)\" -DAVIAN_EMBED_PREFIX=\"$(embed-prefix)\"
build-cflags = $(common-cflags) -fPIC -fvisibility=hidden \ build-cflags = $(common-cflags) -fPIC -fvisibility=hidden \
@ -157,8 +169,6 @@ so-suffix = .so
shared = -shared shared = -shared
native-path = echo
ifeq ($(arch),i386) ifeq ($(arch),i386)
pointer-size = 4 pointer-size = 4
endif endif
@ -241,7 +251,6 @@ ifeq ($(platform),windows)
build-cflags += -mno-cygwin build-cflags += -mno-cygwin
lflags += -mno-cygwin lflags += -mno-cygwin
cflags += -mno-cygwin cflags += -mno-cygwin
native-path = cygpath -m
endif endif
endif endif

View File

@ -1528,11 +1528,11 @@ Avian_sun_misc_Unsafe_compareAndSwapInt
{ {
object target = reinterpret_cast<object>(arguments[1]); object target = reinterpret_cast<object>(arguments[1]);
int64_t offset; memcpy(&offset, arguments + 2, 8); int64_t offset; memcpy(&offset, arguments + 2, 8);
int32_t expect = arguments[4]; uint32_t expect = arguments[4];
int32_t update = arguments[5]; uint32_t update = arguments[5];
return __sync_bool_compare_and_swap return atomicCompareAndSwap32
(&cast<int32_t>(target, offset), expect, update); (&cast<uint32_t>(target, offset), expect, update);
} }
extern "C" JNIEXPORT int64_t JNICALL extern "C" JNIEXPORT int64_t JNICALL
@ -1541,11 +1541,11 @@ Avian_sun_misc_Unsafe_compareAndSwapObject
{ {
object target = reinterpret_cast<object>(arguments[1]); object target = reinterpret_cast<object>(arguments[1]);
int64_t offset; memcpy(&offset, arguments + 2, 8); int64_t offset; memcpy(&offset, arguments + 2, 8);
intptr_t expect = arguments[4]; uintptr_t expect = arguments[4];
intptr_t update = arguments[5]; uintptr_t update = arguments[5];
bool success = __sync_bool_compare_and_swap bool success = atomicCompareAndSwap
(&cast<intptr_t>(target, offset), expect, update); (&cast<uintptr_t>(target, offset), expect, update);
if (success) { if (success) {
mark(t, target, offset); mark(t, target, offset);
@ -1560,11 +1560,11 @@ Avian_sun_misc_Unsafe_compareAndSwapLong
{ {
object target = reinterpret_cast<object>(arguments[1]); object target = reinterpret_cast<object>(arguments[1]);
int64_t offset; memcpy(&offset, arguments + 2, 8); int64_t offset; memcpy(&offset, arguments + 2, 8);
int64_t expect; memcpy(&expect, arguments + 4, 8); uint64_t expect; memcpy(&expect, arguments + 4, 8);
int64_t update; memcpy(&update, arguments + 6, 8); uint64_t update; memcpy(&update, arguments + 6, 8);
return __sync_bool_compare_and_swap return atomicCompareAndSwap64
(&cast<int64_t>(target, offset), expect, update); (&cast<uint64_t>(target, offset), expect, update);
} }
extern "C" JNIEXPORT int64_t JNICALL extern "C" JNIEXPORT int64_t JNICALL

View File

@ -223,6 +223,19 @@ atomicCompareAndSwap64(uint64_t* p, uint64_t old, uint64_t new_)
(reinterpret_cast<LONGLONG*>(p), new_, old); (reinterpret_cast<LONGLONG*>(p), new_, old);
#elif (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 1) #elif (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 1)
return __sync_bool_compare_and_swap(p, old, new_); return __sync_bool_compare_and_swap(p, old, new_);
#elif defined ARCH_x86_32
uint8_t result;
__asm__ __volatile__("lock; cmpxchg8b %0; setz %1"
: "=m"(*p), "=q"(result)
: "a"(static_cast<uint32_t>(old)),
"d"(static_cast<uint32_t>(old >> 32)),
"b"(static_cast<uint32_t>(new_)),
"c"(static_cast<uint32_t>(new_ >> 32)),
"m"(*p)
: "memory");
return result != 0;
#else #else
uint8_t result; uint8_t result;