This commit introduces C++ support.
authorChristian Thalinger <twisti@complang.tuwien.ac.at>
Sun, 22 Jun 2008 16:19:54 +0000 (18:19 +0200)
committerChristian Thalinger <twisti@complang.tuwien.ac.at>
Sun, 22 Jun 2008 16:19:54 +0000 (18:19 +0200)
* configure.ac (OPT_CXXFLAGS): New variable.
(ARCH_CFLAGS): Renamed to ARCH_FLAGS.
(OS_FLAGS): New variable.
(CC_FLAGS, CXX_FLAGS): Likewise.
* m4/threads.m4 (ENABLE_THREADS): Set OS_FLAGS instead of ARCH_CFLAGS.
* src/cacao/Makefile.am (nodist_EXTRA_libjvm_la_SOURCES): Added to
force C++ linking.
* src/cacaoh/dummy.c (instruction_call_site): Added.
(icmd_table): Likewise.
(package_add): Renamed to Package_add.
[HAVE___THREAD] (thread_current): Added.
[!HAVE___THREAD) (thread_current_key): Likewise.
* src/cacaoh/headers.c (printmethod): Print _this instead of this, as
it's a C++ keyword.
* src/mm/boehm-gc/configure.ac: Don't use CACAO's CFLAGS anymore.
* src/mm/memory.h [__cplusplus]: Added define.
* src/native/jni.h [__cplusplus] (_Jv_JNIEnv): Likewise.
[__cplusplus] (_Jv_JavaVM): Likewise.
* src/native/vm/openjdk/jvm.c (vm/package.h): Removed.
(vm/package.hpp): Added.
(JVM_GetSystemPackage): Renamed package_find to Package_find.
* src/toolbox/list.h [__cplusplus]: Added define.
* src/vm/Makefile.am (libvm_la_SOURCES): Removed package.[ch], added
package.{cpp,hpp}.
* src/vm/vm.c (vm/package.h): Removed.
(vm/package.hpp): Added.
(vm_create): Renamed package_init to Package_initialize.
* src/vmcore/loader.c (vm/package.h): Removed.
(vm/package.hpp): Added.
(load_class_bootstrap): Renamed package_add to Package_add.
* src/vm/package.c,
src/vm/package.h: Moved from C...
* src/vm/package.cpp,
src/vm/package.hpp: ...to C++.

17 files changed:
configure.ac
m4/threads.m4
src/cacao/Makefile.am
src/cacaoh/dummy.c
src/cacaoh/headers.c
src/mm/boehm-gc/configure.ac
src/mm/memory.h
src/native/jni.h
src/native/vm/openjdk/jvm.c
src/toolbox/list.h
src/vm/Makefile.am
src/vm/package.c [deleted file]
src/vm/package.cpp [new file with mode: 0644]
src/vm/package.h [deleted file]
src/vm/package.hpp [new file with mode: 0644]
src/vm/vm.c
src/vmcore/loader.c

index e772d32e4c238610f407115e8b0add3742b4271a..45fcc80a753ca153bf4adaa8bb7e15e622aec5cc 100644 (file)
@@ -35,87 +35,93 @@ AM_CONFIG_HEADER([config.h])
 AC_PREFIX_DEFAULT(/usr/local/cacao)
 
 
-dnl set optimization and debugging for all architectures and systems
+dnl Set optimization and debugging for all architectures and systems.
 if test x"$CFLAGS" = "x"; then
     OPT_CFLAGS="-O0 -g"
 else
     OPT_CFLAGS=$CFLAGS
 fi
 
+if test x"$CXXFLAGS" = "x"; then
+    OPT_CXXFLAGS="-O0 -g"
+else
+    OPT_CXXFLAGS=$CXXFLAGS
+fi
+
 dnl system type
 case "$host_cpu" in
 alpha | alphaev56 | alphapca56 )
     ARCH_DIR="alpha"
-    ARCH_CFLAGS="-mieee -D__ALPHA__"
+    ARCH_FLAGS="-mieee -D__ALPHA__"
     JAVA_ARCH="alpha"
     ;;
 
 arm | armv4 | armv4tl | armv5b | armv5l )
     ARCH_DIR="arm"
-    ARCH_CFLAGS="-D__ARM__"
+    ARCH_FLAGS="-D__ARM__"
     JAVA_ARCH="arm"
     ;;
 
 hppa2.0 )
     ARCH_DIR="parisc"
-    ARCH_CFLAGS="-D__PARISC__"
+    ARCH_FLAGS="-D__PARISC__"
     JAVA_ARCH="hppa"
     ;;
 
 i386 | i486 | i586 | i686 )
     ARCH_DIR="i386"
-    ARCH_CFLAGS="-D__I386__"
+    ARCH_FLAGS="-D__I386__"
     JAVA_ARCH="i386"
     ;;
 
 m68k )
     ARCH_DIR="m68k"
-    ARCH_CFLAGS="-D__M68K__"
+    ARCH_FLAGS="-D__M68K__"
     JAVA_ARCH="m68k"
     ;;
 
 mips | mipsel )
     ARCH_DIR="mips"
-    ARCH_CFLAGS="-D__MIPS__"
+    ARCH_FLAGS="-D__MIPS__"
     dnl Is this correct for mipsel?
     JAVA_ARCH="mips"
     ;;
 
 powerpc )
     ARCH_DIR="powerpc"
-    ARCH_CFLAGS="-D__POWERPC__"
+    ARCH_FLAGS="-D__POWERPC__"
     JAVA_ARCH="ppc"
     ;;
 
 powerpc64 )
     ARCH_DIR="powerpc64"
-    ARCH_CFLAGS="-D__POWERPC64__"
+    ARCH_FLAGS="-D__POWERPC64__"
     JAVA_ARCH="ppc64"
     ;;
 
 s390 )
     ARCH_DIR="s390"
-    ARCH_CFLAGS="-D__S390__"
+    ARCH_FLAGS="-D__S390__"
     JAVA_ARCH="s390"
     ;;
 
 sparc | sparc64 )
     ARCH_DIR="sparc64"
-    ARCH_CFLAGS="-mcpu=v9 -m64 -D__SPARC_64__"
+    ARCH_FLAGS="-mcpu=v9 -m64 -D__SPARC_64__"
     dnl Is this correct for 64-bits?
     JAVA_ARCH="sparc"
     ;;
 
 x86_64 )
     ARCH_DIR="x86_64"
-    ARCH_CFLAGS="-D__X86_64__"
+    ARCH_FLAGS="-m64 -D__X86_64__"
     JAVA_ARCH="amd64"
     ;;
 
 xdspcore )
     ARCH_DIR="xdspcore"
     ENABLE_STATICVM="yes"
-    ARCH_CFLAGS="-D__XDSPCORE__"
+    ARCH_FLAGS="-D__XDSPCORE__"
     USE_SCHEDULER="1"
     ;;
 
@@ -128,52 +134,68 @@ dnl host type
 case "$host_os" in
 *cygwin* )
     OS_DIR="cygwin"
-    INTRP_CFLAGS="$ARCH_CFLAGS -D__WINDOWS__ -D__CYGWIN__ -Wall -Wno-long-long"
-    ARCH_CFLAGS="$ARCH_CFLAGS -D__WINDOWS__ -D__CYGWIN__ -std=c99 -pedantic -Wall -Wno-long-long"
+    OS_FLAGS="-D__WINDOWS__ -D__CYGWIN__"
+    CC_FLAGS="-std=c99 -pedantic -Wall -Wno-long-long"
+    CXX_FLAGS="-std=c++98 -pedantic -Wall -Wno-long-long"
+    INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS"
     ;;
 
 *darwin* )
     OS_DIR="darwin"
-    INTRP_CFLAGS="$ARCH_CFLAGS -D__DARWIN__ -Wall -Wno-long-long"
-    ARCH_CFLAGS="$ARCH_CFLAGS -D__DARWIN__ -std=c99 -pedantic -Wall -Wno-long-long"
+    OS_FLAGS="-D__DARWIN__"
+    CC_FLAGS="-std=c99 -pedantic -Wall -Wno-long-long"
+    CXX_FLAGS="-std=c++98 -pedantic -Wall -Wno-long-long"
+    INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS"
     ;;
 
 dnl Must be BEFORE *freebsd*.
 *kfreebsd*-gnu)
     OS_DIR="freebsd"
-    INTRP_CFLAGS="$ARCH_CFLAGS -D__FREEBSD__ -Wall -Wno-long-long -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
-    ARCH_CFLAGS="$ARCH_CFLAGS -D__FREEBSD__ -std=c99 -pedantic -Wall -Wno-long-long -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
+    OS_FLAGS="-D__FREEBSD__ -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
+    CC_FLAGS="-std=c99 -pedantic -Wall -Wno-long-long"
+    CXX_FLAGS="-std=c++98 -pedantic -Wall -Wno-long-long"
+    INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS"
     ;;
 
 *freebsd* )
     OS_DIR="freebsd"
-    INTRP_CFLAGS="$ARCH_CFLAGS -D__FREEBSD__ -Wall -Wno-long-long -D_XOPEN_SOURCE_EXTENDED"
-    ARCH_CFLAGS="$ARCH_CFLAGS -D__FREEBSD__ -std=c99 -pedantic -Wall -Wno-long-long -D_XOPEN_SOURCE_EXTENDED"
+    OS_FLAGS="-D__FREEBSD__ -D_XOPEN_SOURCE_EXTENDED"
+    CC_FLAGS="-std=c99 -pedantic -Wall -Wno-long-long"
+    CXX_FLAGS="-std=c++98 -pedantic -Wall -Wno-long-long"
+    INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS"
     ;;
 
 *irix* )
     OS_DIR="irix"
-    INTRP_CFLAGS="$ARCH_CFLAGS -D__IRIX__"
-    ARCH_CFLAGS="$ARCH_CFLAGS -D__IRIX__"
+    OS_FLAGS="-D__IRIX__"
+    CC_FLAGS=""
+    CXX_FLAGS=""
+    INTRP_CFLAGS="$ARCH_FLAGS $OS_FLAGS"
     ;;
 
 dnl Must be BEFORE *linux*.
 *uclinux | *elf )
     OS_DIR="uclinux"
-    INTRP_CFLAGS="$ARCH_CFLAGS -D__LINUX__ -Wall -Wno-long-long -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
-    ARCH_CFLAGS="$ARCH_CFLAGS -D__LINUX__ -std=c99 -pedantic -Wall -Wno-long-long -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
+    OS_FLAGS="-D__LINUX__ -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
+    CC_FLAGS="-std=c99 -pedantic -Wall -Wno-long-long"
+    CXX_FLAGS="-std=c++98 -pedantic -Wall -Wno-long-long"
+    INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS"
     ;;
 
 *linux* | *Linux* )
     OS_DIR="linux"
-    INTRP_CFLAGS="$ARCH_CFLAGS -D__LINUX__ -Wall -Wno-long-long -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
-    ARCH_CFLAGS="$ARCH_CFLAGS -D__LINUX__ -std=c99 -pedantic -Wall -Wno-long-long -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
+    OS_FLAGS="-D__LINUX__ -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
+    CC_FLAGS="-std=c99 -pedantic -Wall -Wno-long-long"
+    CXX_FLAGS="-std=c++98 -pedantic -Wall -Wno-long-long"
+    INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS"
     ;;
 
 *netbsd* )
     OS_DIR="netbsd"
-    INTRP_CFLAGS="$ARCH_CFLAGS -D__NETBSD__ -Wall -Wno-long-long -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
-    ARCH_CFLAGS="$ARCH_CFLAGS -D__NETBSD__ -std=c99 -pedantic -Wall -Wno-long-long -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
+    OS_FLAGS="-D__NETBSD__ -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
+    CC_FLAGS="-std=c99 -pedantic -Wall -Wno-long-long"
+    CXX_FLAGS="-std=c++98 -pedantic -Wall -Wno-long-long"
+    INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS"
     ;;
 
 *solaris* )
@@ -181,8 +203,10 @@ dnl Must be BEFORE *linux*.
     dnl On solaris the architecture defines 'sparc', 'sun', 'unix' are
     dnl not set when cpp is called with -std=c99, therefore we add them
     dnl here.
-    INTRP_CFLAGS="$ARCH_CFLAGS -D__SOLARIS__ -Wall -Wno-long-long -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D__EXTENSIONS__ -D_BSD_SOURCE -Dsparc -Dsun -Dunix"
-    ARCH_CFLAGS="$ARCH_CFLAGS -D__SOLARIS__ -std=c99 -pedantic -Wall -Wno-long-long -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D__EXTENSIONS__ -D_BSD_SOURCE -Dsparc -Dsun -Dunix"
+    OS_FLAGS="-D__SOLARIS__ -D_POSIX_C_SOURCE=200112L -D__EXTENSIONS__ -D_BSD_SOURCE"
+    CC_FLAGS="-std=c99 -pedantic -Wall -Wno-long-long -D_XOPEN_SOURCE=600"
+    CXX_FLAGS="-std=c++98 -pedantic -Wall -Wno-long-long"
+    INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS"
     ;;
 
 * )
@@ -192,7 +216,8 @@ esac
 
 dnl temporary set the CFLAGS for configure tests (e.g. inline keyword)
 dnl we set it properly at the end of this file
-CFLAGS="$ARCH_CFLAGS $OPT_CFLAGS"
+CFLAGS="$OPT_CFLAGS $ARCH_FLAGS $OS_FLAGS $CC_FLAGS"
+CXXFLAGS="$OPT_CXXFLAGS $ARCH_FLAGS $OS_FLAGS $CXX_FLAGS"
 
 dnl set interpreter flags
 AC_SUBST(INTRP_CFLAGS)
@@ -208,6 +233,7 @@ AC_SUBST(USE_SCHEDULER)
 
 dnl Checks for programs.
 AC_PROG_CC
+AC_PROG_CXX
 AM_PROG_AS
 AC_PROG_LD
 AC_PROG_LD_GNU
@@ -588,14 +614,21 @@ AZ_PYTHON_LSPEC
 dnl define some stuff required for --fullversion
 AC_DEFINE_UNQUOTED(VERSION_CONFIGURE_ARGS, "$ac_configure_args", [configure arguments])
 AC_DEFINE_UNQUOTED(VERSION_CC, "$CC", [CC used])
-AC_DEFINE_UNQUOTED(VERSION_CFLAGS, "$OPT_CFLAGS $ARCH_CFLAGS $CPPFLAGS", [CFLAGS used])
+AC_DEFINE_UNQUOTED(VERSION_CXX, "$CXX", [CXX used])
+AC_DEFINE_UNQUOTED(VERSION_CFLAGS, "$OPT_CFLAGS $ARCH_CFLAGS $CC_FLAGS $CPPFLAGS", [CFLAGS used])
+AC_DEFINE_UNQUOTED(VERSION_CXXFLAGS, "$OPT_CXXFLAGS $ARCH_CXXFLAGS $CXX_FLAGS $CPPFLAGS", [CXXFLAGS used])
 
 
-dnl finally pass CFLAGS to Makefiles via AM_CFLAGS
+dnl Finally pass flags to Makefiles.
 CFLAGS="$OPT_CFLAGS"
-AM_CFLAGS=$ARCH_CFLAGS
+CXXFLAGS="$OPT_CXXFLAGS"
+
+AM_CFLAGS="$CC_FLAGS $ARCH_FLAGS $OS_FLAGS"
+AM_CXXFLAGS="$CXX_FLAGS $ARCH_FLAGS $OS_FLAGS"
 AM_CPPFLAGS="$CPPFLAGS"
+
 AC_SUBST(AM_CFLAGS)
+AC_SUBST(AM_CXXFLAGS)
 AC_SUBST(AM_CPPFLAGS)
 
 
@@ -685,11 +718,8 @@ AC_CONFIG_FILES([Makefile]
 )
 
 
-dnl now configure subpackages with OPT_CFLAGS and ARCH_CFLAGS
-export OPT_CFLAGS
-export ARCH_CFLAGS
 dnl We only build the shared library objects but we use it as
-dnl noinst_LTLIBRARIES
+dnl noinst_LTLIBRARIES.
 ac_configure_args="$ac_configure_args --disable-static"
 AC_CONFIG_SUBDIRS(src/mm/boehm-gc)
 
index 08cc6f8ed9df0c801c38c1112987af74b7cf7a78..c1acf9baebd91fde444220ee39c0af1c8b8ee380 100644 (file)
@@ -57,10 +57,11 @@ case "${ENABLE_THREADS}" in
         AC_DEFINE([ENABLE_THREADS], 1, [enable threads])
         AC_CHECK_LIB(pthread, main)
 
-        ARCH_CFLAGS="$ARCH_CFLAGS -D_REENTRANT"
+        OS_FLAGS="$OS_FLAGS -D_REENTRANT"
 
-        dnl we changed ARCH_CFLAGS, set CFLAGS again
-        CFLAGS="$ARCH_CFLAGS $OPT_CFLAGS"
+        dnl We changed OS_FLAGS, set CFLAGS again.
+        CFLAGS="$OPT_CFLAGS $ARCH_FLAGS $OS_FLAGS $CC_FLAGS"
+        CXXFLAGS="$OPT_CXXFLAGS $ARCH_FLAGS $OS_FLAGS $CXX_FLAGS"
 
         dnl tell boehm to support threads as well
         ac_configure_args="$ac_configure_args --enable-boehm-threads=posix"
index 73f5b839ac3fa782b472f9596de6c593709c1ace..d804c994f6a93acd64b53968518b2b316bb892ca 100644 (file)
@@ -68,6 +68,11 @@ endif
 
 libjvm_la_SOURCES =
 
+# Dummy C++ source to cause C++ linking.
+# http://www.gnu.org/software/automake/manual/automake.html#Libtool-Convenience-Libraries
+nodist_EXTRA_libjvm_la_SOURCES = \
+       dummy.cxx
+
 libjvm_la_LIBADD = \
        $(top_builddir)/src/fdlibm/libfdlibm.la \
        $(top_builddir)/src/mm/libmm.la \
index 82c994a2eab6e89703e6e074617bc811ca44475b..90168f788e53f07493d16a67ff2c99119f0949c5 100644 (file)
@@ -463,8 +463,18 @@ s4 heap_get_hashcode(java_object_t *o)
 }
 
 
+/* instruction ****************************************************************/
+
+methoddesc *instruction_call_site(const instruction *iptr)
+{
+       return NULL;
+}
+
+
 /* jit ************************************************************************/
 
+icmdtable_entry_t icmd_table[256] = {};
+
 void jit_invalidate_code(methodinfo *m)
 {
        vm_abort("jit_invalidate_code");
@@ -562,8 +572,8 @@ void dumpmemory_release(int32_t size)
 
 /* package ********************************************************************/
 
-/* void package_add(java_handle_t *packagename) */
-void package_add(utf *packagename)
+/* void Package_add(java_handle_t *packagename) */
+void Package_add(utf *packagename)
 {
        /* Do nothing. */
 }
@@ -736,6 +746,13 @@ java_handle_objectarray_t *stacktrace_getClassContext()
 
 /* threads ********************************************************************/
 
+#if defined(HAVE___THREAD)
+__thread threadobject *thread_current;
+#else
+#include <pthread.h>
+pthread_key_t thread_current_key;
+#endif
+
 intptr_t threads_get_current_tid(void)
 {
        return 0;
index 8d9c42fc921bfb6e9b2870e412b1f931b9dd7cf0..e8a2951e4830eee8a3d9896b8fa853fd343b3c10 100644 (file)
@@ -313,7 +313,7 @@ void printmethod(methodinfo *m)
        if (!(m->flags & ACC_STATIC)) {
                fprintf(file, ", struct ");
                printID(m->clazz->name);
-               fprintf(file, "* this");
+               fprintf(file, "* _this");
 
        } else {
                fprintf(file, ", jclass clazz");
index 7e5d530f71bfd9416d540a960037342d94694dd6..5ab3d30afd95b7824d35cb6f2aa52b091b504d45 100644 (file)
@@ -35,11 +35,6 @@ AC_SUBST(GC_VERSION)
 AM_PROG_CC_C_O
 AC_PROG_CXX
 
-dnl temporary set the CFLAGS for configure tests (e.g. inline keyword)
-dnl we set it properly later in this file
-CFLAGS="$ARCH_CFLAGS $OPT_CFLAGS"
-AC_C_INLINE
-
 AM_PROG_AS
 ## FIXME: really needed? (AC_LIBTOOL already provides this)
 AC_CHECK_TOOL(AR, ar)
@@ -500,15 +495,6 @@ case "$host" in
  *) AC_MSG_RESULT(no) ;;
 esac
 
-dnl We need to override the top-level CFLAGS.  This is how we do it.
-dnl MY_CFLAGS="$CFLAGS"
-dnl AC_SUBST(MY_CFLAGS)
-
-dnl pass CFLAGS to Makefiles via AM_CFLAGS
-CFLAGS=$OPT_CFLAGS
-AM_CFLAGS=$ARCH_CFLAGS
-AC_SUBST(AM_CFLAGS)
-
 dnl Include defines that have become de facto standard.
 dnl ALL_INTERIOR_POINTERS can be overridden in startup code.
 AC_DEFINE([NO_EXECUTE_PERMISSION], 1, [no exceute permission])
index 0d2c74b2957d2d84bc4d6f8a4e0e3cb5d153e53f..8a88321d38480fceaa3ebb1d34759a2b84952dd9 100644 (file)
 #ifndef _MEMORY_H
 #define _MEMORY_H
 
-
 #include "config.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <string.h>
 
 #include "vm/types.h"
@@ -144,6 +147,10 @@ void *mem_realloc(void *src, int32_t len1, int32_t len2);
 bool  memory_start_thread(void);
 #endif
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _MEMORY_H */
 
 
index a74f68688c9fbe855c6ddcdf36fbd508c6d585c7..c930fab0b5ac02ce4e23c60effe6357961ad851a 100644 (file)
 
 /* _Jv_JNIEnv *****************************************************************/
 
+#ifndef __cplusplus
+
+// FIXME The __cplusplus define is just a quick workaround and needs
+// to be fixed properly.
+
 typedef struct _Jv_JNIEnv _Jv_JNIEnv;
 
 struct _Jv_JNIEnv {
        const struct JNINativeInterface_ *env;    /* This MUST be the first entry */
 };
 
+#endif
+
 
 /* _Jv_JavaVM *****************************************************************/
 
+#ifndef __cplusplus
+
+// FIXME The __cplusplus define is just a quick workaround and needs
+// to be fixed properly.
+
 typedef struct _Jv_JavaVM _Jv_JavaVM;
 
 struct _Jv_JavaVM {
@@ -90,6 +102,8 @@ struct _Jv_JavaVM {
        s8 java_lang_management_ThreadMXBean_TotalStartedThreadCount;
 };
 
+#endif
+
 
 /* CACAO related stuff ********************************************************/
 
index 9990ea5d4cbbce3430788487d667f7e359156d38..2c946b7f1a99d7e2d1fa235c844c7002347b7125 100644 (file)
@@ -81,7 +81,7 @@
 #include "vm/exceptions.h"
 #include "vm/global.h"
 #include "vm/initialize.h"
-#include "vm/package.h"
+#include "vm/package.hpp"
 #include "vm/primitive.h"
 #include "vm/properties.h"
 #include "vm/resolve.h"
@@ -2515,10 +2515,10 @@ jstring JVM_GetSystemPackage(JNIEnv *env, jstring name)
 
        TRACEJVMCALLS(("JVM_GetSystemPackage(env=%p, name=%p)", env, name));
 
-/*     s = package_find(name); */
+/*     s = Package_find(name); */
        u = javastring_toutf((java_handle_t *) name, false);
 
-       result = package_find(u);
+       result = Package_find(u);
 
        if (result != NULL)
                s = javastring_new(result);
index 6837e3b78633199ea1026850e762ff8f01a4df8a..f93cf1b076fa5721d39242cf7f95032f1db49996 100644 (file)
 
 #include "config.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <stdint.h>
 
 #include "vm/global.h"
@@ -137,6 +141,10 @@ void   *list_last(list_t *l);
 void   *list_next(list_t *l, void *element);
 void   *list_prev(list_t *l, void *element);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _LIST_H */
 
 
index fb3c8ba88f96f2177342070b9e071271e43ff67b..cd56a115fff690fba2e7c554d365d0de759f02d9 100644 (file)
@@ -1,9 +1,7 @@
 ## src/vm/Makefile.am
 ##
-## Copyright (C) 1996-2005, 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
+## Copyright (C) 1996-2005, 2006, 2007, 2008
+## CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 ##
 ## This file is part of CACAO.
 ##
@@ -22,7 +20,6 @@
 ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 ## 02110-1301, USA.
 
-## Process this file with automake to produce Makefile.in
 
 AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR) -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR)/$(OS_DIR) -I$(top_builddir)/src -I$(top_srcdir)/contrib/vmlog -I$(top_srcdir)/src/native
 
@@ -66,8 +63,8 @@ libvm_la_SOURCES = \
        initialize.c \
        initialize.h \
        jit_interface.h \
-       package.c \
-       package.h \
+       package.cpp \
+       package.hpp \
        primitive.c \
        primitive.h \
        properties.c \
diff --git a/src/vm/package.c b/src/vm/package.c
deleted file mode 100644 (file)
index c544b96..0000000
+++ /dev/null
@@ -1,170 +0,0 @@
-/* src/vm/package.c - Java boot-package functions
-
-   Copyright (C) 2007, 2008
-   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
-
-   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.
-
-*/
-
-
-#include "config.h"
-
-#include <stdint.h>
-
-#include "toolbox/list.h"
-
-#include "mm/memory.h"
-
-#include "native/jni.h"
-
-#include "native/include/java_lang_String.h"
-
-#include "vm/package.h"
-#include "vm/stringlocal.h"
-
-#include "vmcore/options.h"
-#include "vmcore/utf8.h"
-
-
-/* internal property structure ************************************************/
-
-typedef struct list_package_entry_t list_package_entry_t;
-
-struct list_package_entry_t {
-/*     java_string_t *packagename; */
-       utf           *packagename;
-       listnode_t     linkage;
-};
-
-
-/* global variables ***********************************************************/
-
-static list_t *list_package = NULL;
-
-
-/* package_init ****************************************************************
-
-   Initialize the package list.
-
-*******************************************************************************/
-
-void package_init(void)
-{
-       TRACESUBSYSTEMINITIALIZATION("package_init");
-
-       /* create the properties list */
-
-       list_package = list_create(OFFSET(list_package_entry_t, linkage));
-}
-
-
-/* package_add *****************************************************************
-
-   Add a package to the boot-package list.
-
-   IN:
-       packagename....package name as Java string
-
-*******************************************************************************/
-
-/* void package_add(java_handle_t *packagename) */
-void package_add(utf *packagename)
-{
-/*     java_string_t        *s; */
-       list_package_entry_t *lpe;
-
-       /* Intern the Java string to get a unique address. */
-
-/*     s = javastring_intern(packagename); */
-
-       /* Check if the package is already stored. */
-
-       if (package_find(packagename) != NULL)
-               return;
-
-       /* Add the package. */
-
-#if !defined(NDEBUG)
-       if (opt_DebugPackage) {
-               log_start();
-               log_print("[package_add: packagename=");
-               utf_display_printable_ascii(packagename);
-               log_print("]");
-               log_finish();
-       }
-#endif
-
-       lpe = NEW(list_package_entry_t);
-
-       lpe->packagename = packagename;
-
-       list_add_last(list_package, lpe);
-}
-
-
-/* package_find ****************************************************************
-
-   Find a package in the list.
-
-   IN:
-       packagename....package name as Java string
-
-   OUT:
-       package name as Java string
-
-*******************************************************************************/
-
-/* java_handle_t *package_find(java_handle_t *packagename) */
-utf *package_find(utf *packagename)
-{
-/*     java_string_t        *s; */
-       list_t               *l;
-       list_package_entry_t *lpe;
-
-       /* Intern the Java string to get a unique address. */
-
-/*     s = javastring_intern(packagename); */
-
-       /* For convenience. */
-
-       l = list_package;
-
-       for (lpe = list_first(l); lpe != NULL; lpe = list_next(l, lpe)) {
-/*             if (lpe->packagename == s) */
-               if (lpe->packagename == packagename)
-                       return lpe->packagename;
-       }
-
-       return NULL;
-}
-
-
-/*
- * These are local overrides for various environment variables in Emacs.
- * Please do not remove this and leave it at the end of the file, where
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- * vim:noexpandtab:sw=4:ts=4:
- */
diff --git a/src/vm/package.cpp b/src/vm/package.cpp
new file mode 100644 (file)
index 0000000..647baf1
--- /dev/null
@@ -0,0 +1,169 @@
+/* src/vm/package.cpp - Java boot-package functions
+
+   Copyright (C) 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+
+   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.
+
+*/
+
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "toolbox/list.h"
+
+#include "mm/memory.h"
+
+#include "native/jni.h"
+
+#include "native/include/java_lang_String.h"
+
+#include "vm/package.hpp"
+#include "vm/stringlocal.h"
+
+#include "vmcore/options.h"
+#include "vmcore/utf8.h"
+
+
+/* internal property structure ************************************************/
+
+typedef struct list_package_entry_t list_package_entry_t;
+
+struct list_package_entry_t {
+/*     java_string_t *packagename; */
+       utf           *packagename;
+       listnode_t     linkage;
+};
+
+
+/* global variables ***********************************************************/
+
+static list_t *list_package = NULL;
+
+
+/**
+ * Initialize the package list.
+ */
+void Package::initialize(void)
+{
+       TRACESUBSYSTEMINITIALIZATION("package_init");
+
+       /* create the properties list */
+
+       list_package = list_create(OFFSET(list_package_entry_t, linkage));
+}
+
+
+/**
+ * Add a package to the boot-package list.
+ *
+ * @param packagename Package name as Java string.
+ */
+/* void package_add(java_handle_t *packagename) */
+void Package::add(utf *packagename)
+{
+/*     java_string_t        *s; */
+       list_package_entry_t *lpe;
+
+       /* Intern the Java string to get a unique address. */
+
+/*     s = javastring_intern(packagename); */
+
+       /* Check if the package is already stored. */
+
+       if (Package::find(packagename) != NULL)
+               return;
+
+       /* Add the package. */
+
+#if !defined(NDEBUG)
+       if (opt_DebugPackage) {
+               log_start();
+               log_print("[package_add: packagename=");
+               utf_display_printable_ascii(packagename);
+               log_print("]");
+               log_finish();
+       }
+#endif
+
+       lpe = NEW(list_package_entry_t);
+
+       lpe->packagename = packagename;
+
+       list_add_last(list_package, lpe);
+}
+
+
+/**
+ * Find a package in the list.
+ *
+ * @param packagename Package name as Java string.
+ *
+ * @return Package name as Java string.
+ */
+/* java_handle_t *package_find(java_handle_t *packagename) */
+utf* Package::find(utf *packagename)
+{
+/*     java_string_t        *s; */
+       list_t               *l;
+       list_package_entry_t *lpe;
+
+       /* Intern the Java string to get a unique address. */
+
+/*     s = javastring_intern(packagename); */
+
+       /* For convenience. */
+
+       l = list_package;
+
+       for (lpe = (list_package_entry_t*) list_first(l); lpe != NULL; lpe = (list_package_entry_t*) list_next(l, lpe)) {
+/*             if (lpe->packagename == s) */
+               if (lpe->packagename == packagename)
+                       return lpe->packagename;
+       }
+
+       return NULL;
+}
+
+
+/* Legacy C interface *********************************************************/
+
+extern "C" {
+
+void Package_initialize(void) { Package::initialize(); }
+void Package_add(utf* packagename) { Package::add(packagename); }
+utf* Package_find(utf *packagename) { return Package::find(packagename); }
+
+}
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c++
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
diff --git a/src/vm/package.h b/src/vm/package.h
deleted file mode 100644 (file)
index 95fcd54..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/* src/vm/package.c - Java boot-package functions
-
-   Copyright (C) 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.
-
-*/
-
-
-#ifndef _VM_PACKAGE_H
-#define _VM_PACKAGE_H
-
-#include "config.h"
-
-#include <stdint.h>
-
-#include "native/jni.h"
-
-#include "vm/global.h"
-
-
-/* function prototypes ********************************************************/
-
-void           package_init(void);
-
-/* void           package_add(java_handle_t *packagename); */
-void           package_add(utf *packagename);
-/* java_handle_t *package_find(java_handle_t *packagename); */
-utf           *package_find(utf *packagename);
-
-#endif /* _VM_PACKAGE_H */
-
-
-/*
- * These are local overrides for various environment variables in Emacs.
- * Please do not remove this and leave it at the end of the file, where
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- * vim:noexpandtab:sw=4:ts=4:
- */
diff --git a/src/vm/package.hpp b/src/vm/package.hpp
new file mode 100644 (file)
index 0000000..38b129a
--- /dev/null
@@ -0,0 +1,87 @@
+/* src/vm/package.hpp - Java boot-package functions
+
+   Copyright (C) 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+
+   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.
+
+*/
+
+
+#ifndef _VM_PACKAGE_HPP
+#define _VM_PACKAGE_HPP
+
+#include "config.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+
+#include "native/jni.h"
+
+#include "vm/global.h"
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#ifdef __cplusplus
+
+/**
+ *
+ */
+class Package {
+public:
+       static void initialize();
+       /* static void add(java_handle_t *packagename); */
+       static void add(utf *packagename);
+       /* static java_handle_t* find(java_handle_t *packagename); */
+       static utf* find(utf *packagename);
+};
+
+#else
+
+/* Legacy C interface *********************************************************/
+
+typedef struct Package Package;
+
+void Package_initialize();
+void Package_add(utf* packagename);
+utf* Package_find(utf* packagename);
+
+#endif
+
+#endif /* _VM_PACKAGE_HPP */
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c++
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
index f1c87f7c2dcbfcadf94e7aa4883679d421ec2238..5fa1f57a1db303de45b7fe3d55459255e5654268 100644 (file)
@@ -76,7 +76,7 @@
 #include "vm/finalizer.h"
 #include "vm/global.h"
 #include "vm/initialize.h"
-#include "vm/package.h"
+#include "vm/package.hpp"
 #include "vm/primitive.h"
 #include "vm/properties.h"
 #include "vm/signallocal.h"
@@ -1467,7 +1467,7 @@ bool vm_create(JavaVMInitArgs *vm_args)
 
        /* BEFORE: loader_preinit */
 
-       package_init();
+       Package_initialize();
 
        /* AFTER: utf8_init, classcache_init */
 
index a1d730ccc39f29d7978405fd7c3436cfa10cddd2..c303485d056611d5a8bd2e4d7b3103a0e5f530a2 100644 (file)
@@ -43,7 +43,7 @@
 #include "vm/builtin.h"
 #include "vm/exceptions.h"
 #include "vm/global.h"
-#include "vm/package.h"
+#include "vm/package.hpp"
 #include "vm/primitive.h"
 #include "vm/resolve.h"
 #include "vm/stringlocal.h"
@@ -1323,7 +1323,7 @@ classinfo *load_class_bootstrap(utf *name)
                else {
                        /* Add the package name to the boot packages. */
 
-                       package_add(c->packagename);
+                       Package_add(c->packagename);
                }
 
                r = res;