summaryrefslogtreecommitdiff
path: root/recipes/cacao
diff options
context:
space:
mode:
authorDenys Dmytriyenko <denis@denix.org>2009-03-17 14:32:59 -0400
committerDenys Dmytriyenko <denis@denix.org>2009-03-17 14:32:59 -0400
commit709c4d66e0b107ca606941b988bad717c0b45d9b (patch)
tree37ee08b1eb308f3b2b6426d5793545c38396b838 /recipes/cacao
parentfa6cd5a3b993f16c27de4ff82b42684516d433ba (diff)
rename packages/ to recipes/ per earlier agreement
See links below for more details: http://thread.gmane.org/gmane.comp.handhelds.openembedded/21326 http://thread.gmane.org/gmane.comp.handhelds.openembedded/21816 Signed-off-by: Denys Dmytriyenko <denis@denix.org> Acked-by: Mike Westerhof <mwester@dls.net> Acked-by: Philip Balister <philip@balister.org> Acked-by: Khem Raj <raj.khem@gmail.com> Acked-by: Marcin Juszkiewicz <hrw@openembedded.org> Acked-by: Koen Kooi <koen@openembedded.org> Acked-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com>
Diffstat (limited to 'recipes/cacao')
-rw-r--r--recipes/cacao/cacao-cldc.inc64
-rw-r--r--recipes/cacao/cacao-cldc_0.98.bb17
-rw-r--r--recipes/cacao/cacao-initial_0.98.bb34
-rw-r--r--recipes/cacao/cacao-native.inc36
-rw-r--r--recipes/cacao/cacao-native_0.99.3.bb13
-rw-r--r--recipes/cacao/cacao.inc41
-rw-r--r--recipes/cacao/cacao_0.99.3.bb10
-rw-r--r--recipes/cacao/cacaoh-cldc-native_0.98.bb9
-rw-r--r--recipes/cacao/cacaoh-native.inc26
-rw-r--r--recipes/cacao/cacaoh-native_0.99.3.bb5
-rw-r--r--recipes/cacao/files/arm_mmap.patch21
-rw-r--r--recipes/cacao/files/cacao-0.98+svn-classpath_var.patch56
-rw-r--r--recipes/cacao/files/cacao-0.98-initial.patch45
-rw-r--r--recipes/cacao/files/cacao-arm-race.patch241
-rw-r--r--recipes/cacao/files/cacao-codegen-arm1.patch49
-rw-r--r--recipes/cacao/files/cacao-codegen-arm2.patch66
-rw-r--r--recipes/cacao/files/classpath_var.patch66
-rw-r--r--recipes/cacao/files/libmath.patch53
-rw-r--r--recipes/cacao/files/midpath.patch372
-rw-r--r--recipes/cacao/files/offset.h_arm.patch35
-rw-r--r--recipes/cacao/files/offsets_make.patch25
-rw-r--r--recipes/cacao/files/vfp-compat.patch37
22 files changed, 1321 insertions, 0 deletions
diff --git a/recipes/cacao/cacao-cldc.inc b/recipes/cacao/cacao-cldc.inc
new file mode 100644
index 0000000000..0a6e5249e7
--- /dev/null
+++ b/recipes/cacao/cacao-cldc.inc
@@ -0,0 +1,64 @@
+DESCRIPTION = "Cacao-cldc is a Java Virtual Machine, which uses MIDPath CLDC as default Java core library"
+HOMEPAGE = "http://www.cacaojvm.org/"
+LICENSE = "GPL"
+PRIORITY = "optional"
+SECTION = "interpreters"
+
+DEPENDS = "zlib libtool classpath midpath-cldc cacaoh-cldc-native virtual/javac-native"
+
+# Avoid version number here, otherwise dpkg will expect a package name
+# and cannot be satisfied with a package that provides classpath.
+RDEPENDS = "midpath-cldc"
+
+PROVIDES = "cacao-cldc virtual/java-cldc"
+RPROVIDES_cacao-cldc = "java-cldc-runtime"
+
+inherit autotools update-alternatives
+
+EXTRA_OECONF = "\
+ ${@['','--enable-softfloat'][bb.data.getVar('TARGET_FPU',d,1) == 'soft']} \
+ --enable-debug \
+ --enable-jni \
+ --disable-libjvm \
+ --enable-java=cldc1.1 \
+ --with-classpath=cldc1.1 \
+ --with-classpath-classes=${STAGING_DATADIR}/midpath-cldc/midpath-cldc1.1.jar \
+ --with-target-classpath-classes=${datadir}/midpath-cldc/midpath-cldc1.1.jar \
+ --with-cacaoh=${STAGING_BINDIR_NATIVE}/cacaoh-cldc-${PV} \
+ --with-classpath-libdir=${STAGING_LIBDIR}/classpath \
+ --with-classpath-includedir=${STAGING_INCDIR}/classpath \
+ --with-vm-zip=${datadir}/cacao-cldc/vm.zip \
+ --libdir=${libdir}/cacao-cldc \
+ --program-suffix=-cldc \
+ "
+
+S = "${WORKDIR}/cacao-${PV}"
+
+PACKAGES = "${PN} ${PN}-doc ${PN}-dbg"
+
+FILES_${PN} = "${bindir}/${PN} ${libdir}/lib*.so* ${datadir}/${PN}"
+FILES_${PN}-doc = "${datadir}/man"
+FILES_${PN}-dbg += "${bindir}/.debug ${libdir}/.debug/lib*.so*"
+
+ALTERNATIVE_NAME = "java-cldc"
+ALTERNATIVE_LINK = "${bindir}/${ALTERNATIVE_NAME}"
+ALTERNATIVE_PATH = "${bindir}/cacao-cldc"
+ALTERNATIVE_PRIORITY = "10"
+
+do_configure_prepend() {
+ # Replaces the placeholder OE_LIBDIR_JNI with the JNI library directory
+ # configured in OE.
+ if [ -e src/vm/properties.c ]; then
+ sed -i -e "s|OE_LIBDIR_JNI|${libdir}/jni|" src/vm/properties.c
+ fi
+
+ if [ -e src/vm/properties.c ]; then
+ sed -i -e "s|OE_LIBDIR_JNI|${libdir}/jni|" src/vm/vm.c
+ fi
+}
+
+do_configure_append() {
+ # Fix the executable name in the wrapper script.
+ sed -i -e "s|exec cacao|exec cacao-cldc|" src/scripts/java.in
+}
+
diff --git a/recipes/cacao/cacao-cldc_0.98.bb b/recipes/cacao/cacao-cldc_0.98.bb
new file mode 100644
index 0000000000..f5a48c40a9
--- /dev/null
+++ b/recipes/cacao/cacao-cldc_0.98.bb
@@ -0,0 +1,17 @@
+# Compatible with GNU Classpath 0.95 only!
+
+require cacao-cldc.inc
+
+PR = "r1"
+
+SRC_URI += "\
+ http://www.complang.tuwien.ac.at/cacaojvm/download/cacao-${PV}/cacao-${PV}.tar.bz2;md5sum=8b8907c8b925761c9410bcadb9705346 \
+ file://midpath.patch;patch=1 \
+ file://offsets_make.patch;patch=1 \
+ file://classpath_var.patch;patch=1 \
+ file://libmath.patch;patch=1 \
+ file://arm_mmap.patch;patch=1 \
+ "
+
+SRC_URI_append_arm = "file://offset.h_arm.patch;patch=1"
+
diff --git a/recipes/cacao/cacao-initial_0.98.bb b/recipes/cacao/cacao-initial_0.98.bb
new file mode 100644
index 0000000000..08abf41c33
--- /dev/null
+++ b/recipes/cacao/cacao-initial_0.98.bb
@@ -0,0 +1,34 @@
+require cacao-native.inc
+
+PROVIDES = "virtual/java-initial"
+
+DEPENDS = "zlib-native libtool-native fastjar-native classpath-initial jikes-initial"
+
+PR = "r0"
+
+SRC_URI = "\
+ http://www.complang.tuwien.ac.at/cacaojvm/download/cacao-${PV}/cacao-${PV}.tar.bz2; \
+ file://cacao-0.98-initial.patch;patch=1;pnum=1 \
+ "
+
+# libjvm disabled - it would conflict with cacao-native installations
+EXTRA_OECONF = "\
+ --enable-debug \
+ --with-classpath-libdir=${libdir} \
+ --with-classpath-includedir=${includedir}/classpath-initial \
+ --with-classpath-classes=${datadir}/classpath-initial/glibj.zip \
+ --with-vm-zip=${datadir}/cacao-initial/vm.zip \
+ --program-suffix=-initial \
+ --disable-libjvm \
+ "
+
+# enforces the usage of jikes-initial
+export JAVAC=jikes-initial
+
+# enforces the usage of fastjar
+export JAR=fastjar
+
+do_configure_append() {
+ # Fix the executable name in the wrapper script.
+ sed -i -e "s|exec cacao|exec cacao-initial|" src/scripts/java.in
+}
diff --git a/recipes/cacao/cacao-native.inc b/recipes/cacao/cacao-native.inc
new file mode 100644
index 0000000000..fc86e684c5
--- /dev/null
+++ b/recipes/cacao/cacao-native.inc
@@ -0,0 +1,36 @@
+DESCRIPTION = "CacaoVM for use as OpenEmbedded's Java VM"
+HOMEPAGE = "http://www.cacaojvm.org/"
+LICENSE = "GPL"
+PRIORITY = "optional"
+SECTION = "interpreters"
+
+DEPENDS = "zlib-native libtool-native classpath-native ecj-initial fastjar-native"
+
+PROVIDES = "virtual/java-native"
+
+S = "${WORKDIR}/cacao-${PV}"
+
+inherit native autotools
+
+EXTRA_OECONF = "\
+ --enable-debug \
+ --with-vm-zip=${datadir}/cacao/vm.zip \
+ \
+ --with-classpath-libdir=${libdir_jni}:${libdir} \
+ --with-classpath-includedir=${includedir}/classpath \
+ --with-classpath-classes=${datadir}/classpath/glibj.zip \
+ \
+ --with-java-runtime-library-classes=${datadir}/classpath/glibj.zip \
+ --with-java-runtime-library-libdir=${libdir_jni}:${libdir} \
+ --with-jni_md_h=${includedir}/classpath \
+ --with-jni_h=${includedir}/classpath \
+ "
+
+# force usage of ecj-initial
+# Important: Not specifying the bootclasspath argument here is only supported
+# for Cacao >= 0.99. Earlier Cacao may need the BCP set to a Java5-capable
+# class library.
+export JAVAC="${STAGING_BINDIR_NATIVE}/ecj-initial"
+
+# force usage of fastjar
+export JAR="fastjar"
diff --git a/recipes/cacao/cacao-native_0.99.3.bb b/recipes/cacao/cacao-native_0.99.3.bb
new file mode 100644
index 0000000000..878ef4dac2
--- /dev/null
+++ b/recipes/cacao/cacao-native_0.99.3.bb
@@ -0,0 +1,13 @@
+require cacao-native.inc
+
+PR = "r0"
+
+SRC_URI = "http://www.complang.tuwien.ac.at/cacaojvm/download/cacao-${PV}/cacao-${PV}.tar.bz2"
+
+do_compile_prepend() {
+
+ install -d ${S}/src/classes/classes/java
+ install -d ${S}/src/classes/classes/gnu/java
+ install -d ${S}/src/classes/classes/sun
+}
+
diff --git a/recipes/cacao/cacao.inc b/recipes/cacao/cacao.inc
new file mode 100644
index 0000000000..c22bbffd50
--- /dev/null
+++ b/recipes/cacao/cacao.inc
@@ -0,0 +1,41 @@
+DESCRIPTION = "Cacao is a Java Virtual Machine, which uses GNU Classpath as default Java core library"
+HOMEPAGE = "http://www.cacaojvm.org/"
+LICENSE = "GPL"
+PRIORITY = "optional"
+SECTION = "interpreters"
+
+DEPENDS = "zlib libtool classpath cacaoh-native virtual/javac-native"
+
+# Avoid version number here, otherwise dpkg will expect a package name
+# and cannot be satisfied with a package that provides classpath.
+RDEPENDS = "classpath"
+
+RPROVIDES_cacao = "java2-runtime"
+
+inherit java autotools update-alternatives
+
+ARM_INSTRUCTION_SET = "arm"
+
+# Configure options compatible with Cacao >= 0.99 only!
+EXTRA_OECONF = "\
+ ${@['','--enable-softfloat'][bb.data.getVar('TARGET_FPU',d,1) == 'soft']} \
+ --enable-debug \
+ --with-vm-zip=${datadir}/cacao/vm.zip \
+ --with-cacaoh=${STAGING_BINDIR_NATIVE}/cacaoh-${PV} \
+ --with-build-java-runtime-library-classes=${STAGING_DATADIR}/classpath/glibj.zip \
+ --with-java-runtime-library-classes=${datadir}/classpath/glibj.zip \
+ --with-java-runtime-library-libdir=${libdir_jni}:${libdir} \
+ --with-jni_md_h=${STAGING_INCDIR}/classpath \
+ --with-jni_h=${STAGING_INCDIR}/classpath \
+ "
+
+PACKAGES = "${PN} ${PN}-doc ${PN}-dbg"
+
+FILES_${PN} = "${bindir}/${PN} ${libdir}/lib*.so* ${datadir}/${PN}"
+FILES_${PN}-doc = "${datadir}/man"
+FILES_${PN}-dbg += "${bindir}/.debug ${libdir}/.debug/lib*.so*"
+
+ALTERNATIVE_NAME = "java"
+ALTERNATIVE_LINK = "${bindir}/${ALTERNATIVE_NAME}"
+ALTERNATIVE_PATH = "${bindir}/cacao"
+ALTERNATIVE_PRIORITY = "10"
diff --git a/recipes/cacao/cacao_0.99.3.bb b/recipes/cacao/cacao_0.99.3.bb
new file mode 100644
index 0000000000..b2f5801369
--- /dev/null
+++ b/recipes/cacao/cacao_0.99.3.bb
@@ -0,0 +1,10 @@
+require cacao.inc
+
+PR = "r5"
+
+SRC_URI = "http://www.complang.tuwien.ac.at/cacaojvm/download/cacao-${PV}/cacao-${PV}.tar.bz2 \
+ file://cacao-codegen-arm1.patch;patch=1 \
+ file://cacao-codegen-arm2.patch;patch=1 \
+ file://cacao-arm-race.patch;patch=1 \
+ file://vfp-compat.patch;patch=1 \
+ "
diff --git a/recipes/cacao/cacaoh-cldc-native_0.98.bb b/recipes/cacao/cacaoh-cldc-native_0.98.bb
new file mode 100644
index 0000000000..eac95b8ace
--- /dev/null
+++ b/recipes/cacao/cacaoh-cldc-native_0.98.bb
@@ -0,0 +1,9 @@
+require cacaoh-native.inc
+
+SRC_URI = "\
+ http://www.complang.tuwien.ac.at/cacaojvm/download/cacao-${PV}/cacao-${PV}.tar.bz2;md5sum=8b8907c8b925761c9410bcadb9705346 \
+ "
+
+do_stage() {
+ install -m 0755 src/cacaoh/.libs/cacaoh ${STAGING_BINDIR}/cacaoh-cldc-${PV}
+}
diff --git a/recipes/cacao/cacaoh-native.inc b/recipes/cacao/cacaoh-native.inc
new file mode 100644
index 0000000000..a44c5035c6
--- /dev/null
+++ b/recipes/cacao/cacaoh-native.inc
@@ -0,0 +1,26 @@
+DESCRIPTION = "Header generator for Cacao JVM - Needed for cross-compilation builds"
+HOMEPAGE = "http://www.cacaojvm.org/"
+LICENSE = "GPL"
+
+DEPENDS = "libtool-native zlib-native virtual/javac-native classpath-native"
+
+S = "${WORKDIR}/cacao-${PV}"
+
+inherit autotools native
+
+EXTRA_OECONF = " \
+ --with-java-runtime-library-classes=${STAGING_DATADIR}/classpath/glibj.zip \
+ --with-jni_md_h=${STAGING_INCDIR}/classpath \
+ --with-jni_h=${STAGING_INCDIR}/classpath \
+ "
+
+do_compile() {
+ # Compile the header generator only (and what is needed for it).
+ oe_runmake -C src/toolbox libtoolbox.la
+ oe_runmake -C src/vmcore libvmcore.la
+ oe_runmake -C src/cacaoh cacaoh
+}
+
+do_stage() {
+ install -m 0755 src/cacaoh/.libs/cacaoh ${STAGING_BINDIR}/cacaoh-${PV}
+}
diff --git a/recipes/cacao/cacaoh-native_0.99.3.bb b/recipes/cacao/cacaoh-native_0.99.3.bb
new file mode 100644
index 0000000000..a7f59baa7b
--- /dev/null
+++ b/recipes/cacao/cacaoh-native_0.99.3.bb
@@ -0,0 +1,5 @@
+require cacaoh-native.inc
+
+PR = "r1"
+
+SRC_URI = "http://www.complang.tuwien.ac.at/cacaojvm/download/cacao-${PV}/cacao-${PV}.tar.bz2"
diff --git a/recipes/cacao/files/arm_mmap.patch b/recipes/cacao/files/arm_mmap.patch
new file mode 100644
index 0000000000..e34c7b7802
--- /dev/null
+++ b/recipes/cacao/files/arm_mmap.patch
@@ -0,0 +1,21 @@
+--- cacao-0.98/src/vm/exceptions.c 2007/06/27 09:04:17 8146
++++ cacao-0.98/src/vm/exceptions.c 2007/07/02 14:07:24 8175
+@@ -92,6 +92,10 @@
+
+ bool exceptions_init(void)
+ {
++#if !(defined(__ARM__) && defined(__LINUX__))
++ /* On arm-linux the first memory page can't be mmap'ed, as it
++ contains the exception vectors. */
++
+ int pagesize;
+
+ /* mmap a memory page at address 0x0, so our hardware-exceptions
+@@ -100,6 +104,7 @@
+ pagesize = getpagesize();
+
+ (void) memory_mmap_anon(NULL, pagesize, PROT_NONE, MAP_PRIVATE | MAP_FIXED);
++#endif
+
+ /* check if we get into trouble with our hardware-exceptions */
+
diff --git a/recipes/cacao/files/cacao-0.98+svn-classpath_var.patch b/recipes/cacao/files/cacao-0.98+svn-classpath_var.patch
new file mode 100644
index 0000000000..255281d386
--- /dev/null
+++ b/recipes/cacao/files/cacao-0.98+svn-classpath_var.patch
@@ -0,0 +1,56 @@
+Index: cacao-trunk/src/vm/properties.c
+===================================================================
+--- cacao-trunk.orig/src/vm/properties.c 2007-08-31 13:28:53.000000000 +0200
++++ cacao-trunk/src/vm/properties.c 2007-09-03 00:36:14.000000000 +0200
+@@ -294,14 +294,14 @@
+ len =
+ strlen(CACAO_VM_ZIP) +
+ strlen(":") +
+- strlen(CLASSPATH_CLASSES) +
++ strlen(TARGET_CLASSPATH_CLASSES) +
+ strlen("0");
+
+ boot_class_path = MNEW(char, len);
+
+ strcpy(boot_class_path, CACAO_VM_ZIP);
+ strcat(boot_class_path, ":");
+- strcat(boot_class_path, CLASSPATH_CLASSES);
++ strcat(boot_class_path, TARGET_CLASSPATH_CLASSES);
+
+ # elif defined(WITH_CLASSPATH_SUN)
+
+Index: cacao-trunk/configure.ac
+===================================================================
+--- cacao-trunk.orig/configure.ac 2007-08-31 13:22:03.000000000 +0200
++++ cacao-trunk/configure.ac 2007-08-31 13:30:44.000000000 +0200
+@@ -851,6 +851,7 @@
+ AC_CHECK_WITH_CLASSPATH
+ AC_CHECK_WITH_CLASSPATH_PREFIX
+ AC_CHECK_WITH_CLASSPATH_CLASSES
++AC_CHECK_WITH_TARGET_CLASSPATH_CLASSES
+ AC_CHECK_WITH_CLASSPATH_LIBDIR
+ AC_CHECK_WITH_CLASSPATH_INCLUDEDIR
+
+Index: cacao-trunk/m4/classpath.m4
+===================================================================
+--- cacao-trunk.orig/m4/classpath.m4 2007-08-31 13:22:21.000000000 +0200
++++ cacao-trunk/m4/classpath.m4 2007-08-31 13:30:55.000000000 +0200
+@@ -98,6 +98,18 @@
+ AC_SUBST(CLASSPATH_CLASSES)
+ ])
+
++dnl where are Java core library classes installed on the target
++
++AC_DEFUN([AC_CHECK_WITH_TARGET_CLASSPATH_CLASSES],[
++AC_MSG_CHECKING(where Java core library classes are installed on the target)
++AC_ARG_WITH([target-classpath-classes],
++ [AS_HELP_STRING(--with-target-classpath-classes=<path>,path to Java core library classes (includes the name of the file and may be flat) [[default=/usr/local/classpath/share/classpath/glibj.zip]])],
++ [TARGET_CLASSPATH_CLASSES=${withval}],
++ [TARGET_CLASSPATH_CLASSES=${CLASSPATH_PREFIX}/share/classpath/glibj.zip])
++AC_MSG_RESULT(${TARGET_CLASSPATH_CLASSES})
++AC_DEFINE_UNQUOTED([TARGET_CLASSPATH_CLASSES], "${TARGET_CLASSPATH_CLASSES}", [Java core library classes on the target])
++AC_SUBST(TARGET_CLASSPATH_CLASSES)
++])
+
+ dnl where are Java core library native libraries installed
+
diff --git a/recipes/cacao/files/cacao-0.98-initial.patch b/recipes/cacao/files/cacao-0.98-initial.patch
new file mode 100644
index 0000000000..30b6d147e8
--- /dev/null
+++ b/recipes/cacao/files/cacao-0.98-initial.patch
@@ -0,0 +1,45 @@
+Index: cacao-0.98/configure.ac
+===================================================================
+--- cacao-0.98.orig/configure.ac 2007-12-19 22:07:55.000000000 +0100
++++ cacao-0.98/configure.ac 2007-12-19 22:08:02.000000000 +0100
+@@ -27,7 +27,7 @@
+ dnl Process this file with autoconf to produce a configure script.
+
+
+-AC_INIT(cacao, 0.98, cacao@cacaojvm.org)
++AC_INIT(cacao-initial, 0.98, cacao@cacaojvm.org)
+ AC_CONFIG_SRCDIR(src/cacao/cacao.c)
+ AC_CANONICAL_HOST
+ AC_PREREQ(2.59)
+Index: cacao-0.98/src/vm/vm.c
+===================================================================
+--- cacao-0.98.orig/src/vm/vm.c 2007-12-19 22:31:19.000000000 +0100
++++ cacao-0.98/src/vm/vm.c 2007-12-19 22:32:36.000000000 +0100
+@@ -623,7 +623,7 @@
+ #else
+ puts(" java.boot.class.path : "CLASSPATH_CLASSES"");
+ #endif
+- puts(" gnu.classpath.boot.library.path: "CLASSPATH_LIBDIR"/classpath\n");
++ puts(" gnu.classpath.boot.library.path: "CLASSPATH_LIBDIR"/classpath-initial\n");
+
+ puts("Runtime variables:\n");
+ printf(" maximum heap size : %d\n", opt_heapmaxsize);
+@@ -828,15 +828,15 @@
+
+ /* and finally set the path to GNU Classpath libraries */
+
+- len = strlen(cacao_prefix) + strlen("/lib/classpath") + strlen("0");
++ len = strlen(cacao_prefix) + strlen("/lib/classpath-initial") + strlen("0");
+
+ classpath_libdir = MNEW(char, len);
+ strcpy(classpath_libdir, cacao_prefix);
+- strcat(classpath_libdir, "/lib/classpath");
++ strcat(classpath_libdir, "/lib/classpath-initial");
+ #else
+ cacao_prefix = CACAO_PREFIX;
+ cacao_libjvm = CACAO_LIBDIR"/libjvm";
+- classpath_libdir = CLASSPATH_LIBDIR"/classpath";
++ classpath_libdir = CLASSPATH_LIBDIR"/classpath-initial";
+ #endif
+
+ /* set the bootclasspath */
diff --git a/recipes/cacao/files/cacao-arm-race.patch b/recipes/cacao/files/cacao-arm-race.patch
new file mode 100644
index 0000000000..a4b730df18
--- /dev/null
+++ b/recipes/cacao/files/cacao-arm-race.patch
@@ -0,0 +1,241 @@
+Index: cacao-0.99.3/src/vm/jit/arm/linux/md-os.c
+===================================================================
+--- cacao-0.99.3.orig/src/vm/jit/arm/linux/md-os.c 2008-07-07 13:36:19.000000000 +0200
++++ cacao-0.99.3/src/vm/jit/arm/linux/md-os.c 2008-09-24 17:15:23.191805889 +0200
+@@ -2,6 +2,7 @@
+
+ Copyright (C) 1996-2005, 2006, 2007, 2008
+ CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
++ Copyright (C) 2008 Theobroma Systems Ltd.
+
+ This file is part of CACAO.
+
+@@ -60,7 +61,7 @@
+ #include "vm/jit/executionstate.h"
+ #include "vm/jit/stacktrace.h"
+ #include "vm/jit/trap.h"
+-
++#include "vm/jit/patcher-common.h"
+
+ /* md_signal_handler_sigsegv ***************************************************
+
+@@ -126,56 +127,52 @@
+
+ void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p)
+ {
+- ucontext_t *_uc;
+- scontext_t *_sc;
+- u1 *pv;
+- u1 *sp;
+- u1 *ra;
+- u1 *xpc;
+- u4 mcode;
+- int type;
+- intptr_t val;
+- void *p;
+-
+- _uc = (ucontext_t*) _p;
+- _sc = &_uc->uc_mcontext;
+-
+- /* ATTENTION: glibc included messed up kernel headers we needed a
+- workaround for the ucontext structure. */
+-
+- pv = (u1 *) _sc->arm_ip;
+- sp = (u1 *) _sc->arm_sp;
+- ra = (u1 *) _sc->arm_lr; /* this is correct for leafs */
+- xpc = (u1 *) _sc->arm_pc;
+-
+- /* get exception-throwing instruction */
+-
+- mcode = *((u4 *) xpc);
+-
+- /* check for undefined instruction we use */
+-
+- if ((mcode & 0x0ff000f0) != 0x07f000f0) {
+- log_println("md_signal_handler_sigill: unknown illegal instruction: inst=%x", mcode);
+-#if defined(ENABLE_DISASSEMBLER)
+- DISASSINSTR(xpc);
+-#endif
+- vm_abort("Aborting...");
+- }
+-
+- type = (mcode >> 8) & 0x0fff;
+- val = *((s4 *) _sc + OFFSET(scontext_t, arm_r0)/4 + (mcode & 0x0f));
+-
+- /* Handle the trap. */
+-
+- p = trap_handle(type, val, pv, sp, ra, xpc, _p);
+-
+- /* set registers if we have an exception, continue execution
+- otherwise (this is needed for patchers to work) */
+-
+- if (p != NULL) {
+- _sc->arm_r10 = (uintptr_t) p;
+- _sc->arm_fp = (uintptr_t) xpc;
+- _sc->arm_pc = (uintptr_t) asm_handle_exception;
++ int type;
++ intptr_t val;
++ void *p;
++ ucontext_t* _uc = (ucontext_t*) _p;
++ scontext_t* _sc = &_uc->uc_mcontext;
++
++ /* ATTENTION: glibc included messed up kernel headers we needed a
++ workaround for the ucontext structure. */
++
++ void* pv = (void*) _sc->arm_ip;
++ void* sp = (void*) _sc->arm_sp;
++ void* ra = (void*) _sc->arm_lr; // The RA is correct for leaf methods.
++ void* xpc = (void*) _sc->arm_pc;
++
++ // Get the exception-throwing instruction.
++ uint32_t mcode = *((uint32_t*) xpc);
++
++ // Check if the trap instruction is valid.
++ // TODO Move this into patcher_handler.
++ if (patcher_is_valid_trap_instruction_at(xpc) == false) {
++ // Check if the PC has been patched during our way to this
++ // signal handler (see PR85).
++ // NOTE: ARM uses SIGILL for other traps too, but it's OK to
++ // do this check anyway because it will fail.
++ if (patcher_is_patched_at(xpc) == true)
++ return;
++
++ // We have a problem...
++ log_println("md_signal_handler_sigill: Unknown illegal instruction 0x%x at 0x%x", mcode, xpc);
++ #if defined(ENABLE_DISASSEMBLER)
++ (void) disassinstr(xpc);
++ #endif
++ vm_abort("Aborting...");
++ }
++
++ type = (mcode >> 8) & 0x0fff;
++ val = *((int32_t*) _sc + OFFSET(scontext_t, arm_r0)/4 + (mcode & 0x0f));
++
++ // Handle the trap.
++ p = trap_handle(type, val, pv, sp, ra, xpc, _p);
++
++ // Set registers if we have an exception, continue execution
++ // otherwise.
++ if (p != NULL) {
++ _sc->arm_r10 = (uintptr_t) p;
++ _sc->arm_fp = (uintptr_t) xpc;
+ }
+ }
+
+Index: cacao-0.99.3/src/vm/jit/arm/patcher.c
+===================================================================
+--- cacao-0.99.3.orig/src/vm/jit/arm/patcher.c 2008-04-27 23:44:08.000000000 +0200
++++ cacao-0.99.3/src/vm/jit/arm/patcher.c 2008-09-24 17:05:17.003795314 +0200
+@@ -2,6 +2,7 @@
+
+ Copyright (C) 1996-2005, 2006, 2007, 2008
+ CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
++ Copyright (C) 2008 Theobroma Systems Ltd.
+
+ This file is part of CACAO.
+
+@@ -76,6 +77,25 @@
+ PATCH_BACK_ORIGINAL_MCODE;
+ }
+
++
++/**
++ * Check if the trap instruction at the given PC is valid.
++ *
++ * @param pc Program counter.
++ *
++ * @return true if valid, false otherwise.
++ */
++bool patcher_is_valid_trap_instruction_at(void* pc)
++{
++ uint32_t mcode = *((uint32_t*) pc);
++
++ // Check for the undefined instruction we use.
++ if ((mcode & 0x0ff000f0) != 0x07f000f0) {
++ return false;
++ }
++
++ return true;
++}
+
+ /* patcher_get_putstatic *******************************************************
+
+Index: cacao-0.99.3/src/vm/jit/patcher-common.c
+===================================================================
+--- cacao-0.99.3.orig/src/vm/jit/patcher-common.c 2008-04-28 21:52:41.000000000 +0200
++++ cacao-0.99.3/src/vm/jit/patcher-common.c 2008-09-24 17:05:17.047796037 +0200
+@@ -2,6 +2,7 @@
+
+ Copyright (C) 2007, 2008
+ CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
++ Copyright (C) 2008 Theobroma Systems Ltd.
+
+ This file is part of CACAO.
+
+@@ -254,6 +255,49 @@
+ }
+
+
++/**
++ * Check if the patcher is already patched. This is done by comparing
++ * the machine instruction.
++ *
++ * @param pr Patcher structure.
++ *
++ * @return true if patched, false otherwise.
++ */
++bool patcher_is_patched(patchref_t* pr)
++{
++ // Validate the instruction at the patching position is the same
++ // instruction as the patcher structure contains.
++ uint32_t mcode = *((uint32_t*) pr->mpc);
++
++ if (mcode != pr->mcode) {
++ // The code differs.
++ return false;
++ }
++
++ return true;
++}
++
++
++/**
++ *
++ */
++bool patcher_is_patched_at(void* pc)
++{
++ codeinfo* code = code_find_codeinfo_for_pc(pc);
++
++ // Get the patcher for the given PC.
++ patchref_t* pr = patcher_list_find(code, pc);
++
++ if (pr == NULL) {
++ // The given PC is not a patcher position.
++ return false;
++ }
++
++ // Validate the instruction.
++ return patcher_is_patched(pr);
++}
++
++
+ /* patcher_handler *************************************************************
+
+ Handles the request to patch JIT code at the given patching
+Index: cacao-0.99.3/src/vm/jit/patcher-common.h
+===================================================================
+--- cacao-0.99.3.orig/src/vm/jit/patcher-common.h 2008-04-27 23:44:08.000000000 +0200
++++ cacao-0.99.3/src/vm/jit/patcher-common.h 2008-09-24 17:05:17.115800331 +0200
+@@ -73,6 +73,12 @@
+
+ void patcher_resolve(jitdata* jd);
+
++bool patcher_is_patched(patchref_t* pr);
++bool patcher_is_patched_at(void* pc);
++
++// MD function.
++bool patcher_is_valid_trap_instruction_at(void* pc);
++
+ java_handle_t *patcher_handler(u1 *pc);
+
+
diff --git a/recipes/cacao/files/cacao-codegen-arm1.patch b/recipes/cacao/files/cacao-codegen-arm1.patch
new file mode 100644
index 0000000000..b4d9db8eb1
--- /dev/null
+++ b/recipes/cacao/files/cacao-codegen-arm1.patch
@@ -0,0 +1,49 @@
+
+# HG changeset patch
+# User Christian Thalinger <twisti@complang.tuwien.ac.at>
+# Date 1221466650 -7200
+# Node ID d88bf99453b644bd2cc5c0dc5f8038f3151d897a
+# Parent b567fffd0ff7b8330b172a3f12325c731bee67bb
+* src/vm/jit/arm/codegen.h [__VFP_FP__] (M_CVTFI, M_CVTDI): Use signed
+conversion functions.
+
+--- a/src/vm/jit/arm/codegen.h Sat Sep 13 15:00:00 2008 +0200
++++ b/src/vm/jit/arm/codegen.h Mon Sep 15 10:17:30 2008 +0200
+@@ -643,6 +643,7 @@
+ #if !defined(ENABLE_SOFTFLOAT)
+
+ #if defined(__VFP_FP__)
++
+ #define M_FADD(a,b,d) M_CPDP(UNCOND,0,1,1,0,10,0,0,0,d,a,b)/* d = a + b */
+ #define M_FSUB(a,b,d) M_CPDP(UNCOND,0,1,1,1,10,0,0,0,d,a,b)/* d = a - b */
+ #define M_FMUL(a,b,d) M_CPDP(UNCOND,0,1,0,0,10,0,0,0,d,a,b)/* d = a * b */
+@@ -664,8 +665,8 @@
+ #define M_CVTFD(a,d) M_CPDP(UNCOND,1,1,1,1,10,0,1,0,d,0x7,a)
+ #define M_CVTIF(a,d) M_CPDP(UNCOND,1,1,1,1,10,0,1,0,d,0x8,a)
+ #define M_CVTID(a,d) M_CPDP(UNCOND,1,1,1,1,11,0,1,0,d,0x8,a)
+-#define M_CVTFI(a,d) M_CPDP(UNCOND,1,1,1,1,10,0,1,0,d,0xc,a)
+-#define M_CVTDI(a,d) M_CPDP(UNCOND,1,1,1,1,11,0,1,0,d,0xc,a)
++#define M_CVTFI(a,d) M_CPDP(UNCOND,1,1,1,1,10,0,1,0,d,0xd,a) // ftosis
++#define M_CVTDI(a,d) M_CPDP(UNCOND,1,1,1,1,11,0,1,0,d,0xd,a) // ftosid
+
+ #define M_FMSTAT M_CPRT(UNCOND,0x07,1,10,0,0x1,0xf)
+
+@@ -675,7 +676,9 @@
+ #define M_FMRDL(Fa,b) M_CPRT(UNCOND,0x00,1,11,0,Fa,b)
+ #define M_FMDHR(a,Fb) M_CPRT(UNCOND,0x01,0,11,0,Fb,a)
+ #define M_FMRDH(Fa,b) M_CPRT(UNCOND,0x01,1,11,0,Fa,b)
++
+ #else
++
+ #define M_FADD(a,b,d) M_CPDOS(UNCOND,0x00,0,d,a,b) /* d = a + b */
+ #define M_FSUB(a,b,d) M_CPDOS(UNCOND,0x02,0,d,a,b) /* d = a - b */
+ #define M_FMUL(a,b,d) M_CPDOS(UNCOND,0x01,0,d,a,b) /* d = a * b */
+@@ -701,6 +704,7 @@
+ #define M_CVTID(a,d) M_CPRTD(UNCOND,0,a,d,0) /* d = (float) a */
+ #define M_CVTFI(a,d) M_CPRTI(UNCOND,1,d,0,a) /* d = (int) a */
+ #define M_CVTDI(a,d) M_CPRTI(UNCOND,1,d,0,a) /* d = (int) a */
++
+ #endif
+
+
+
diff --git a/recipes/cacao/files/cacao-codegen-arm2.patch b/recipes/cacao/files/cacao-codegen-arm2.patch
new file mode 100644
index 0000000000..710f284345
--- /dev/null
+++ b/recipes/cacao/files/cacao-codegen-arm2.patch
@@ -0,0 +1,66 @@
+
+# HG changeset patch
+# User Christian Thalinger <twisti@complang.tuwien.ac.at>
+# Date 1221467463 -7200
+# Node ID a67fe1cb2b81b7cbfc9d824f17b440e50c7697ef
+# Parent d88bf99453b644bd2cc5c0dc5f8038f3151d897a
+* src/vm/jit/arm/codegen.c (codegen_emit) [__VFP_FP__]: Implemented
+I2F, I2D, F2I, and D2I correctly.
+
+--- a/src/vm/jit/arm/codegen.c Mon Sep 15 10:17:30 2008 +0200
++++ b/src/vm/jit/arm/codegen.c Mon Sep 15 10:31:03 2008 +0200
+@@ -1013,7 +1013,12 @@
+
+ s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+ d = codegen_reg_of_dst(jd, iptr, REG_FTMP1);
++#if defined(__VFP_FP__)
++ M_FMSR(s1, d);
++ M_CVTIF(d, d);
++#else
+ M_CVTIF(s1, d);
++#endif
+ emit_store_dst(jd, iptr, d);
+ break;
+
+@@ -1021,7 +1026,12 @@
+
+ s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+ d = codegen_reg_of_dst(jd, iptr, REG_FTMP1);
++#if defined(__VFP_FP__)
++ M_FMSR(s1, d);
++ M_CVTID(d, d);
++#else
+ M_CVTID(s1, d);
++#endif
+ emit_store_dst(jd, iptr, d);
+ break;
+
+@@ -1029,9 +1039,12 @@
+
+ s1 = emit_load_s1(jd, iptr, REG_FTMP1);
+ d = codegen_reg_of_dst(jd, iptr, REG_ITMP1);
++#if defined(__VFP_FP__)
++ M_CVTFI(s1, REG_FTMP2);
++ M_FMRS(REG_FTMP2, d);
++#else
+ /* this uses round towards zero, as Java likes it */
+ M_CVTFI(s1, d);
+-#if !defined(__VFP_FP__)
+ /* this checks for NaN; to return zero as Java likes it */
+ M_FCMP(s1, 0x8);
+ M_MOVVS_IMM(0, d);
+@@ -1043,9 +1056,12 @@
+
+ s1 = emit_load_s1(jd, iptr, REG_FTMP1);
+ d = codegen_reg_of_dst(jd, iptr, REG_ITMP1);
++#if defined(__VFP_FP__)
++ M_CVTDI(s1, REG_FTMP2);
++ M_FMRS(REG_FTMP2, d);
++#else
+ /* this uses round towards zero, as Java likes it */
+ M_CVTDI(s1, d);
+-#if !defined(__VFP_FP__)
+ /* this checks for NaN; to return zero as Java likes it */
+ M_DCMP(s1, 0x8);
+ M_MOVVS_IMM(0, d);
+
diff --git a/recipes/cacao/files/classpath_var.patch b/recipes/cacao/files/classpath_var.patch
new file mode 100644
index 0000000000..a2a69f9d1c
--- /dev/null
+++ b/recipes/cacao/files/classpath_var.patch
@@ -0,0 +1,66 @@
+Index: cacao-0.98/configure.ac
+===================================================================
+--- cacao-0.98.orig/configure.ac 2007-06-06 11:24:23.000000000 +0200
++++ cacao-0.98/configure.ac 2007-07-18 23:26:43.000000000 +0200
+@@ -842,6 +842,7 @@
+ AC_CHECK_WITH_CLASSPATH
+ AC_CHECK_WITH_CLASSPATH_PREFIX
+ AC_CHECK_WITH_CLASSPATH_CLASSES
++AC_CHECK_WITH_TARGET_CLASSPATH_CLASSES
+ AC_CHECK_WITH_CLASSPATH_LIBDIR
+ AC_CHECK_WITH_CLASSPATH_INCLUDEDIR
+
+Index: cacao-0.98/src/vm/vm.c
+===================================================================
+--- cacao-0.98.orig/src/vm/vm.c 2007-06-05 09:44:38.000000000 +0200
++++ cacao-0.98/src/vm/vm.c 2007-07-18 23:26:43.000000000 +0200
+@@ -621,7 +621,7 @@
+ #if defined(WITH_CLASSPATH_GNU)
+ puts(" java.boot.class.path : "CACAO_VM_ZIP":"CLASSPATH_CLASSES"");
+ #else
+- puts(" java.boot.class.path : "CLASSPATH_CLASSES"");
++ puts(" java.boot.class.path : "TARGET_CLASSPATH_CLASSES"");
+ #endif
+ puts(" gnu.classpath.boot.library.path: "CLASSPATH_LIBDIR"/classpath\n");
+
+@@ -873,7 +873,7 @@
+ strlen(CACAO_VM_ZIP) +
+ strlen(":") +
+ # endif
+- strlen(CLASSPATH_CLASSES) +
++ strlen(TARGET_CLASSPATH_CLASSES) +
+ strlen("0");
+
+ _Jv_bootclasspath = MNEW(char, len);
+@@ -881,7 +881,7 @@
+ strcat(_Jv_bootclasspath, CACAO_VM_ZIP);
+ strcat(_Jv_bootclasspath, ":");
+ # endif
+- strcat(_Jv_bootclasspath, CLASSPATH_CLASSES);
++ strcat(_Jv_bootclasspath, TARGET_CLASSPATH_CLASSES);
+ #endif
+ }
+
+Index: cacao-0.98/m4/classpath.m4
+===================================================================
+--- cacao-0.98.orig/m4/classpath.m4 2007-04-23 22:06:07.000000000 +0200
++++ cacao-0.98/m4/classpath.m4 2007-07-18 23:38:06.000000000 +0200
+@@ -82,6 +82,18 @@
+ AC_SUBST(CLASSPATH_CLASSES)
+ ])
+
++dnl where are Java core library classes installed on the target
++
++AC_DEFUN([AC_CHECK_WITH_TARGET_CLASSPATH_CLASSES],[
++AC_MSG_CHECKING(where Java core library classes are installed on the target)
++AC_ARG_WITH([target-classpath-classes],
++ [AS_HELP_STRING(--with-target-classpath-classes=<path>,path to Java core library classes (includes the name of the file and may be flat) [[default=/usr/local/classpath/share/classpath/glibj.zip]])],
++ [TARGET_CLASSPATH_CLASSES=${withval}],
++ [TARGET_CLASSPATH_CLASSES=${CLASSPATH_PREFIX}/share/classpath/glibj.zip])
++AC_MSG_RESULT(${TARGET_CLASSPATH_CLASSES})
++AC_DEFINE_UNQUOTED([TARGET_CLASSPATH_CLASSES], "${TARGET_CLASSPATH_CLASSES}", [Java core library classes on the target])
++AC_SUBST(TARGET_CLASSPATH_CLASSES)
++])
+
+ dnl where are Java core library native libraries installed
+
diff --git a/recipes/cacao/files/libmath.patch b/recipes/cacao/files/libmath.patch
new file mode 100644
index 0000000000..f8a4e837e2
--- /dev/null
+++ b/recipes/cacao/files/libmath.patch
@@ -0,0 +1,53 @@
+Index: cacao-0.98/configure.ac
+===================================================================
+--- cacao-0.98.orig/configure.ac 2007-07-21 12:11:47.000000000 +0200
++++ cacao-0.98/configure.ac 2007-07-21 13:36:40.000000000 +0200
+@@ -234,6 +234,48 @@
+ AC_EGREP_HEADER(u_int32_t, sys/types.h, AC_DEFINE(HAVE_BSD_INT32_DEFINED, 1, [Define to 1 if you have BSD u_int32_t]))
+ AC_EGREP_HEADER(u_int32_t, sys/config.h, AC_DEFINE(HAVE_BSD_INT32_DEFINED, 1, [Define to 1 if you have BSD u_int32_t]))
+
++dnl The idea of this solutions comes from bochs-project configure.in
++dnl
++dnl Add the -lm library if math functions cannot be used without it.
++dnl This check is important on cygwin because of the bizarre way that they
++dnl have organized functions into libraries. On cygwin, both libc.a and
++dnl libm.a are symbolic links to a single lib libcygwin.a. This means that
++dnl 1) linking with -lm is not necessary, and
++dnl 2) linking with -lm is dangerous if the order of libraries is wrong
++dnl In particular, if you compile any program with -mno-cygwin and link with
++dnl -lm, it will crash instantly when it is run. This happens because the
++dnl linker incorrectly links the Cygwin libm.a (==libcygwin.a), which replaces
++dnl the ___main function instead of allowing it to be defined by
++dnl /usr/lib/mingw/libmingw32.a as it should be.
++dnl
++dnl On MacOS X, this test will find that -lm is unnecessary and leave it out.
++dnl
++dnl With uClibc and without libjvm cacao needs to be linked with -lm because of
++dnl the function scalbn
++dnl
++dnl Just check this math functions. If it is found without
++dnl -lm, then we must not need -lm.
++have_scalbn=0
++AC_CHECK_FUNCS(scalbn, have_scalbn=1)
++AC_MSG_CHECKING(if math functions link without -lm)
++if test "$have_scalbn" = 1; then
++ AC_MSG_RESULT(yes)
++else
++ AC_MSG_RESULT(no)
++ LIBS="$LIBS -lm"
++ # use different functions to bypass configure caching
++ have_scalbl=0
++ AC_CHECK_FUNCS(scalbl, have_scalbl=1)
++ AC_MSG_CHECKING(if math functions link with -lm)
++ if test "$have_scalbl" = 1; then
++ AC_MSG_RESULT(yes)
++ else
++ AC_MSG_RESULT(no)
++ # not sure we should warn the user, crash, etc.
++ # expect link failure
++ fi
++fi
++
+ dnl Checks for typedefs, structures, and compiler characteristics.
+ AC_C_CONST
+ AC_C_INLINE
diff --git a/recipes/cacao/files/midpath.patch b/recipes/cacao/files/midpath.patch
new file mode 100644
index 0000000000..b905f774af
--- /dev/null
+++ b/recipes/cacao/files/midpath.patch
@@ -0,0 +1,372 @@
+Index: cacao-0.98/src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c
+===================================================================
+--- cacao-0.98.orig/src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c 2007-05-16 10:06:15.000000000 +0200
++++ cacao-0.98/src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c 2007-07-22 00:15:55.000000000 +0200
+@@ -26,25 +26,53 @@
+
+ */
+
++#include <sys/stat.h>
++#include <stdlib.h>
+
+ #include "config.h"
+-#include "vm/types.h"
++
++#include "arch.h"
++#include "mm/memory.h"
+
+ #include "native/jni.h"
+ #include "native/native.h"
+
+ #include "native/include/java_lang_Object.h"
+ #include "native/include/java_lang_String.h"
+-
++#include "native/include/java_lang_Integer.h"
+ #include "native/include/com_sun_cldc_io_ResourceInputStream.h"
++#include "native/include/com_sun_cldchi_jvm_FileDescriptor.h"
+
++#include "vm/types.h"
++#include "vm/builtin.h"
+ #include "vm/vm.h" /* REMOVE ME: temporarily */
++#include "vm/exceptions.h"
++#include "vm/initialize.h"
++#include "vm/stringlocal.h"
++#include "vm/properties.h"
++
++#include "vmcore/class.h"
++#include "vmcore/classcache.h"
++#include "vmcore/linker.h"
++#include "vmcore/loader.h"
++#include "vmcore/options.h"
++#include "vmcore/statistics.h"
++#include "vmcore/suck.h"
++#include "vmcore/zip.h"
++
++#include "toolbox/list.h"
++#include "toolbox/logging.h"
++#include "toolbox/util.h"
+
+
+ /* native methods implemented by this file ************************************/
+
+ static JNINativeMethod methods[] = {
+ { "open", "(Ljava/lang/String;)Ljava/lang/Object;", (void *) (ptrint) &Java_com_sun_cldc_io_ResourceInputStream_open },
++ { "bytesRemain", "(Ljava/lang/Object;)I", (void *) (ptrint) &Java_com_sun_cldc_io_ResourceInputStream_bytesRemain },
++ { "readByte", "(Ljava/lang/Object;)I", (void *) (ptrint) &Java_com_sun_cldc_io_ResourceInputStream_readByte },
++ { "readBytes", "(Ljava/lang/Object;[BII)I", (void *) (ptrint) &Java_com_sun_cldc_io_ResourceInputStream_readBytes },
++ { "clone", "(Ljava/lang/Object;)Ljava/lang/Object;", (void *) (ptrint) &Java_com_sun_cldc_io_ResourceInputStream_clone },
+ };
+
+ /* _Jv_com_sun_cldc_io_ResourceInputStream_init ********************************
+@@ -68,13 +96,209 @@
+ * Method: open
+ * Signature: (Ljava/lang/String;)Ljava/lang/Object;
+ */
+-JNIEXPORT java_lang_Object* JNICALL Java_com_sun_cldc_io_ResourceInputStream_open(JNIEnv *env, jclass clazz, java_lang_String *name)
++JNIEXPORT struct java_lang_Object* JNICALL Java_com_sun_cldc_io_ResourceInputStream_open(JNIEnv *env, jclass clazz, java_lang_String *name)
+ {
+- vm_abort("Java_com_sun_cldc_io_ResourceInputStream_open: IMPLEMENT ME!");
++
++ list_classpath_entry *lce;
++ char *filename;
++ s4 filenamelen;
++ char *path;
++ FILE *classfile;
++ /*struct stat statBuffer;
++ int bufferSize = -1;*/
++ utf *uname;
++ /*java_lang_Integer *fhandler;*/
++ com_sun_cldchi_jvm_FileDescriptor *fileDescriptor;
++ classinfo *ci;
++
++
++ /* get the classname as char string (do it here for the warning at
++ the end of the function) */
++
++ uname = javastring_toutf((java_objectheader *)name, false);
++ filenamelen = utf_bytes(uname) + strlen("0");
++ filename = MNEW(char, filenamelen);
++ utf_copy(filename, uname);
++ classfile = NULL;
++
++
++ /* walk through all classpath entries */
++
++ for (lce = list_first(list_classpath_entries); lce != NULL;
++ lce = list_next(list_classpath_entries, lce)) {
++
++ path = MNEW(char, lce->pathlen + filenamelen);
++ strcpy(path, lce->path);
++ strcat(path, filename);
++
++ classfile = fopen(path, "r");
++
++ MFREE(path, char, lce->pathlen + filenamelen);
++
++ if (classfile) { /* file exists */
++ break;
++ }
++ }
++
++ MFREE(filename, char, filenamelen);
++
++ if (classfile) {
++ ci = load_class_bootstrap(utf_new_char("com/sun/cldchi/jvm/FileDescriptor"));
++ fileDescriptor = (com_sun_cldchi_jvm_FileDescriptor *) native_new_and_init(ci);
++ fileDescriptor->handle = (int) classfile;
++ fileDescriptor->valid = (int) 0;
++ return (java_lang_Object*) fileDescriptor;
++ } else {
++ return NULL;
++ }
++
++}
++
++
++/*
++ * Class: com_sun_cldc_io_ResourceInputStream
++ * Method: bytesRemain
++ * Signature: (Ljava/lang/Object;)I
++ */
++JNIEXPORT s4 JNICALL Java_com_sun_cldc_io_ResourceInputStream_bytesRemain(JNIEnv *env, jclass clazz, struct java_lang_Object* jobj) {
++
++ com_sun_cldchi_jvm_FileDescriptor *fileDescriptor;
++ struct stat statBuffer;
++ FILE *file;
++ int fd;
++ int position;
++ int hposition;
++
++ fileDescriptor = (com_sun_cldchi_jvm_FileDescriptor *) jobj;
++ file = (FILE *)fileDescriptor->handle;
++
++ /* Change access position if needed */
++ hposition = fileDescriptor->valid;
++ position = ftell(file);
++ if (position != hposition) {
++ fseek(file, hposition, SEEK_SET);
++ }
++
++ fd = fileno(file);
++ if (fstat(fd, &statBuffer) != -1) {
++ return (statBuffer.st_size - hposition);
++ } else {
++ /* TODO Throw an IOException */
++ return 0;
++ }
+
+- return NULL;
+ }
+
++/*
++ * Class: com_sun_cldc_io_ResourceInputStream
++ * Method: readByte
++ * Signature: (Ljava/lang/Object;)I
++ */
++JNIEXPORT s4 JNICALL Java_com_sun_cldc_io_ResourceInputStream_readByte(JNIEnv *env, jclass clazz, struct java_lang_Object* jobj) {
++
++ com_sun_cldchi_jvm_FileDescriptor *fileDescriptor;
++ int readBytes = -1;
++ char byte;
++ FILE * file;
++ int position;
++ int hposition;
++
++ fileDescriptor = (com_sun_cldchi_jvm_FileDescriptor *) jobj;
++ file = (FILE *)fileDescriptor->handle;
++
++ /* Change access position if needed */
++ hposition = fileDescriptor->valid;
++ position = ftell(file);
++ if (position != hposition) {
++ fseek(file, hposition, SEEK_SET);
++ }
++
++ readBytes = fread(&byte, 1, 1, file);
++
++ /* Check if EOF or an error occurred */
++ if (readBytes != 1) {
++ if (feof(file)) {
++ return -1;
++ } else if (ferror(file)) {
++ /* TODO: throw an IOException */
++ }
++ }
++
++ /* Update access position */
++ fileDescriptor->valid = ftell(file);
++
++ return (byte & 0xFF);
++
++}
++
++/*
++ * Class: com_sun_cldc_io_ResourceInputStream
++ * Method: readBytes
++ * Signature: (Ljava/lang/Object;[BII)I
++ */
++JNIEXPORT s4 JNICALL Java_com_sun_cldc_io_ResourceInputStream_readBytes(JNIEnv *env, jclass clazz, struct java_lang_Object* jobj, java_bytearray* byteArray, s4 off, s4 len) {
++
++ com_sun_cldchi_jvm_FileDescriptor *fileDescriptor;
++ int readBytes = -1;
++ FILE * file;
++ int position;
++ int hposition;
++ void *buf;
++
++ /* get pointer to the buffer */
++ buf = &(byteArray->data[off]);
++
++ fileDescriptor = (com_sun_cldchi_jvm_FileDescriptor *) jobj;
++ file = (FILE *)fileDescriptor->handle;
++
++ /* Change access position if needed */
++ hposition = fileDescriptor->valid;
++ position = ftell(file);
++ if (position != hposition) {
++ fseek(file, hposition, SEEK_SET);
++ }
++
++ readBytes = fread(buf, 1, len, file);
++
++ /* Check if EOF or an error occurred */
++ if (readBytes != len) {
++ if ((readBytes == 0) && feof(file)) {
++ return -1;
++ } else if (ferror(file)) {
++ /* TODO: throw an IOException */
++ }
++ }
++
++ /* Update access position */
++ fileDescriptor->valid = ftell(file);
++
++ return readBytes;
++}
++
++/*
++ * Class: com_sun_cldc_io_ResourceInputStream
++ * Method: clone
++ * Signature: (Ljava/lang/Object;)Ljava/lang/Object;
++ */
++JNIEXPORT struct java_lang_Object* JNICALL Java_com_sun_cldc_io_ResourceInputStream_clone(JNIEnv *env, jclass clazz, struct java_lang_Object* jobj) {
++
++ classinfo *ci;
++ com_sun_cldchi_jvm_FileDescriptor *srcFileDescriptor;
++ com_sun_cldchi_jvm_FileDescriptor *dstFileDescriptor;
++
++ srcFileDescriptor = (com_sun_cldchi_jvm_FileDescriptor *) jobj;
++
++ ci = load_class_bootstrap(utf_new_char("com/sun/cldchi/jvm/FileDescriptor"));
++ dstFileDescriptor = (com_sun_cldchi_jvm_FileDescriptor *) native_new_and_init(ci);
++ dstFileDescriptor->handle = srcFileDescriptor->handle;
++ dstFileDescriptor->valid = srcFileDescriptor->valid;
++
++ return (java_lang_Object*) dstFileDescriptor;
++
++}
++
++
++
+
+ /*
+ * These are local overrides for various environment variables in Emacs.
+Index: cacao-0.98/src/native/vm/cldc1.1/Makefile.am
+===================================================================
+--- cacao-0.98.orig/src/native/vm/cldc1.1/Makefile.am 2007-04-02 13:23:24.000000000 +0200
++++ cacao-0.98/src/native/vm/cldc1.1/Makefile.am 2007-07-22 00:15:55.000000000 +0200
+@@ -38,6 +38,7 @@
+ com_sun_cldc_io_j2me_socket_Protocol.c \
+ com_sun_cldchi_io_ConsoleOutputStream.c \
+ com_sun_cldchi_jvm_JVM.c \
++ com_sun_cldchi_jvm_FileDescriptor.c \
+ java_lang_Class.c \
+ java_lang_Double.c \
+ java_lang_Float.c \
+Index: cacao-0.98/src/native/include/Makefile.am
+===================================================================
+--- cacao-0.98.orig/src/native/include/Makefile.am 2007-05-23 20:15:07.000000000 +0200
++++ cacao-0.98/src/native/include/Makefile.am 2007-07-22 00:15:55.000000000 +0200
+@@ -74,6 +74,7 @@
+ com_sun_cldc_io_j2me_socket_Protocol.h \
+ com_sun_cldchi_io_ConsoleOutputStream.h \
+ com_sun_cldchi_jvm_JVM.h \
++ com_sun_cldchi_jvm_FileDescriptor.h \
+ java_lang_Math.h \
+ java_lang_Runtime.h \
+ java_lang_System.h
+Index: cacao-0.98/src/native/vm/cldc1.1/com_sun_cldchi_jvm_FileDescriptor.c
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ cacao-0.98/src/native/vm/cldc1.1/com_sun_cldchi_jvm_FileDescriptor.c 2007-07-22 00:18:01.000000000 +0200
+@@ -0,0 +1,70 @@
++/* src/native/vm/cldc1.1/com_sun_cldchi_jvm_FileDescriptor.c
++
++ Copyright (C) 2006, 2007 R. Grafl, A. Krall, C. Kruegel, C. Oates,
++ R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
++ C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
++ Institut f. Computersprachen - TU Wien
++
++ This file is part of CACAO.
++
++ This program is free software; you can redistribute it and/or
++ modify it under the terms of the GNU General Public License as
++ published by the Free Software Foundation; either version 2, or (at
++ your option) any later version.
++
++ This program is distributed in the hope that it will be useful, but
++ WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ General Public License for more details.
++
++ You should have received a copy of the GNU General Public License
++ along with this program; if not, write to the Free Software
++ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
++ 02110-1301, USA.
++
++ $Id: java_lang_VMRuntime.c 5900 2006-11-04 17:30:44Z michi $
++
++*/
++
++#include "config.h"
++
++#include <stdio.h>
++
++#include "vm/types.h"
++
++#include "native/jni.h"
++#include "native/native.h"
++
++#include "native/include/com_sun_cldchi_jvm_FileDescriptor.h"
++
++/* native methods implemented by this file ************************************/
++
++static JNINativeMethod methods[] = {
++ { "finalize", "()V", (void *) (ptrint) &Java_com_sun_cldchi_jvm_FileDescriptor_finalize },
++};
++
++/* _Jv_com_sun_cldchi_jvm_FileDescriptor_init ******************************
++
++ Register native functions.
++
++*******************************************************************************/
++
++void _Jv_com_sun_cldchi_jvm_FileDescriptor_init(void)
++{
++ utf *u;
++
++ u = utf_new_char("com/sun/cldchi/jvm/FileDescriptor");
++
++ native_method_register(u, methods, NATIVE_METHODS_COUNT);
++}
++
++/*
++ * Class: com/sun/cldchi/jvm/FileDescriptor
++ * Method: finalize
++ * Signature: ()V
++ */
++JNIEXPORT void JNICALL Java_com_sun_cldchi_jvm_FileDescriptor_finalize(JNIEnv *env, struct com_sun_cldchi_jvm_FileDescriptor* this) {
++ /* printf("close\n"); */
++ fclose((FILE *)this->handle);
++
++}
diff --git a/recipes/cacao/files/offset.h_arm.patch b/recipes/cacao/files/offset.h_arm.patch
new file mode 100644
index 0000000000..7011527540
--- /dev/null
+++ b/recipes/cacao/files/offset.h_arm.patch
@@ -0,0 +1,35 @@
+Index: cacao-0.98/src/vm/jit/arm/offsets.h
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ cacao-0.98/src/vm/jit/arm/offsets.h 2007-07-17 23:35:56.000000000 +0200
+@@ -0,0 +1,30 @@
++/* This file is machine generated, don't edit it! */
++
++/* define some sizeof()'s */
++
++#define sizevmarg 16
++
++
++/* define some offsets */
++
++#define offobjvftbl 0
++
++
++/* vftbl_t */
++
++#define offbaseval 20
++#define offdiffval 24
++
++
++/* classinfo */
++
++#define offclassvftbl 124
++
++
++#define offvmargtype 0
++#define offvmargdata 8
++
++
++#define offcast_super_baseval 0
++#define offcast_super_diffval 4
++#define offcast_sub_baseval 8
diff --git a/recipes/cacao/files/offsets_make.patch b/recipes/cacao/files/offsets_make.patch
new file mode 100644
index 0000000000..d6f9dbef3a
--- /dev/null
+++ b/recipes/cacao/files/offsets_make.patch
@@ -0,0 +1,25 @@
+Index: cacao-0.98/src/vm/jit/arm/Makefile.am
+===================================================================
+--- cacao-0.98.orig/src/vm/jit/arm/Makefile.am 2007-04-02 13:23:22.000000000 +0200
++++ cacao-0.98/src/vm/jit/arm/Makefile.am 2007-07-17 23:26:33.000000000 +0200
+@@ -40,10 +40,6 @@
+ AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_builddir) -I$(top_builddir)/src
+ AM_CCASFLAGS = $(AM_CPPFLAGS)
+
+-BUILT_SOURCES = offsets.h
+-
+-CLEANFILES = offsets.h
+-
+ noinst_HEADERS = \
+ arch.h \
+ machine-instr.h \
+@@ -72,9 +68,6 @@
+
+ $(srcdir)/asmpart.S: $(top_builddir)/config.h offsets.h
+
+-offsets.h: $(top_builddir)/src/vm/jit/tools/genoffsets $(top_builddir)/config.h
+- $(top_builddir)/src/vm/jit/tools/genoffsets > offsets.h
+-
+
+ ## Local variables:
+ ## mode: Makefile
diff --git a/recipes/cacao/files/vfp-compat.patch b/recipes/cacao/files/vfp-compat.patch
new file mode 100644
index 0000000000..9feba6344e
--- /dev/null
+++ b/recipes/cacao/files/vfp-compat.patch
@@ -0,0 +1,37 @@
+Index: cacao-0.99.3/src/vm/jit/arm/codegen.c
+===================================================================
+--- cacao-0.99.3.orig/src/vm/jit/arm/codegen.c 2008-10-01 16:23:21.439856241 +0200
++++ cacao-0.99.3/src/vm/jit/arm/codegen.c 2008-10-01 16:41:24.278841537 +0200
+@@ -2353,10 +2353,12 @@
+
+ d = md->returntype.type;
+
+-#if !defined(__SOFTFP__)
++#if !defined(__SOFTFP__) && !defined(__VFP_FP__)
+ /* TODO: this is only a hack, since we use R0/R1 for float
+ return! this depends on gcc; it is independent from
+- our ENABLE_SOFTFLOAT define */
++ our ENABLE_SOFTFLOAT define
++ It is only needed for -mfpu=fpa -mfloat-abi=hard!
++ */
+ if (iptr->opc == ICMD_BUILTIN && d != TYPE_VOID && IS_FLT_DBL_TYPE(d)) {
+ #if 0 && !defined(NDEBUG)
+ dolog("BUILTIN that returns float or double (%s.%s)", m->clazz->name->text, m->name->text);
+@@ -3019,7 +3021,7 @@
+ s1 = (s4) (cd->mcodeptr - cd->mcodebase);
+ M_RECOMPUTE_PV(s1);
+
+-#if !defined(__SOFTFP__)
++#if !defined(__SOFTFP__) && !defined(__VFP_FP__)
+ /* TODO: this is only a hack, since we use R0/R1 for float return! */
+ /* this depends on gcc; it is independent from our ENABLE_SOFTFLOAT define */
+ if (md->returntype.type != TYPE_VOID && IS_FLT_DBL_TYPE(md->returntype.type)) {
+@@ -3030,7 +3032,7 @@
+ /* M_CAST_FLT_TO_INT_TYPED(md->returntype.type, REG_FRESULT, REG_RESULT_TYPED(md->returntype.type)); */
+ if (IS_2_WORD_TYPE(md->returntype.type)) {
+ DCD(0xed2d8102); /* stfd f0, [sp, #-8]! */
+- M_LDRD_UPDATE(REG_RESULT_PACKED, REG_SP, 8);
++ M_LDRD_UPDATE(REG_RESULT_PACKED, REG_SP, 8);
+ } else {
+ DCD(0xed2d0101); /* stfs f0, [sp, #-4]!*/
+ M_LDR_UPDATE(REG_RESULT, REG_SP, 4);