Linux: Consolidate typesizes.h
[glibc.git] / sysdeps / unix / sysv / linux / sysconf-pthread_stack_min.h
blob4a2c7afdea05640529434c2a073420c0a86683ba
1 /* __get_pthread_stack_min (). Linux version.
2 Copyright (C) 2021-2022 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
19 /* Return sysconf (_SC_THREAD_STACK_MIN). */
21 static inline long int
22 __get_pthread_stack_min (void)
24 /* sysconf (_SC_THREAD_STACK_MIN) >= sysconf (_SC_MINSIGSTKSZ). */
25 long int pthread_stack_min = GLRO(dl_minsigstacksize);
26 assert (pthread_stack_min != 0);
27 _Static_assert (__builtin_constant_p (PTHREAD_STACK_MIN),
28 "PTHREAD_STACK_MIN is constant");
29 /* Return MAX (PTHREAD_STACK_MIN, pthread_stack_min). */
30 if (pthread_stack_min < PTHREAD_STACK_MIN)
31 pthread_stack_min = PTHREAD_STACK_MIN;
32 /* We have a private interface, __pthread_get_minstack@GLIBC_PRIVATE
33 which returns a larger size that includes the required TLS variable
34 space which has been determined at startup. For sysconf here we are
35 conservative and don't include the space required for TLS access.
36 Eventually the TLS variable space will not be part of the stack
37 (Bug 11787). */
38 return pthread_stack_min;