]> granicus.if.org Git - gc/commitdiff
Support multi-threading for RTEMS target.
authorJie Liu <lj8175@gmail.com>
Fri, 9 Sep 2011 14:21:49 +0000 (18:21 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Fri, 9 Sep 2011 14:21:49 +0000 (18:21 +0400)
(Apply commit e773036)

* configure.ac: Add GC_RTEMS_PTHREADS AH_TEMPLATE and configure
for rtems.
* os_dep.c: Add GC_get_stack_base if GC_RTEMS_PTHREADS for rtems.
* pthread_stop_world.c (GC_stop_init): Add ifdef SA_RESTART.
* pthread_stop_world.c (GC_stop_init): Use sigprocmask for rtems
when defined GC_RTEMS_PTHREADS.
* pthread_support.c: Exclude sys/mman.h for rtems.
* pthread_support.c (GC_thr_init): Set default GC_nprocs (1) for
rtems.
* include/gc_config_macros.h: Define GC_RTEMS_PTHREADS for rtems
pthread and define GC_NO_DLOPEN for rtems.
* include/private/gc_locks.h: Define USE_PTHREAD_LOCKS for rtems.
* include/private/gcconfig.h: Use rtems_get_stack_bottom()
for InitStackBottom; and use SIGUSR1 for SIG_SUSPEND, SIGUSR2
for SIG_THR_RESTART on rtems.
* include/private/thread_local_alloc.h: Use USE_PTHREAD_SPECIFIC
for rtems.
* tests/test.c (Init): Use exit(0) for rtems instead of return.
* configure: Regenerate.
* include/private/config.h.in: Ditto.

12 files changed:
ChangeLog
configure
configure.ac
include/gc_config_macros.h
include/private/config.h.in
include/private/gc_locks.h
include/private/gcconfig.h
include/private/thread_local_alloc.h
os_dep.c
pthread_stop_world.c
pthread_support.c
tests/test.c

index a96ab00000d6951a4cc82aaa8b0261562019c4bd..9021db94e20c7aa43da3e1a9f9c632752ffb102b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2011-08-09  Ivan Maidanski <ivmai@mail.ru> (really Jie Liu)
+
+       * configure.ac: Add GC_RTEMS_PTHREADS AH_TEMPLATE and configure
+       for rtems.
+       * os_dep.c: Add GC_get_stack_base if GC_RTEMS_PTHREADS for rtems.
+       * pthread_stop_world.c (GC_stop_init): Add ifdef SA_RESTART.
+       * pthread_stop_world.c (GC_stop_init): Use sigprocmask for rtems
+       when defined GC_RTEMS_PTHREADS.
+       * pthread_support.c: Exclude sys/mman.h for rtems.
+       * pthread_support.c (GC_thr_init): Set default GC_nprocs (1) for
+       rtems.
+       * include/gc_config_macros.h: Define GC_RTEMS_PTHREADS for rtems
+       pthread and define GC_NO_DLOPEN for rtems.
+       * include/private/gc_locks.h: Define USE_PTHREAD_LOCKS for rtems.
+       * include/private/gcconfig.h: Use rtems_get_stack_bottom()
+       for InitStackBottom; and use SIGUSR1 for SIG_SUSPEND, SIGUSR2
+       for SIG_THR_RESTART on rtems.
+       * include/private/thread_local_alloc.h: Use USE_PTHREAD_SPECIFIC
+       for rtems.
+       * tests/test.c (Init): Use exit(0) for rtems instead of return.
+       * configure: Regenerate.
+       * include/private/config.h.in: Ditto.
+
 2011-07-26  Ivan Maidanski <ivmai@mail.ru>
 
        * tests/realloc_test.c: New file.
index 7f975b409cd3d3da1aa4ecd0e725de0f5b7093db..dab24e1f4340718fc0766380f58865823513afb0 100755 (executable)
--- a/configure
+++ b/configure
@@ -4968,6 +4968,7 @@ fi
 
 
 
+
 
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5
@@ -5292,6 +5293,13 @@ $as_echo "#define DGUX_THREADS 1" >>confdefs.h
 
     $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 | solaris | dce | vxworks)
     as_fn_error $? "thread package $THREADS not yet supported" "$LINENO" 5
index f25d0216dd4b862ef3a8176670e2600b2caa1b44..d0d6e3fccef82f2f3ffe07b1b4db2cc65fe3a8da 100644 (file)
@@ -93,6 +93,7 @@ AH_TEMPLATE([GC_OSF1_THREADS],      [Define to support Tru64 pthreads.])
 AH_TEMPLATE([GC_SOLARIS_THREADS],   [Define to support Solaris pthreads.])
 AH_TEMPLATE([GC_WIN32_THREADS],     [Define to support Win32 threads.])
 AH_TEMPLATE([GC_WIN32_PTHREADS],    [Define to support win32-pthreads.])
+AH_TEMPLATE([GC_RTEMS_PTHREADS],    [Define to support rtems-pthreads.])
 
 dnl System header feature requests.
 AH_TEMPLATE([_POSIX_C_SOURCE], [The POSIX feature macro.])
@@ -280,6 +281,11 @@ case "$THREADS" in
     AC_DEFINE(GC_AIX_THREADS)
     AC_DEFINE(_REENTRANT)
     ;;
+ rtems)
+    THREADS=posix
+    AC_DEFINE(GC_RTEMS_PTHREADS)
+    AC_DEFINE(THREAD_LOCAL_ALLOC)
+    ;;
  decosf1 | irix | mach | os2 | solaris | dce | vxworks)
     AC_MSG_ERROR(thread package $THREADS not yet supported)
     ;;
index a27f8dd7a1db8ef440c4e5cea1e51d007a669991..73db584f87c1a273db1ab6de8afd43ad4de85720 100644 (file)
@@ -50,6 +50,9 @@
 #if defined(WIN32_THREADS)
 # define GC_WIN32_THREADS
 #endif
+#if defined(RTEMS_THREADS)
+# define GC_RTEMS_PTHREADS
+#endif
 #if defined(USE_LD_WRAP)
 # define GC_USE_LD_WRAP
 #endif
@@ -65,7 +68,7 @@
     || defined(GC_IRIX_THREADS) || defined(GC_LINUX_THREADS) \
     || defined(GC_NETBSD_THREADS) || defined(GC_OPENBSD_THREADS) \
     || defined(GC_OSF1_THREADS) || defined(GC_SOLARIS_THREADS) \
-    || defined(GC_WIN32_THREADS)
+    || defined(GC_WIN32_THREADS) || defined(GC_RTEMS_PTHREADS)
 # ifndef GC_THREADS
 #   define GC_THREADS
 # endif
     /* Either posix or native Win32 threads. */
 #   define GC_WIN32_THREADS
 # endif
+# if defined(__rtems__) && (defined(i386) || defined(__i386__))
+#   define GC_RTEMS_PTHREADS
+# endif
 #endif /* GC_THREADS */
 
 #undef GC_PTHREADS
 #if (!defined(GC_WIN32_THREADS) || defined(GC_WIN32_PTHREADS) \
-     || defined(__CYGWIN32__) || defined(__CYGWIN__)) && defined(GC_THREADS)
+     || defined(GC_RTEMS_PTHREADS) || defined(__CYGWIN32__) \
+     || defined(__CYGWIN__)) && defined(GC_THREADS)
   /* Posix threads. */
 # define GC_PTHREADS
 #endif
 #ifdef GC_PTHREADS
 
 # if (defined(GC_DARWIN_THREADS) || defined(GC_WIN32_PTHREADS) \
-      || defined(__native_client__)) && !defined(GC_NO_DLOPEN)
+      || defined(__native_client__) || defined(GC_RTEMS_PTHREADS)) \
+      && !defined(GC_NO_DLOPEN)
     /* Either there is no dlopen() or we do not need to intercept it.   */
 #   define GC_NO_DLOPEN
 # endif
index a14c0f3451dfee93d58b19c2a54e3e73cfa90a4b..50b2004cf0cdf2854b011242e63f74826aa66df0 100644 (file)
@@ -66,6 +66,9 @@
 /* Define to support Tru64 pthreads. */
 #undef GC_OSF1_THREADS
 
+/* Define to support rtems-pthreads. */
+#undef GC_RTEMS_PTHREADS
+
 /* Define to support Solaris pthreads. */
 #undef GC_SOLARIS_THREADS
 
index 113b4aeae5aad1689532e82d16c117d69fc4dbc7..a5d9c35fc39355389b084b9f37a90774481d452c 100644 (file)
 #    define USE_PTHREAD_LOCKS
 #  endif
 
+#  if defined(GC_RTEMS_PTHREADS)
+#    define USE_PTHREAD_LOCKS
+#  endif
+
 #  if defined(GC_WIN32_THREADS) && !defined(USE_PTHREAD_LOCKS)
 #    ifndef WIN32_LEAN_AND_MEAN
 #      define WIN32_LEAN_AND_MEAN 1
index a3600f11200a3115867828e44bb4983feb5e979e..553f4087067ea09393a7d35fa2cbaec982ebe936 100644 (file)
 #       include <sys/unistd.h>
         extern int etext[];
         extern int end[];
-        extern void *InitStackBottom;
+        void *rtems_get_stack_bottom(void);
+#       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"
index 55d8fd6e03171aaedf6d4ca68043c8a119eaa605..68d6d88bfa830ce9a7f6671918d7871ba525cfa6 100644 (file)
@@ -47,7 +47,7 @@
 #   define USE_COMPILER_TLS
 # elif defined(GC_DGUX386_THREADS) || defined(GC_OSF1_THREADS) \
        || defined(GC_DARWIN_THREADS) || defined(GC_AIX_THREADS) \
-       || defined(GC_NETBSD_THREADS)
+       || defined(GC_NETBSD_THREADS) || defined(GC_RTEMS_PTHREADS)
 #   define USE_PTHREAD_SPECIFIC
 # elif defined(GC_HPUX_THREADS)
 #   ifdef __GNUC__
index 2d73340ad0f0fd4c86cbea3ce89b1665752fa46e..3cc6fff4d591848f9f3dc69eae6d91432a04a772 100644 (file)
--- a/os_dep.c
+++ b/os_dep.c
@@ -1351,6 +1351,15 @@ GC_INNER word GC_page_size = 0;
 # define HAVE_GET_STACK_BASE
 #endif /* GC_SOLARIS_THREADS */
 
+#ifdef GC_RTEMS_PTHREADS
+  GC_API int GC_CALL GC_get_stack_base(struct GC_stack_base *sb)
+  {
+    sb->mem_base = rtems_get_stack_bottom();
+    return GC_SUCCESS;
+  } 
+# define HAVE_GET_STACK_BASE
+#endif /* GC_RTEMS_PTHREADS */
+
 #ifndef HAVE_GET_STACK_BASE
   /* Retrieve stack base.                                               */
   /* Using the GC_find_limit version is risky.                          */
index 9302f93f6ed7c80b1cbaef213dd34259089dc9b8..fa4e4d5f41e06fb25e0d02dce8cee3a47d44a9e4 100644 (file)
@@ -816,14 +816,23 @@ GC_INNER void GC_stop_init(void)
         ABORT("sem_init failed");
 #   endif
 
-    act.sa_flags = SA_RESTART
+#   ifdef SA_RESTART
+      act.sa_flags = SA_RESTART
+#   else
+      act.sa_flags = 0
+#   endif
 #   ifdef SA_SIGINFO
-        | SA_SIGINFO
+                     | SA_SIGINFO
 #   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");
+      }
+#   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 bcdfebd1437f978d6deef27a55b83a0b6462a7e3..873177550573ffe7f599d2e1188318b9e339004e 100644 (file)
@@ -52,7 +52,9 @@
 # include <time.h>
 # include <errno.h>
 # include <unistd.h>
-# include <sys/mman.h>
+# if !defined(GC_RTEMS_PTHREADS)
+#   include <sys/mman.h>
+# endif
 # include <sys/time.h>
 # include <sys/types.h>
 # include <sys/stat.h>
@@ -953,6 +955,8 @@ GC_INNER void GC_thr_init(void)
       GC_nprocs = get_ncpu();
 #   elif defined(GC_LINUX_THREADS) || defined(GC_DGUX386_THREADS)
       GC_nprocs = GC_get_nprocs();
+#   elif defined(GC_RTEMS_PTHREADS)
+      GC_nprocs = 1; /* not implemented */
 #   endif
   }
   if (GC_nprocs <= 0) {
index fa2eda170df0cc7d6e0befcbfa0a5c90376f5130..2800308b04dd7dfaf528ff2d8f0cb71c8427692c 100644 (file)
@@ -1462,7 +1462,11 @@ void GC_CALLBACK warn_proc(char *msg, GC_word p)
 #   ifdef MSWIN32
       GC_win32_free_heap();
 #   endif
-    return(0);
+#   ifdef RTEMS
+      exit(0);
+#   else
+      return(0);
+#   endif
 }
 # endif