Kaffe 1.0.1 on NetWinder (linux/arm/elf)

Raffaele Sena raff at aromatic.com
Sun Jul 19 20:47:40 PDT 1998


Here are my changes to make Kaffe work on Corel NetWinder (a StrongARM
based linux box).

Some of the changes are general fixes while some are more related to
the port.

Kaffe now builds and runs on NetWinder using jthreads, static link and
the interpreter. Just a plain 'configure' should generate the correct
configuration.

All the regression tests pass.

There is a pending problem with signals that now has a hack in
kaffe/kaffevm/intrp/jthreads.c. It could be a problem of the current
NetWinder kernel, but I'm not sure yet.

The diff are made against today (7/19) snapshot.

Happy Hacking,
	Raffaele

#########################################################################

Note: the current alignment for data objects is defined in 
      kaffe/kaffevm/classMethod as:

	#define ALIGNMENT_OF_SIZE(S)	(S)

      this forces objects in a class to get aligned to their native size
      (i.e. 4 for a Java integer, 8 for a Java long)

      this has to corrispond with the alignment your compiler applies
      to data structure.

      This definition can be overridden by a specific architecture,
      but this is only done for Intel, where the macro is defined as:

	#define	ALIGNMENT_OF_SIZE(S)	((S) < 4 ? (S) : 4)

      I believe most of the current 32bits compilers align fields in
      a data structure to a maximum of 4. So, I would guess this should
      be the default definition.

      I had to define the macro as before to make kaffe run on arm/linux
      and I got a message from another person that did the same for m68k.


      If you get an error using pizza to compile HelloWorldApp.java,
      you probably are having the same problem.

#############################################################################
#
# A fix to make the interpreter correctly convert from Java int to Java char
#
diff -u ./kaffe/kaffevm/intrp/icode.h ../kaffe-snap/./kaffe/kaffevm/intrp/icode.h
--- ./kaffe/kaffevm/intrp/icode.h	Sun Jul 19 18:07:57 1998
+++ ../kaffe-snap/./kaffe/kaffevm/intrp/icode.h	Tue Mar 31 14:10:54 1998
@@ -89,7 +89,7 @@
 #define	xor_int(t, f1, f2)			(t)[0].v.tint = ((f1)[0].v.tint) ^ ((f2)[0].v.tint)
 
 #define	cvt_int_byte(t, f)			(t)[0].v.tint = (((f)[0].v.tint) << 24) >> 24
-#define	cvt_int_char(t, f)			(t)[0].v.tint = (((f)[0].v.tint) << 16) >> 16
+#define	cvt_int_char(t, f)			(t)[0].v.tint = ((f)[0].v.tint) & 0xFF
 #define	cvt_int_short(t, f)			(t)[0].v.tint = (((f)[0].v.tint) << 16) >> 16
 
 #define	branch_indirect(w)			w



#########################################################################
#
# This is to make kaffe compile with CREATE_NULLPOINTER_CHECKS defined
#
diff -u ./kaffe/kaffevm/kaffe.def ../kaffe-snap/./kaffe/kaffevm/kaffe.def
--- ./kaffe/kaffevm/kaffe.def	Sun Jul 19 18:05:16 1998
+++ ../kaffe-snap/./kaffe/kaffevm/kaffe.def	Mon May 11 16:56:36 1998
@@ -2059,26 +2059,26 @@
 		break;
 	case 'S':
 		check_stack_ref(1);
-		CHECK_NULL(PUTFIELD, stack(1), 37_1);
+		CHECK_NULL(PUTFIELD, stack(1), 37);
 		store_offset_short(stack(1), FIELD_OFFSET(finfo.field), stack(0));
 		pop(2);
 		break;
 	case 'B':
 	case 'Z':
 		check_stack_ref(1);
-		CHECK_NULL(PUTFIELD, stack(1), 37_2);
+		CHECK_NULL(PUTFIELD, stack(1), 37);
 		store_offset_byte(stack(1), FIELD_OFFSET(finfo.field), stack(0));
 		pop(2);
 		break;
 	case 'C':
 		check_stack_ref(1);
-		CHECK_NULL(PUTFIELD, stack(1), 37_3);
+		CHECK_NULL(PUTFIELD, stack(1), 37);
 		store_offset_char(stack(1), FIELD_OFFSET(finfo.field), stack(0));
 		pop(2);
 		break;
 	case 'F':
 		check_stack_ref(1);
-		CHECK_NULL(PUTFIELD, stack(1), 37_4);
+		CHECK_NULL(PUTFIELD, stack(1), 37);
 		store_offset_float(stack(1), FIELD_OFFSET(finfo.field), stack(0));
 		pop(2);
 		break;



#########################################################################
#
# This is to make kaffe work with no classpath defined and no shared
# library
#
diff -u ./libraries/clib/native/Runtime.c ../kaffe-snap/./libraries/clib/native/Runtime.c
--- ./libraries/clib/native/Runtime.c	Sun Jul 19 18:37:56 1998
+++ ../kaffe-snap/./libraries/clib/native/Runtime.c	Tue Jul 14 10:02:11 1998
@@ -37,7 +37,7 @@
 struct Hjava_lang_String*
 java_lang_Runtime_initializeLinkerInternal(struct Hjava_lang_Runtime* this)
 {
-#if 0 && defined(NO_SHARED_LIBRARIES)
+#if defined(NO_SHARED_LIBRARIES)
 	return (0);
 #else
 	return (makeJavaString(libraryPath, strlen(libraryPath)));

#--------------------------------------------------------------------------

diff -u ./libraries/javalib/java/lang/Runtime.java ../kaffe-snap/./libraries/javalib/java/lang/Runtime.java
--- ./libraries/javalib/java/lang/Runtime.java	Sun Jul 19 18:41:05 1998
+++ ../kaffe-snap/./libraries/javalib/java/lang/Runtime.java	Tue Jul 14 10:20:02 1998
@@ -113,7 +113,7 @@
 }
 
 public synchronized void loadLibrary(String libname) {
-	if ( paths != null && paths.length > 0) {
+	if ( paths != null ) {
 		/* Try library for each path */
 		for (int path = 0; path < paths.length; path++) {
 			if (loadInternal(buildLibName(paths[path], libname)) == true) {



###########################################################################
#
# FIX to make kaffe correctly set the default classpath if --prefix is
# not used (configure.in should also be updated accordingly)
#
diff -u ./configure ../kaffe-snap/configure
--- configure	Sun Jul 19 20:13:45 1998
+++ ../kaffe-snap/configure	Tue Jul 14 19:49:44 1998
@@ -4790,6 +4790,13 @@
 "
 
 
+kaffehome=`eval echo $datadir`/kaffe
+cat >> confdefs.h <<EOF
+#define DEFAULT_KAFFEHOME "$kaffehome"
+EOF
+
+
+
 trap '' 1 2 15
 cat > confcache <<\EOF
 # This file is a shell script that caches the results of configure
@@ -4989,7 +4996,6 @@
 
 cat >> $CONFIG_STATUS <<\EOF
 
-
 # Split the substitutions into bite-sized pieces for seds with
 # small command number limits, like on Digital OSF/1 and HP-UX.
 ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
@@ -5125,12 +5131,6 @@
   cat $ac_file_inputs > conftest.in
 
 EOF
-
-kaffehome=`eval echo $datadir`/kaffe
-cat >> confdefs.h <<EOF
-#define DEFAULT_KAFFEHOME "$kaffehome"
-EOF
-
 
 # Transform confdefs.h into a sed script conftest.vals that substitutes
 # the proper values into config.h.in to produce config.h.  And first:


########################################################################
#
# Changes to make kaffe build on NetWinder (arm/linux/elf)
#
diff -u ./config/config-hacks.h ../kaffe-snap/./config/config-hacks.h
--- ./config/config-hacks.h	Sun Jul 19 19:12:09 1998
+++ ../kaffe-snap/./config/config-hacks.h	Thu Jun  4 22:02:08 1998
@@ -53,6 +53,6 @@
  * emulation.  We define this constant to declare that the word order
  * in a 64bit double is the opposite of the word order in a 64bit int.
  */
-#if defined(arm32) || (defined(arm) && defined(linux))
+#if defined(arm32)
 #define DOUBLE_ORDER_OPPOSITE
 #endif

#----------------------------------------------------------------------

diff -u ./config/arm/common.h ../kaffe-snap/./config/arm/common.h
--- ./config/arm/common.h	Sun Jul 19 18:00:35 1998
+++ ../kaffe-snap/./config/arm/common.h	Mon Jun 15 17:43:26 1998
@@ -14,9 +14,6 @@
 #ifndef __arm_common_h
 #define __arm_common_h
 
-/* The arm never aligns to more than a 4 byte boundary. */
-#define	ALIGNMENT_OF_SIZE(S)	((S) < 4 ? (S) : 4)
-
 /*
  * The calling convention is such that the first four 32bit values are
  * passed in r0-r3, and the remainder goes on the stack.

#-----------------------------------------------------------------------

diff -u ./config/arm/threads.h ../kaffe-snap/./config/arm/threads.h
--- ./config/arm/threads.h	Sun Jul 19 18:01:46 1998
+++ ../kaffe-snap/./config/arm/threads.h	Thu Jun  4 22:15:46 1998
@@ -24,12 +24,6 @@
  * This is the offset into the setjmp buffer where the stack pointer is
  * stored.  This may be different with different OSes.
  */
-
-#if defined(linux)	/* arm/linux/elf (NetWinder) */
-#define	SP_OFFSET		20
-#define	FP_OFFSET		19
-#else
 #define	SP_OFFSET		23
-#endif
 
 #endif

#------------------------------------------------------------------------

diff -u ./kaffe/kaffevm/systems/unix-jthreads/config-jthreads.h ../kaffe-snap/./kaffe/kaffevm/systems/unix-jthreads/config-jthreads.h
--- ./kaffe/kaffevm/systems/unix-jthreads/config-jthreads.h	Sun Jul 19 19:13:04 1998
+++ ../kaffe-snap/./kaffe/kaffevm/systems/unix-jthreads/config-jthreads.h	Mon Jun  1 15:54:32 1998
@@ -13,14 +13,6 @@
  *            Tim Wilkinson <tim at transvirtual.com>
  */
 
-/*
- * Note: this file get included only when jthreads are used outside
- *       the context of the virtual machine. 
- *
- *       The virtual machines uses definitions from the config directory
- *	 for the specific processor.	
- */
-
 #ifndef __config_jthreads_h
 #define __config_jthreads_h
 
@@ -102,11 +94,6 @@
 #elif defined(arm32) && defined(__NetBSD__)
 
 #define SP_OFFSET		23
-
-#elif defined(arm) && defined(linux)
-
-#define SP_OFFSET		20
-#define FP_OFFSET		19
 
 #else
 #error Your system was not yet tested

#--------------------------------------------------------------------------

diff -u ./kaffe/kaffevm/systems/unix-jthreads/jthread.c ../kaffe-snap/./kaffe/kaffevm/systems/unix-jthreads/jthread.c
--- ./kaffe/kaffevm/systems/unix-jthreads/jthread.c	Sun Jul 19 19:15:18 1998
+++ ../kaffe-snap/./kaffe/kaffevm/systems/unix-jthreads/jthread.c	Fri Jul 10 22:42:43 1998
@@ -1248,10 +1248,6 @@
 	if (sleep) {
 		b = blockInts;
 		blockInts = 0;
-
-#if defined(arm) && defined(linux)	/* temporary patch for NetWinder */
-        	catchSignal(SIGALRM, interrupt);
-#endif
 	}
 	r = select(maxFd+1, &rd, &wr, 0, sleep ? 0 : &zero);
 	if (sleep) {

#--------------------------------------------------------------------------

new directory: ./config/arm/linux/

#--------------------------------------------------------------------------

new file: ./config/arm/linux/config.frag
#
# Arm/Linux configuration
#
host_cpu=arm
host_os=linux

#
# We do not support shared libraries yet
#
dynamic_libraries=no

#
# ...and only unix-jthreads is present
#
#with_threads=unix-internal

#--------------------------------------------------------------------------

new file: md.c
/*
 * arm/linux/md.c
 * Linux arm specific functions.
 *
 * Copyright (c) 1996, 1997
 *	Transvirtual Technologies, Inc.  All rights reserved.
 *
 * See the file "license.terms" for information on usage and redistribution 
 * of this file. 
 */

#include "config.h"
#include <malloc.h>

void
init_md(void)
{
#if defined(M_MMAP_MAX) && defined(HAVE_MALLOPT)
	mallopt(M_MMAP_MAX, 0);
#endif
}

#--------------------------------------------------------------------------

new file: md.h
/*
 * arm/linux/md.h
 * Linux arm configuration information.
 *
 * Copyright (c) 1996, 1997
 *	Transvirtual Technologies, Inc.  All rights reserved.
 *
 * See the file "license.terms" for information on usage and redistribution 
 * of this file. 
 */

#ifndef __arm_linux_md_h
#define __arm_linux_md_h

#include "arm/common.h"
#include "arm/threads.h"

#if defined(TRANSLATOR)
#include "jit-md.h"
#endif

/* Linux requires a little initialisation */
#define	INIT_MD()	init_md()

/* Define CREATE_NULLPOINTER_CHECKS in md.h when your machine cannot use the
 * MMU for detecting null pointer accesses
 *
 * Actually, when debugging, it would be nice to don't catch unexpected
 * exception, so...
 */

#ifdef	DEBUG
#define CREATE_NULLPOINTER_CHECKS
#endif

#endif



More information about the kaffe mailing list