[23/23] nptl: Move semi-public __pthread_get_minstack symbol into libc
Checks
Commit Message
No abilist updates here because it is a GLIBC_PRIVATE symbol.
It's also necessary to move nptl_version into pthread_create, so
that it still ends up in static binaries.
---
nptl/Versions | 2 +-
nptl/nptl-init.c | 19 -------------------
nptl/nptl-stack.c | 17 +++++++++++++++++
nptl/pthreadP.h | 1 +
nptl/pthread_create.c | 4 ++++
5 files changed, 23 insertions(+), 20 deletions(-)
Comments
On 12/05/2021 13:59, Florian Weimer via Libc-alpha wrote:
> No abilist updates here because it is a GLIBC_PRIVATE symbol.
>
> It's also necessary to move nptl_version into pthread_create, so
> that it still ends up in static binaries.
LGTM, thanks.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
> ---
> nptl/Versions | 2 +-
> nptl/nptl-init.c | 19 -------------------
> nptl/nptl-stack.c | 17 +++++++++++++++++
> nptl/pthreadP.h | 1 +
> nptl/pthread_create.c | 4 ++++
> 5 files changed, 23 insertions(+), 20 deletions(-)
>
> diff --git a/nptl/Versions b/nptl/Versions
> index 2097e517ae..016a9bef09 100644
> --- a/nptl/Versions
> +++ b/nptl/Versions
> @@ -408,6 +408,7 @@ libc {
> __pthread_disable_asynccancel;
> __pthread_enable_asynccancel;
> __pthread_force_elision;
> + __pthread_get_minstack;
> __pthread_getattr_default_np;
> __pthread_getattr_default_np;
> __pthread_keys;
> @@ -510,7 +511,6 @@ libpthread {
> GLIBC_PRIVATE {
> __pthread_clock_gettime;
> __pthread_clock_settime;
> - __pthread_get_minstack;
> __pthread_initialize_minimal;
> }
> }
Ok.
> diff --git a/nptl/nptl-init.c b/nptl/nptl-init.c
> index 732e580355..5a460aedba 100644
> --- a/nptl/nptl-init.c
> +++ b/nptl/nptl-init.c
> @@ -38,28 +38,9 @@
> #include <pthread_mutex_conf.h>
> #include <nptl-stack.h>
>
> -/* Version of the library, used in libthread_db to detect mismatches. */
> -static const char nptl_version[] __attribute_used__ = VERSION;
> -
> void
> __pthread_initialize_minimal_internal (void)
> {
> }
> strong_alias (__pthread_initialize_minimal_internal,
> __pthread_initialize_minimal)
> -
> -
> -/* This function is internal (it has a GLIBC_PRIVATE) version, but it
> - is widely used (either via weak symbol, or dlsym) to obtain the
> - __static_tls_size value. This value is then used to adjust the
> - value of the stack size attribute, so that applications receive the
> - full requested stack size, not diminished by the TCB and static TLS
> - allocation on the stack. Once the TCB is separately allocated,
> - this function should be removed or renamed (if it is still
> - necessary at that point). */
> -size_t
> -__pthread_get_minstack (const pthread_attr_t *attr)
> -{
> - return (GLRO(dl_pagesize) + __nptl_tls_static_size_for_stack ()
> - + PTHREAD_STACK_MIN);
> -}
Ok.
> diff --git a/nptl/nptl-stack.c b/nptl/nptl-stack.c
> index 7853c105be..1a0c460ba8 100644
> --- a/nptl/nptl-stack.c
> +++ b/nptl/nptl-stack.c
> @@ -19,6 +19,7 @@
>
> #include <nptl-stack.h>
> #include <ldsodefs.h>
> +#include <pthreadP.h>
>
> /* Maximum size in kB of cache. 40MiBi by default. */
> static const size_t stack_cache_maxsize = 40 * 1024 * 1024;
> @@ -128,3 +129,19 @@ __nptl_deallocate_stack (struct pthread *pd)
> lll_unlock (GL (dl_stack_cache_lock), LLL_PRIVATE);
> }
> libc_hidden_def (__nptl_deallocate_stack)
> +
> +/* This function is internal (it has a GLIBC_PRIVATE) version, but it
> + is widely used (either via weak symbol, or dlsym) to obtain the
> + __static_tls_size value. This value is then used to adjust the
> + value of the stack size attribute, so that applications receive the
> + full requested stack size, not diminished by the TCB and static TLS
> + allocation on the stack. Once the TCB is separately allocated,
> + this function should be removed or renamed (if it is still
> + necessary at that point). */
> +size_t
> +__pthread_get_minstack (const pthread_attr_t *attr)
> +{
> + return (GLRO(dl_pagesize) + __nptl_tls_static_size_for_stack ()
> + + PTHREAD_STACK_MIN);
> +}
> +libc_hidden_def (__pthread_get_minstack)
Ok.
> diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h
> index 3e9da9c7ea..c6b82851bf 100644
> --- a/nptl/pthreadP.h
> +++ b/nptl/pthreadP.h
> @@ -340,6 +340,7 @@ extern unsigned long int __fork_generation attribute_hidden;
> extern unsigned long int *__fork_generation_pointer attribute_hidden;
>
> extern size_t __pthread_get_minstack (const pthread_attr_t *attr);
> +libc_hidden_proto (__pthread_get_minstack)
>
> /* Namespace save aliases. */
> extern int __pthread_getschedparam (pthread_t thread_id, int *policy,
Ok.
> diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c
> index 43f3722f57..220edda917 100644
> --- a/nptl/pthread_create.c
> +++ b/nptl/pthread_create.c
> @@ -36,6 +36,7 @@
> #include <tls-setup.h>
> #include "libioP.h"
> #include <sys/single_threaded.h>
> +#include <version.h>
>
> #include <shlib-compat.h>
>
> @@ -56,6 +57,9 @@ static struct rtld_global *__nptl_rtld_global __attribute_used__
> = &_rtld_global;
> #endif
>
> +/* Version of the library, used in libthread_db to detect mismatches. */
> +static const char nptl_version[] __attribute_used__ = VERSION;
> +
> /* Code to allocate and deallocate a stack. */
> #include "allocatestack.c"
>
>
Ok.
@@ -408,6 +408,7 @@ libc {
__pthread_disable_asynccancel;
__pthread_enable_asynccancel;
__pthread_force_elision;
+ __pthread_get_minstack;
__pthread_getattr_default_np;
__pthread_getattr_default_np;
__pthread_keys;
@@ -510,7 +511,6 @@ libpthread {
GLIBC_PRIVATE {
__pthread_clock_gettime;
__pthread_clock_settime;
- __pthread_get_minstack;
__pthread_initialize_minimal;
}
}
@@ -38,28 +38,9 @@
#include <pthread_mutex_conf.h>
#include <nptl-stack.h>
-/* Version of the library, used in libthread_db to detect mismatches. */
-static const char nptl_version[] __attribute_used__ = VERSION;
-
void
__pthread_initialize_minimal_internal (void)
{
}
strong_alias (__pthread_initialize_minimal_internal,
__pthread_initialize_minimal)
-
-
-/* This function is internal (it has a GLIBC_PRIVATE) version, but it
- is widely used (either via weak symbol, or dlsym) to obtain the
- __static_tls_size value. This value is then used to adjust the
- value of the stack size attribute, so that applications receive the
- full requested stack size, not diminished by the TCB and static TLS
- allocation on the stack. Once the TCB is separately allocated,
- this function should be removed or renamed (if it is still
- necessary at that point). */
-size_t
-__pthread_get_minstack (const pthread_attr_t *attr)
-{
- return (GLRO(dl_pagesize) + __nptl_tls_static_size_for_stack ()
- + PTHREAD_STACK_MIN);
-}
@@ -19,6 +19,7 @@
#include <nptl-stack.h>
#include <ldsodefs.h>
+#include <pthreadP.h>
/* Maximum size in kB of cache. 40MiBi by default. */
static const size_t stack_cache_maxsize = 40 * 1024 * 1024;
@@ -128,3 +129,19 @@ __nptl_deallocate_stack (struct pthread *pd)
lll_unlock (GL (dl_stack_cache_lock), LLL_PRIVATE);
}
libc_hidden_def (__nptl_deallocate_stack)
+
+/* This function is internal (it has a GLIBC_PRIVATE) version, but it
+ is widely used (either via weak symbol, or dlsym) to obtain the
+ __static_tls_size value. This value is then used to adjust the
+ value of the stack size attribute, so that applications receive the
+ full requested stack size, not diminished by the TCB and static TLS
+ allocation on the stack. Once the TCB is separately allocated,
+ this function should be removed or renamed (if it is still
+ necessary at that point). */
+size_t
+__pthread_get_minstack (const pthread_attr_t *attr)
+{
+ return (GLRO(dl_pagesize) + __nptl_tls_static_size_for_stack ()
+ + PTHREAD_STACK_MIN);
+}
+libc_hidden_def (__pthread_get_minstack)
@@ -340,6 +340,7 @@ extern unsigned long int __fork_generation attribute_hidden;
extern unsigned long int *__fork_generation_pointer attribute_hidden;
extern size_t __pthread_get_minstack (const pthread_attr_t *attr);
+libc_hidden_proto (__pthread_get_minstack)
/* Namespace save aliases. */
extern int __pthread_getschedparam (pthread_t thread_id, int *policy,
@@ -36,6 +36,7 @@
#include <tls-setup.h>
#include "libioP.h"
#include <sys/single_threaded.h>
+#include <version.h>
#include <shlib-compat.h>
@@ -56,6 +57,9 @@ static struct rtld_global *__nptl_rtld_global __attribute_used__
= &_rtld_global;
#endif
+/* Version of the library, used in libthread_db to detect mismatches. */
+static const char nptl_version[] __attribute_used__ = VERSION;
+
/* Code to allocate and deallocate a stack. */
#include "allocatestack.c"