From 5f3498428e0e515dad7a7a505ec5fec9df681307 Mon Sep 17 00:00:00 2001 From: GNU Libc Maintainers Date: Sun, 3 Jul 2016 19:59:34 +0000 Subject: [PATCH] unsubmitted-libc_alloca_cutoff =================================================================== Gbp-Pq: Topic hurd-i386 Gbp-Pq: Name unsubmitted-libc_alloca_cutoff.diff --- libpthread/Makefile | 2 +- libpthread/Versions | 1 + libpthread/pthread/alloca_cutoff.c | 7 +++++++ sysdeps/pthread/allocalim.h | 7 +++++-- 4 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 libpthread/pthread/alloca_cutoff.c diff --git a/libpthread/Makefile b/libpthread/Makefile index 29067885e..b42bf3922 100644 --- a/libpthread/Makefile +++ b/libpthread/Makefile @@ -191,7 +191,7 @@ headers := \ ifeq ($(IN_GLIBC),yes) distribute := -routines := forward libc_pthread_init +routines := forward libc_pthread_init alloca_cutoff shared-only-routines = forward vpath %.c diff --git a/libpthread/Versions b/libpthread/Versions index 0cec436e6..0c6616b27 100644 --- a/libpthread/Versions +++ b/libpthread/Versions @@ -36,6 +36,7 @@ libc { __pthread_get_cleanup_stack; } GLIBC_PRIVATE { + __libc_alloca_cutoff; __libc_pthread_init; __register_atfork; } diff --git a/libpthread/pthread/alloca_cutoff.c b/libpthread/pthread/alloca_cutoff.c new file mode 100644 index 000000000..8e7f95b77 --- /dev/null +++ b/libpthread/pthread/alloca_cutoff.c @@ -0,0 +1,7 @@ +#include +int +__libc_alloca_cutoff (size_t size) +{ + return size <= 4096; +} +libc_hidden_def (__libc_alloca_cutoff) diff --git a/sysdeps/pthread/allocalim.h b/sysdeps/pthread/allocalim.h index 076889463..3d43d2a00 100644 --- a/sysdeps/pthread/allocalim.h +++ b/sysdeps/pthread/allocalim.h @@ -24,6 +24,9 @@ extern __always_inline int __libc_use_alloca (size_t size) { - return (__builtin_expect (size <= PTHREAD_STACK_MIN / 4, 1) - || __builtin_expect (__libc_alloca_cutoff (size), 1)); + return ( +#ifdef PTHREAD_STACK_MIN + __builtin_expect (size <= PTHREAD_STACK_MIN / 4, 1) || +#endif + __builtin_expect (__libc_alloca_cutoff (size), 1)); } -- 2.30.2