https://gcc.gnu.org/g:714c84393a9f7b70836f4cab1148d447ca871f13

commit 714c84393a9f7b70836f4cab1148d447ca871f13
Author: Alexandre Oliva <[email protected]>
Date:   Fri Mar 13 00:30:18 2026 -0300

    vxworks: fix gthr visibility issues
    
    xtreme-header-8.C fails on VxWorks because various TU-local gthr
    functions defined as static inline are referenced from libstdc++
    symbols with global visibility.
    
    C++ modules require those functions to be non-static inline, and other
    gthr implementations adopt always_inline in C++.
    
    Follow this practice in gthr-vxworks.h as well.
    
    
    for  libgcc/ChangeLog
    
            * config/gthr-vxworks.h (__GTHREAD_ALWAYS_INLINE,
            __GTHREAD_INLINE): Copy from gthr-posix.h.  Replace static
            inline with __GTHREAD_INLINE.

Diff:
---
 libgcc/config/gthr-vxworks.h | 37 +++++++++++++++++++++++++++----------
 1 file changed, 27 insertions(+), 10 deletions(-)

diff --git a/libgcc/config/gthr-vxworks.h b/libgcc/config/gthr-vxworks.h
index d6d9b0dabf41..a822eaebfb60 100644
--- a/libgcc/config/gthr-vxworks.h
+++ b/libgcc/config/gthr-vxworks.h
@@ -62,6 +62,20 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If 
not, see
 
 #include <errnoLib.h>
 
+#ifdef __has_attribute
+# if __has_attribute(__always_inline__)
+#  define __GTHREAD_ALWAYS_INLINE __attribute__((__always_inline__))
+# endif
+#endif
+#ifndef __GTHREAD_ALWAYS_INLINE
+# define __GTHREAD_ALWAYS_INLINE
+#endif
+
+#ifdef __cplusplus
+# define __GTHREAD_INLINE inline __GTHREAD_ALWAYS_INLINE
+#else
+# define __GTHREAD_INLINE static inline
+#endif
 
 /* --------------------- Test & Set/Swap internal API --------------------- */
 
@@ -131,7 +145,7 @@ typedef SEM_ID __gthread_recursive_mutex_t;
 /* Non re-entrant mutex implementation. Libstdc++ expects the default
    gthread mutex to be non reentrant.  */
 
-static inline void
+__GTHREAD_INLINE void
 __gthread_mutex_init (__gthread_mutex_t * __mutex)
 {
   if (!__mutex)
@@ -139,7 +153,7 @@ __gthread_mutex_init (__gthread_mutex_t * __mutex)
   *__mutex = semBCreate (SEM_Q_PRIORITY, SEM_FULL);
 }
 
-static inline int
+__GTHREAD_INLINE int
 __gthread_mutex_destroy (__gthread_mutex_t * __mutex)
 {
   if (!__mutex)
@@ -147,7 +161,7 @@ __gthread_mutex_destroy (__gthread_mutex_t * __mutex)
   return __CHECK_RESULT (semDelete (*__mutex));
 }
 
-static inline int
+__GTHREAD_INLINE int
 __gthread_mutex_lock (__gthread_mutex_t * __mutex)
 {
   if (!__mutex)
@@ -155,7 +169,7 @@ __gthread_mutex_lock (__gthread_mutex_t * __mutex)
   return __CHECK_RESULT (semTake(*__mutex, WAIT_FOREVER));
 }
 
-static inline int
+__GTHREAD_INLINE int
 __gthread_mutex_trylock (__gthread_mutex_t * __mutex)
 {
   if (!__mutex)
@@ -163,7 +177,7 @@ __gthread_mutex_trylock (__gthread_mutex_t * __mutex)
   return __CHECK_RESULT (semTake (*__mutex, NO_WAIT));
 }
 
-static inline int
+__GTHREAD_INLINE int
 __gthread_mutex_unlock (__gthread_mutex_t * __mutex)
 {
   if (!__mutex)
@@ -174,7 +188,7 @@ __gthread_mutex_unlock (__gthread_mutex_t * __mutex)
 /* Recursive mutex implementation. The only change is that we use semMCreate()
    instead of semBCreate().  */
 
-static inline void
+__GTHREAD_INLINE void
 __gthread_recursive_mutex_init (__gthread_recursive_mutex_t * __mutex)
 {
   if (!__mutex)
@@ -183,25 +197,25 @@ __gthread_recursive_mutex_init 
(__gthread_recursive_mutex_t * __mutex)
     semMCreate (SEM_Q_PRIORITY | SEM_INVERSION_SAFE | SEM_DELETE_SAFE);
 }
 
-static inline int
+__GTHREAD_INLINE int
 __gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t * __mutex)
 {
   return __gthread_mutex_destroy (__mutex);
 }
 
-static inline int
+__GTHREAD_INLINE int
 __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t * __mutex)
 {
   return __gthread_mutex_lock (__mutex);
 }
 
-static inline int
+__GTHREAD_INLINE int
 __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t * __mutex)
 {
   return __gthread_mutex_trylock (__mutex);
 }
 
-static inline int
+__GTHREAD_INLINE int
 __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t * __mutex)
 {
   return __gthread_mutex_unlock (__mutex);
@@ -353,4 +367,7 @@ extern __gthread_t __gthread_self (void);
 
 #endif /* not _LIBOBJC */
 
+#undef __GTHREAD_INLINE
+#undef __GTHREAD_ALWAYS_INLINE
+
 #endif /* gthr-vxworks.h */

Reply via email to