This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] gthr-posix / fix threading support on FreeBSD


This simple patch replicates what we have been doing for Solaris for
a while.

FreeBSD requires similar treatment, and in fact the FreeBSD system
compiler has had this patch for a bit.  Without this patch, default
scripts and Makefiles will fail on FreeBSD.

I've Tested an earlier version of this patch on i386-unknown-freebsd6.2 
without regressions (all languages except for Ada and libgcj) and am 
testing a slightly tweaked one right now.

I'm asking for review and permission to apply this to HEAD and the 4.3 
branch, ideally also to older release branches after a bit.

Gerald


2008-04-17  Marius Strobl <marius@FreeBSD.org>

	* gthr-posix.h (__gthread_active_p): Use the Solaris implementation
	for FreeBSD as well.
	* gthr-posix95.h: Likewise.

Index: gthr-posix.h
===================================================================
--- gthr-posix.h	(revision 134333)
+++ gthr-posix.h	(working copy)
@@ -158,9 +158,12 @@
    it is passed so we cannot pretend that the interface is active if -pthreads
    is not specified.  On Solaris 2.5.1, the interface is not exposed at all so
    we need to play the usual game with weak symbols.  On Solaris 10 and up, a
-   working interface is always exposed.  */
+   working interface is always exposed.  On FreeBSD 6 and later, libc also
+   exposes a dummy POSIX threads interface, similar to what Solaris 2.6 up
+   to 9 does.  FreeBSD >= 700014 even provides a pthread_cancel stub in libc,
+   which means the alternate __gthread_active_p below cannot be used there.  */
 
-#if defined(__sun) && defined(__svr4__)
+#if defined(__FreeBSD__) || (defined(__sun) && defined(__svr4__))
 
 static volatile int __gthread_active = -1;
 
@@ -203,7 +206,7 @@
   return __gthread_active_latest_value != 0;
 }
 
-#else /* not Solaris */
+#else /* neither FreeBSD nor Solaris */
 
 static inline int
 __gthread_active_p (void)
@@ -213,7 +216,7 @@
   return __gthread_active_ptr != 0;
 }
 
-#endif /* Solaris */
+#endif /* FreeBSD or Solaris */
 
 #else /* not SUPPORTS_WEAK */
 
Index: gthr-posix95.h
===================================================================
--- gthr-posix95.h	(revision 134333)
+++ gthr-posix95.h	(working copy)
@@ -121,9 +121,12 @@
    it is passed so we cannot pretend that the interface is active if -pthreads
    is not specified.  On Solaris 2.5.1, the interface is not exposed at all so
    we need to play the usual game with weak symbols.  On Solaris 10 and up, a
-   working interface is always exposed.  */
+   working interface is always exposed.  On FreeBSD 6 and later, libc also
+   exposes a dummy POSIX threads interface, similar to what Solaris 2.6 up
+   to 9 does.  FreeBSD >= 700014 even provides a pthread_cancel stub in libc,
+   which means the alternate __gthread_active_p below cannot be used there.  */
 
-#if defined(__sun) && defined(__svr4__)
+#if defined(__FreeBSD__) || (defined(__sun) && defined(__svr4__))
 
 static volatile int __gthread_active = -1;
 
@@ -166,7 +169,7 @@
   return __gthread_active_latest_value != 0;
 }
 
-#else /* not Solaris */
+#else /* neither FreeBSD nor Solaris */
 
 static inline int
 __gthread_active_p (void)
@@ -176,7 +179,7 @@
   return __gthread_active_ptr != 0;
 }
 
-#endif /* Solaris */
+#endif /* FreeBSD or Solaris */
 
 #else /* not SUPPORTS_WEAK */
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]