gcc/libstdc++-v3/include/pstl
Nathaniel Shead 6a4d1c374e libgcc, libstdc++: Make declarations no longer TU-local [PR115126]
In C++20, modules streaming check for exposures of TU-local entities.
In general exposing internal linkage functions in a header is liable to
cause ODR violations in C++, and this is now detected in a module
context.

This patch goes through and removes 'static' from many declarations
exposed through libstdc++ to prevent code like the following from
failing:

  export module M;
  extern "C++" {
    #include <bits/stdc++.h>
  }

Since gthreads is used from C as well, we need to choose whether to use
'inline' or 'static inline' depending on whether we're compiling for C
or C++ (since the semantics of 'inline' are different between the
languages).  Additionally we need to remove static global variables, so
we migrate these to function-local statics to avoid the ODR issues.

There doesn't seem to be a good workaround for weakrefs, so I've left
them as-is and will work around it in the modules streaming code to
consider them as not TU-local.

The same issue occurs in the objective-C specific parts of gthreads, but
I'm not familiar with the surrounding context and we don't currently
test modules with Objective C++ anyway so I've left it as-is.

	PR libstdc++/115126

libgcc/ChangeLog:

	* gthr-posix.h (__GTHREAD_ALWAYS_INLINE): New macro.
	(__GTHREAD_INLINE): New macro.
	(__gthread_active): Convert from variable to (hidden) function.
	(__gthread_active_p): Mark as __GTHREAD_INLINE instead of
	static; make visibility("hidden") when it has a static local
	variable.
	(__gthread_trigger): Mark as __GTHREAD_INLINE instead of static.
	(__gthread_create): Likewise.
	(__gthread_join): Likewise.
	(__gthread_detach): Likewise.
	(__gthread_equal): Likewise.
	(__gthread_self): Likewise.
	(__gthread_yield): Likewise.
	(__gthread_once): Likewise.
	(__gthread_key_create): Likewise.
	(__gthread_key_delete): Likewise.
	(__gthread_getspecific): Likewise.
	(__gthread_setspecific): Likewise.
	(__gthread_mutex_init_function): Likewise.
	(__gthread_mutex_destroy): Likewise.
	(__gthread_mutex_lock): Likewise.
	(__gthread_mutex_trylock): Likewise.
	(__gthread_mutex_timedlock): Likewise.
	(__gthread_mutex_unlock): Likewise.
	(__gthread_recursive_mutex_init_function): Likewise.
	(__gthread_recursive_mutex_lock): Likewise.
	(__gthread_recursive_mutex_trylock): Likewise.
	(__gthread_recursive_mutex_timedlock): Likewise.
	(__gthread_recursive_mutex_unlock): Likewise.
	(__gthread_recursive_mutex_destroy): Likewise.
	(__gthread_cond_init_function): Likewise.
	(__gthread_cond_broadcast): Likewise.
	(__gthread_cond_signal): Likewise.
	(__gthread_cond_wait): Likewise.
	(__gthread_cond_timedwait): Likewise.
	(__gthread_cond_wait_recursive): Likewise.
	(__gthread_cond_destroy): Likewise.
	(__gthread_rwlock_rdlock): Likewise.
	(__gthread_rwlock_tryrdlock): Likewise.
	(__gthread_rwlock_wrlock): Likewise.
	(__gthread_rwlock_trywrlock): Likewise.
	(__gthread_rwlock_unlock): Likewise.
	* gthr-single.h: (__GTHREAD_ALWAYS_INLINE): New macro.
	(__GTHREAD_INLINE): New macro.
	(__gthread_active_p): Mark as __GTHREAD_INLINE instead of static.
	(__gthread_once): Likewise.
	(__gthread_key_create): Likewise.
	(__gthread_key_delete): Likewise.
	(__gthread_getspecific): Likewise.
	(__gthread_setspecific): Likewise.
	(__gthread_mutex_destroy): Likewise.
	(__gthread_mutex_lock): Likewise.
	(__gthread_mutex_trylock): Likewise.
	(__gthread_mutex_unlock): Likewise.
	(__gthread_recursive_mutex_lock): Likewise.
	(__gthread_recursive_mutex_trylock): Likewise.
	(__gthread_recursive_mutex_unlock): Likewise.
	(__gthread_recursive_mutex_destroy): Likewise.

libstdc++-v3/ChangeLog:

	* include/bits/shared_ptr.h (std::__is_shared_ptr): Remove
	unnecessary 'static'.
	* include/bits/unique_ptr.h (std::__is_unique_ptr): Likewise.
	* include/std/future (std::__create_task_state): Likewise.
	* include/std/shared_mutex (_GLIBCXX_GTRHW): Likewise.
	(__glibcxx_rwlock_init): Likewise.
	(__glibcxx_rwlock_timedrdlock): Likewise.
	(__glibcxx_rwlock_timedwrlock): Likewise.
	(__glibcxx_rwlock_rdlock): Likewise.
	(__glibcxx_rwlock_tryrdlock): Likewise.
	(__glibcxx_rwlock_wrlock): Likewise.
	(__glibcxx_rwlock_trywrlock): Likewise.
	(__glibcxx_rwlock_unlock): Likewise.
	(__glibcxx_rwlock_destroy): Likewise.
	(__glibcxx_rwlock_init): Likewise.
	* include/pstl/algorithm_impl.h
	(__pstl::__internal::__set_algo_cut_off): Mark inline.
	* include/pstl/unseq_backend_simd.h
	(__pstl::__unseq_backend::__lane_size): Mark inline.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Reviewed-by: Jakub Jelinek <jakub@redhat.com>
2024-09-27 09:16:53 +10:00
..
algorithm_fwd.h
algorithm_impl.h libgcc, libstdc++: Make declarations no longer TU-local [PR115126] 2024-09-27 09:16:53 +10:00
execution_defs.h
execution_impl.h libstdc++: Make PSTL algorithms accept C++20 iterators [PR110512] 2024-09-15 16:15:22 +01:00
glue_algorithm_defs.h libstdc++: add default template parameters to algorithms 2024-09-22 17:45:05 +01:00
glue_algorithm_impl.h
glue_execution_defs.h
glue_memory_defs.h
glue_memory_impl.h
glue_numeric_defs.h
glue_numeric_impl.h
LICENSE.txt
memory_impl.h
numeric_fwd.h
numeric_impl.h
parallel_backend_serial.h
parallel_backend_tbb.h
parallel_backend_utils.h
parallel_backend.h
parallel_impl.h
pstl_config.h
unseq_backend_simd.h libgcc, libstdc++: Make declarations no longer TU-local [PR115126] 2024-09-27 09:16:53 +10:00
utils.h