unsubmitted-libc_alloca_cutoff
authorGNU Libc Maintainers <debian-glibc@lists.debian.org>
Sat, 17 Sep 2016 18:00:44 +0000 (18:00 +0000)
committerAurelien Jarno <aurel32@debian.org>
Sat, 17 Sep 2016 18:00:44 +0000 (18:00 +0000)
===================================================================

Gbp-Pq: Topic hurd-i386
Gbp-Pq: Name unsubmitted-libc_alloca_cutoff.diff

libpthread/Makefile
libpthread/Versions
libpthread/pthread/alloca_cutoff.c [new file with mode: 0644]
sysdeps/pthread/allocalim.h

index 29067885e91675dba4080800d2e3dcc8b8fc13b5..b42bf39227938f16164161bcb3c90ff7ef699fbe 100644 (file)
@@ -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
index 0c08cea97cf876755cb6097c24acad8d76e08ffc..75ef59df62343673c18dc94250eee3214274133c 100644 (file)
@@ -39,6 +39,7 @@ libc {
     __pthread_get_cleanup_stack;
   }
   GLIBC_PRIVATE {
+    __libc_alloca_cutoff;
     __libc_pthread_init;
   }
 }
diff --git a/libpthread/pthread/alloca_cutoff.c b/libpthread/pthread/alloca_cutoff.c
new file mode 100644 (file)
index 0000000..8e7f95b
--- /dev/null
@@ -0,0 +1,7 @@
+#include <alloca.h>
+int
+__libc_alloca_cutoff (size_t size)
+{
+       return size <= 4096;
+}
+libc_hidden_def (__libc_alloca_cutoff)
index 076889463b000b61e713d9165dc8a061195bdd1b..3d43d2a005c0adcaf22c6154434afeb7ed9bae21 100644 (file)
@@ -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));
 }