Hi,

The patch attached changes the RTEMS thread model in GCC from 'rtems' to 'posix'. The patch also fixes the include paths for newlib so the correct 'machine/_types.h' is picked up.

RTEMS using the POSIX thread model in gcc means C++ works with SMP. The 'rtems' thread model uses an RTEMS specific interface to code in RTEMS that uses task variables. Task variables make no sense and will never work in SMP systems [1].

This patch leaves the RTEMS thread model in the gcc sources. A patch for gcc patches list would need to remove these sources.

Chris

[1] We should consider no building the task variable code when building an SMP kernel.
diff --git a/gcc/config.gcc b/gcc/config.gcc
index ef37e61..6e03865 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -763,7 +763,7 @@ case ${target} in
   ;;
 *-*-rtems*)
   case ${enable_threads} in
-    yes) thread_file='rtems' ;;
+    yes) thread_file='posix' ;;
   esac
   extra_options="${extra_options} rtems.opt"
   default_use_cxa_atexit=yes
diff --git a/libgcc/config/t-rtems b/libgcc/config/t-rtems
index 85f1da9..11e0c64 100644
--- a/libgcc/config/t-rtems
+++ b/libgcc/config/t-rtems
@@ -1,4 +1,4 @@
 # If we are building next to newlib, this will let us find the RTEMS
 # limits.h when building libgcc2.  Otherwise, newlib must be installed
 # first.
-LIBGCC2_INCLUDES = -I$(srcdir)/../newlib/libc/sys/rtems/include
+LIBGCC2_INCLUDES = -I$(srcdir)/../newlib/libc/sys/rtems/include 
-I$(srcdir)/../newlib/libc/sys/rtems
diff --git a/libgcc/gthr-posix.h b/libgcc/gthr-posix.h
index f0d8cd7..6c2e544 100644
--- a/libgcc/gthr-posix.h
+++ b/libgcc/gthr-posix.h
@@ -110,7 +110,9 @@ __gthrw(pthread_detach)
 #ifndef __BIONIC__
 __gthrw(pthread_cancel)
 #endif
+#ifndef __rtems__
 __gthrw(sched_yield)
+#endif
 
 __gthrw(pthread_mutex_lock)
 __gthrw(pthread_mutex_trylock)
@@ -447,8 +449,10 @@ __gthread_objc_thread_get_priority (void)
 static inline void
 __gthread_objc_thread_yield (void)
 {
+#ifndef __rtems__
   if (__gthread_active_p ())
     __gthrw_(sched_yield) ();
+#endif
 }
 
 /* Terminate the current thread.  */
@@ -689,7 +693,9 @@ __gthread_self (void)
 static inline int
 __gthread_yield (void)
 {
+#ifndef __rtems__
   return __gthrw_(sched_yield) ();
+#endif
 }
 
 static inline int
_______________________________________________
rtems-devel mailing list
[email protected]
http://www.rtems.org/mailman/listinfo/rtems-devel

Reply via email to