Re: [PATCH] patch for Java on RTEMS

Jie Liu <[email protected]>
Newsgroups gmane.comp.gcc.java.devel,gmane.comp.gcc.java.patches,gmane.comp.gcc.patches
Message-ID <CABc96T_xe41pdHOBJDMvExbkbUrs9NknOT9-Lj1aDUEB6-sQBQ@mail.gmail.com>
> Looks OK, but there is no ChangeLog.  Do you have copyright
> assignment?

Have added ChangeLog to the patch, please see the attachment. And I
think I have copyright assignment, because I have Free Software
Foundation paperwork, as "ASSIGNMENT - GNU GCC ... JIE RT688742"

Best Regards,
Jie
gcj-rtems.patch (application/octet-stream, 14.6 KB)
Index: configure.ac
===================================================================
--- configure.ac	(revision 172224)
+++ configure.ac	(working copy)
@@ -623,7 +623,7 @@
     noconfigdirs="$noconfigdirs target-newlib target-libgloss ${libgcj}"
     ;;
   *-*-rtems*)
-    noconfigdirs="$noconfigdirs target-libgloss ${libgcj}"
+    noconfigdirs="$noconfigdirs target-libgloss"
     ;;
     # The tpf target doesn't support gdb yet.
   *-*-tpf*)
Index: boehm-gc/mach_dep.c
===================================================================
--- boehm-gc/mach_dep.c	(revision 172224)
+++ boehm-gc/mach_dep.c	(working copy)
@@ -411,7 +411,8 @@
     word dummy;
 
 #   if defined(USE_GENERIC_PUSH_REGS)
-#     ifdef HAVE_BUILTIN_UNWIND_INIT
+#     if defined(HAVE_BUILTIN_UNWIND_INIT)\
+         &&!(defined(I386) && defined(RTEMS))
         /* This was suggested by Richard Henderson as the way to	*/
         /* force callee-save registers and register windows onto	*/
         /* the stack.						*/
@@ -437,8 +438,8 @@
   	for (; (char *)i < lim; i++) {
   	    *i = 0;
   	}
-#       if defined(MSWIN32) || defined(MSWINCE) \
-                  || defined(UTS4) || defined(LINUX) || defined(EWS4800)
+#       if defined(MSWIN32) || defined(MSWINCE) || defined(UTS4) \
+           || defined(LINUX) || defined(EWS4800) || defined(RTEMS)
   	  (void) setjmp(regs);
 #       else
             (void) _setjmp(regs);
Index: boehm-gc/configure.ac
===================================================================
--- boehm-gc/configure.ac	(revision 172224)
+++ boehm-gc/configure.ac	(working copy)
@@ -235,6 +235,11 @@
     AC_DEFINE(GC_AIX_THREADS,1)
     AC_DEFINE(_REENTRANT,1)
     ;;
+ rtems)
+    THREADS=posix
+    AC_DEFINE(GC_RTEMS_PTHREADS,1)
+    AC_DEFINE(THREAD_LOCAL_ALLOC,1);
+    ;;
  decosf1 | irix | mach | os2 | dce | vxworks)
     AC_MSG_ERROR(thread package $THREADS not yet supported)
     ;;
Index: boehm-gc/include/gc_config_macros.h
===================================================================
--- boehm-gc/include/gc_config_macros.h	(revision 172224)
+++ boehm-gc/include/gc_config_macros.h	(working copy)
@@ -20,7 +20,7 @@
 	defined(GC_IRIX_THREADS) || defined(GC_LINUX_THREADS) || \
 	defined(GC_HPUX_THREADS) || defined(GC_OSF1_THREADS) || \
 	defined(GC_DGUX386_THREADS) || defined(GC_DARWIN_THREADS) || \
-	defined(GC_AIX_THREADS) || \
+	defined(GC_AIX_THREADS) || defined(GC_RTEMS_PTHREADS) || \
         (defined(GC_WIN32_THREADS) && defined(__CYGWIN32__))
 #   define GC_PTHREADS
 # endif
Index: boehm-gc/include/gc_config.h.in
===================================================================
--- boehm-gc/include/gc_config.h.in	(revision 172224)
+++ boehm-gc/include/gc_config.h.in	(working copy)
@@ -51,6 +51,9 @@
 /* support for win32 threads */
 #undef GC_WIN32_THREADS
 
+/* Define to support RTEMS pthreads. */
+#undef GC_RTEMS_PTHREADS
+
 /* ppc_thread_state64_t has field r0 */
 #undef HAS_PPC_THREAD_STATE64_R0
 
Index: boehm-gc/include/private/gcconfig.h
===================================================================
--- boehm-gc/include/private/gcconfig.h	(revision 172224)
+++ boehm-gc/include/private/gcconfig.h	(working copy)
@@ -315,6 +315,11 @@
 #    define mach_type_known
 #   endif
 # endif
+# if defined(__rtems__) && (defined(i386) || defined(__i386__))
+#   define I386
+#   define RTEMS
+#   define mach_type_known
+# endif
 # if defined(NeXT) && defined(mc68000)
 #   define M68K
 #   define NEXT
@@ -1297,6 +1302,19 @@
 #	define STACKBOTTOM ((ptr_t)0xc0000000)
 #	define DATAEND	/* not needed */
 #   endif
+#   ifdef RTEMS
+#       define OS_TYPE "RTEMS"
+#       include <sys/unistd.h>
+        extern int etext[];
+        extern int end[];
+        void *rtems_get_stack_bottom();
+#       define InitStackBottom rtems_get_stack_bottom()
+#       define DATASTART ((ptr_t)etext)
+#       define DATAEND ((ptr_t)end)
+#       define STACKBOTTOM ((ptr_t)InitStackBottom)
+#       define SIG_SUSPEND SIGUSR1
+#       define SIG_THR_RESTART SIGUSR2
+#   endif
 #   ifdef DOS4GW
 #     define OS_TYPE "DOS4GW"
       extern long __nullarea;
@@ -2370,7 +2388,8 @@
 #   else
 #     if defined(NEXT) || defined(DOS4GW) || \
 		 (defined(AMIGA) && !defined(GC_AMIGA_FASTALLOC)) || \
-		 (defined(SUNOS5) && !defined(USE_MMAP))
+		 (defined(SUNOS5) && !defined(USE_MMAP)) || \
+                 defined(RTEMS)
 #       define GET_MEM(bytes) HBLKPTR((size_t) \
 					      calloc(1, (size_t)bytes + GC_page_size) \
 					      + GC_page_size-1)
Index: boehm-gc/ChangeLog
===================================================================
--- boehm-gc/ChangeLog	(revision 172224)
+++ boehm-gc/ChangeLog	(working copy)
@@ -1,3 +1,22 @@
+2011-08-15  Jie Liu  <[email protected]>
+	* configure.ac: Add configure for RTEMS.
+	* configure: Add configure for RTEMS.
+	* include/gc_config.h.in: Add GC_RTEMS_PTHREADS for RTEMS.
+	* mach_dep.c (GC_with_callee_saves_pushed): Use setjmp for
+	RTEMS.
+	* include/gc_config_macros.h: Define GC_PTHREADS for rtems.
+	* include/private/gcconfig.h: Add configure for RTEMS/i386;
+	Use calloc for RTEMS to GET_MEM.
+	* pthread_stop_world.c (GC_stop_init): Add judge SA_RESTART
+	for operating system; Use sigprocmask unblock the signal
+	for RTEMS.
+	* pthread_support.c: Define USE_PTHREAD_SPECIFIC for RTEMS;
+	Do not include sys/mman.h for RTEMS; Add default GC_nprocs
+	for RTEMS.
+	* gc_dlopen.c: Do not include dlfcn.h for RTEMS.
+	* os_dep.c: Do not use auxiliary routines for obtaining 
+	memory from RTEMS.
+
 2011-04-06  Rainer Orth  <[email protected]>
 
 	PR testsuite/48480
Index: boehm-gc/configure
===================================================================
--- boehm-gc/configure	(revision 172224)
+++ boehm-gc/configure	(working copy)
@@ -14867,6 +14867,11 @@
     $as_echo "#define _REENTRANT 1" >>confdefs.h
 
     ;;
+ rtems)
+    THREADS=posix
+    $as_echo "#define GC_RTEMS_PTHREADS 1" >>confdefs.h
+    $as_echo "#define THREAD_LOCAL_ALLOC 1" >>confdefs.h
+    ;;
  decosf1 | irix | mach | os2 | dce | vxworks)
     as_fn_error "thread package $THREADS not yet supported" "$LINENO" 5
     ;;
Index: boehm-gc/pthread_stop_world.c
===================================================================
--- boehm-gc/pthread_stop_world.c	(revision 172224)
+++ boehm-gc/pthread_stop_world.c	(working copy)
@@ -540,10 +540,19 @@
     if (sem_init(&GC_suspend_ack_sem, 0, 0) != 0)
         ABORT("sem_init failed");
 
+#   ifdef SA_RESTART
     act.sa_flags = SA_RESTART;
+#   else
+    act.sa_flags = 0;
+#   endif
     if (sigfillset(&act.sa_mask) != 0) {
     	ABORT("sigfillset() failed");
     }
+#   ifdef GC_RTEMS_PTHREADS
+    if(sigprocmask(SIG_UNBLOCK,&act.sa_mask,NULL) !=0) {
+        ABORT("rtems sigprocmask() failed\n");
+    }
+#   endif
     GC_remove_allowed_signals(&act.sa_mask);
     /* SIG_THR_RESTART is set in the resulting mask.		*/
     /* It is unmasked by the handler when necessary. 		*/
Index: boehm-gc/pthread_support.c
===================================================================
--- boehm-gc/pthread_support.c	(revision 172224)
+++ boehm-gc/pthread_support.c	(working copy)
@@ -75,8 +75,8 @@
 # endif
 
 # if (defined(GC_DGUX386_THREADS) || defined(GC_OSF1_THREADS) || \
-      defined(GC_DARWIN_THREADS) || defined(GC_AIX_THREADS)) \
-      && !defined(USE_PTHREAD_SPECIFIC)
+      defined(GC_DARWIN_THREADS) || defined(GC_AIX_THREADS) || \
+      defined(GC_RTEMS_PTHREADS)) && !defined(USE_PTHREAD_SPECIFIC)
 #   define USE_PTHREAD_SPECIFIC
 # endif
 
@@ -111,7 +111,9 @@
 # include <time.h>
 # include <errno.h>
 # include <unistd.h>
+#if !defined(GC_RTEMS_PTHREADS)
 # include <sys/mman.h>
+#endif
 # include <sys/time.h>
 # include <sys/types.h>
 # include <sys/stat.h>
@@ -900,6 +902,9 @@
 #       endif
 #	if defined(GC_LINUX_THREADS) || defined(GC_DGUX386_THREADS)
           GC_nprocs = GC_get_nprocs();
+#       endif
+#       if defined(GC_RTEMS_PTHREADS)
+          if (GC_nprocs <= 0) GC_nprocs = 1;
 #	endif
       }
       if (GC_nprocs <= 0) {
Index: boehm-gc/gc_dlopen.c
===================================================================
--- boehm-gc/gc_dlopen.c	(revision 172224)
+++ boehm-gc/gc_dlopen.c	(working copy)
@@ -60,7 +60,9 @@
   /* GC_register_dynamic_libraries.			*/
   /* Should probably happen for other operating	systems, too. */
 
+#if !defined(GC_RTEMS_PTHREADS)
 #include <dlfcn.h>
+#endif
 
 #ifdef GC_USE_LD_WRAP
   void * __wrap_dlopen(const char *path, int mode)
Index: boehm-gc/os_dep.c
===================================================================
--- boehm-gc/os_dep.c	(revision 172224)
+++ boehm-gc/os_dep.c	(working copy)
@@ -1507,7 +1507,7 @@
 
 # if !defined(OS2) && !defined(PCR) && !defined(AMIGA) \
 	&& !defined(MSWIN32) && !defined(MSWINCE) \
-	&& !defined(MACOS) && !defined(DOS4GW)
+	&& !defined(MACOS) && !defined(DOS4GW) && !defined(RTEMS)
 
 # ifdef SUNOS4
     extern caddr_t sbrk();
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 172224)
+++ ChangeLog	(working copy)
@@ -1,3 +1,8 @@
+2011-08-15  Jie Liu  <[email protected]>
+
+	* configure.ac (*-*-rtems*): Remove ${libgcj} in nonconfigdirs.
+	* configure: Regenerate.
+
 2011-04-07  Stuart Henderson  <[email protected]>
 
 	* MAINTAINERS (Write After Approval): Add myself.
Index: libjava/configure.host
===================================================================
--- libjava/configure.host	(revision 172224)
+++ libjava/configure.host	(working copy)
@@ -347,6 +347,12 @@
 	slow_pthread_self=
 	can_unwind_signal=yes
 	;;
+  *-*-rtems*)
+	libgcj_javaflags="${libgcj_javaflags} -fcheck-references"
+	can_unwind_signal=no
+	CHECKREFSPEC=-fcheck-references
+	DIVIDESPEC=-fuse-divide-subroutine
+	;;
 esac
 
 case "${host}" in
Index: libjava/configure.ac
===================================================================
--- libjava/configure.ac	(revision 172224)
+++ libjava/configure.ac	(working copy)
@@ -1048,6 +1048,19 @@
     ;;
  win32)
     ;;
+ rtems)
+    THREADS=posix
+    AC_DEFINE(HAVE_SYS_SOCKET_H, 1, [Required define in rtems.])
+    AC_DEFINE(HAVE_NETINET_IN_H, 1, [Required define in rtems.])
+    AC_DEFINE(HAVE_ARPA_INET_H, 1, [Required define in rtems.])
+    AC_DEFINE(HAVE_NETDB_H, 1, [Required define in rtems.])
+    AC_DEFINE(HAVE_SYS_IOCTL_H, 1, [Required define in rtems.])
+    AC_DEFINE(HAVE_NET_IF_H, 1, [Required define in rtems.])
+    AC_DEFINE(HAVE_IFADDRS_H, 1, [Required define in rtems.])
+    AC_DEFINE(HAVE_GETTIMEOFDAY, 1, [Required define in rtems.])
+    AC_DEFINE(HAVE_GETHOSTNAME_DECL, 1, [Required define in rtems.])
+    AC_DEFINE(RTEMS_PTHREADS, 1, [Required define in rtems.])
+    ;;
  decosf1 | irix | mach | os2 | dce | vxworks)
     AC_MSG_ERROR(thread package $THREADS not yet supported)
     ;;
Index: libjava/classpath/native/fdlibm/mprec.c
===================================================================
--- libjava/classpath/native/fdlibm/mprec.c	(revision 172224)
+++ libjava/classpath/native/fdlibm/mprec.c	(working copy)
@@ -1004,7 +1004,7 @@
 {1e-16, 1e-32};
 #endif
 
-
+#ifdef RTEMS_PTHREADS
 double
 _DEFUN (_mprec_log10, (dig),
 	int dig)
@@ -1019,3 +1019,4 @@
     }
   return v;
 }
+#endif
Index: libjava/include/config.h.in
===================================================================
--- libjava/include/config.h.in	(revision 172224)
+++ libjava/include/config.h.in	(working copy)
@@ -379,6 +379,9 @@
 /* Define if using POSIX threads on Linux. */
 #undef LINUX_THREADS
 
+/* Define if using POSIX threads on RTEMS. */
+#undef RTEMS_PTHREADS
+
 /* Define to the name of the environment variable that determines the dynamic
    library search path. */
 #undef LTDL_SHLIBPATH_VAR
Index: libjava/ChangeLog
===================================================================
--- libjava/ChangeLog	(revision 172224)
+++ libjava/ChangeLog	(working copy)
@@ -1,3 +1,13 @@
+2011-08-15  Jie Liu  <[email protected]>
+
+	* configure.ac (THREADS): Add configuration for RTEMS.
+	* configure.host (host): Add configuration for RTEMS.
+	* include/config.h.in: Add RTEMS_PTHREADS for RTEMS.
+	* configure: Add configure for RTEMS.
+	* classpath/native/fdlibm/mprec.c: Remove _mprec_log10 for RTEMS.
+	* posix-threads.cc: Use SIGHUP for INTR on RTEMS.
+	* java/lang/natClass.cc: Undef HAVE_TLS for RTEMS.
+
 2011-04-08  Kai Tietz  <[email protected]>
 
 	* configure.ac (libgcj_ld_export_all): Set for windows
Index: libjava/posix-threads.cc
===================================================================
--- libjava/posix-threads.cc	(revision 172224)
+++ libjava/posix-threads.cc	(working copy)
@@ -62,9 +62,11 @@
 static int non_daemon_count;
 
 // The signal to use when interrupting a thread.
-#if defined(LINUX_THREADS) || defined(FREEBSD_THREADS)
+#if defined(LINUX_THREADS) || defined(FREEBSD_THREADS) \
+    || defined(RTEMS_PTHREADS)
   // LinuxThreads (prior to glibc 2.1) usurps both SIGUSR1 and SIGUSR2.
   // GC on FreeBSD uses both SIGUSR1 and SIGUSR2.
+  // GC on  RTEMS  uses both SIGUSR1 and SIGUSR2.
 #  define INTR SIGHUP
 #else /* LINUX_THREADS */
 #  define INTR SIGUSR2
Index: libjava/configure
===================================================================
--- libjava/configure	(revision 172224)
+++ libjava/configure	(working copy)
@@ -20704,6 +20704,20 @@
     ;;
  win32)
     ;;
+ rtems)
+    THREADS=posix
+$as_echo "#define HAVE_SYS_SOCKET_H 1" >>confdefs.h
+$as_echo "#define HAVE_NETINET_IN_H 1" >>confdefs.h
+$as_echo "#define HAVE_ARPA_INET_H 1" >>confdefs.h
+$as_echo "#define HAVE_NETDB_H 1" >>confdefs.h
+$as_echo "#define HAVE_SYS_IOCTL_H 1" >>confdefs.h
+$as_echo "#define HAVE_NET_IF_H 1" >>confdefs.h
+$as_echo "#define HAVE_IFADDRS_H 1" >>confdefs.h
+$as_echo "#define HAVE_GETTIMEOFDAY 1" >>confdefs.h
+$as_echo "#define HAVE_GETHOSTNAME_DECL 1" >>confdefs.h
+$as_echo "#define HAVE_MPREC_LOG10 1" >>confdefs.h
+$as_echo "#define RTEMS_PTHREADS 1" >>confdefs.h
+    ;;
  decosf1 | irix | mach | os2 | dce | vxworks)
     as_fn_error "thread package $THREADS not yet supported" "$LINENO" 5
     ;;
Index: libjava/java/lang/natClass.cc
===================================================================
--- libjava/java/lang/natClass.cc	(revision 172224)
+++ libjava/java/lang/natClass.cc	(working copy)
@@ -1679,6 +1679,10 @@
   return NULL;
 }
 
+#ifdef RTEMS_PTHREADS
+# undef HAVE_TLS
+#endif
+
 #ifdef HAVE_TLS
 
 // NOTE: MCACHE_SIZE should be a power of 2 minus one.
Index: configure
===================================================================
--- configure	(revision 172224)
+++ configure	(working copy)
@@ -3176,7 +3176,7 @@
     noconfigdirs="$noconfigdirs target-newlib target-libgloss ${libgcj}"
     ;;
   *-*-rtems*)
-    noconfigdirs="$noconfigdirs target-libgloss ${libgcj}"
+    noconfigdirs="$noconfigdirs target-libgloss"
     ;;
     # The tpf target doesn't support gdb yet.
   *-*-tpf*)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.