]> git.ipfire.org Git - thirdparty/glibc.git/blame - htl/pt-getattr.c
x86: In ld.so, diagnose missing APX support in APX-only builds
[thirdparty/glibc.git] / htl / pt-getattr.c
CommitLineData
33574c17 1/* Thread attributes retrieval.
dff8da6b 2 Copyright (C) 2008-2024 Free Software Foundation, Inc.
33574c17
ST
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
ad2b41bf
ST
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.
33574c17
ST
9
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
ad2b41bf 13 Lesser General Public License for more details.
33574c17 14
ad2b41bf
ST
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
5a82c748 17 <https://www.gnu.org/licenses/>. */
33574c17
ST
18
19#include <assert.h>
20#include <errno.h>
21#include <pthread.h>
22
23#include <pt-internal.h>
24
25/* Initialize thread attribute *ATTR with attributes corresponding to the
26 already running thread THREAD. It shall be called on an uninitialized ATTR
27 and destroyed with pthread_attr_destroy when no longer needed. */
28int
29__pthread_getattr_np (pthread_t thread, pthread_attr_t *attr)
30{
31 struct __pthread *pthread;
32
33 pthread = __pthread_getid (thread);
34 if (pthread == NULL)
35 return ESRCH;
36
37 /* Some attributes (schedparam, inheritsched, contentionscope and schedpolicy)
38 are not supported yet, so fill them with our default values. */
39 *attr = __pthread_default_attr;
40
a04549c1
JM
41 attr->__stackaddr = (pthread->stackaddr
42 + ((pthread->guardsize + __vm_page_size - 1)
43 / __vm_page_size * __vm_page_size));
33574c17
ST
44 attr->__stacksize = pthread->stacksize;
45 attr->__guardsize = pthread->guardsize;
46 attr->__detachstate = (pthread->state == PTHREAD_DETACHED
47 ? PTHREAD_CREATE_DETACHED : PTHREAD_CREATE_JOINABLE);
48
49 return 0;
50}
51weak_alias (__pthread_getattr_np, pthread_getattr_np)