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.
This commit is contained in:
Alexandre Oliva
2026-03-25 06:45:47 -03:00
committed by Alexandre Oliva
parent e3419bfd79
commit aadc863a1f

View File

@@ -62,6 +62,25 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#include <errnoLib.h>
/* For C++ modules that end up calling gthr functions, we need the symbols to
have global linkage, so static inline won't do, see
e.g. g++.dg/module/xtreme-headers-8.C. Making them always_inline in C++
brings about higher but similar inlinability as static inline in C. */
#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 +150,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 +158,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 +166,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 +174,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 +182,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 +193,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 +202,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 +372,7 @@ extern __gthread_t __gthread_self (void);
#endif /* not _LIBOBJC */
#undef __GTHREAD_INLINE
#undef __GTHREAD_ALWAYS_INLINE
#endif /* gthr-vxworks.h */