1f3cf9008SAlexey Zelkin.\" Copyright (c) 2002,2003 Alexey Zelkin <phantom@FreeBSD.org> 21f1e884aSAlexey Zelkin.\" All rights reserved. 3*6211cd4bSOlivier Certner.\" Copyright (c) 2024 The FreeBSD Foundation 4*6211cd4bSOlivier Certner.\" 5*6211cd4bSOlivier Certner.\" Portions of this documentation were written by Olivier Certner 6*6211cd4bSOlivier Certner.\" <olce@FreeBSD.org> at Kumacom SARL under sponsorship from the 7*6211cd4bSOlivier Certner.\" FreeBSD Foundation. 81f1e884aSAlexey Zelkin.\" 91f1e884aSAlexey Zelkin.\" Redistribution and use in source and binary forms, with or without 101f1e884aSAlexey Zelkin.\" modification, are permitted provided that the following conditions 111f1e884aSAlexey Zelkin.\" are met: 121f1e884aSAlexey Zelkin.\" 1. Redistributions of source code must retain the above copyright 131f1e884aSAlexey Zelkin.\" notice, this list of conditions and the following disclaimer. 141f1e884aSAlexey Zelkin.\" 2. Redistributions in binary form must reproduce the above copyright 151f1e884aSAlexey Zelkin.\" notice, this list of conditions and the following disclaimer in the 161f1e884aSAlexey Zelkin.\" documentation and/or other materials provided with the distribution. 171f1e884aSAlexey Zelkin.\" 181f1e884aSAlexey Zelkin.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 191f1e884aSAlexey Zelkin.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 201f1e884aSAlexey Zelkin.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 211f1e884aSAlexey Zelkin.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 221f1e884aSAlexey Zelkin.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 231f1e884aSAlexey Zelkin.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 241f1e884aSAlexey Zelkin.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 251f1e884aSAlexey Zelkin.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 261f1e884aSAlexey Zelkin.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 271f1e884aSAlexey Zelkin.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 281f1e884aSAlexey Zelkin.\" SUCH DAMAGE. 291f1e884aSAlexey Zelkin.\" 30*6211cd4bSOlivier Certner.Dd January 5, 2024 311f1e884aSAlexey Zelkin.Dt PTHREAD_ATTR_GET_NP 3 321f1e884aSAlexey Zelkin.Os 331f1e884aSAlexey Zelkin.Sh NAME 341f1e884aSAlexey Zelkin.Nm pthread_attr_get_np 35*6211cd4bSOlivier Certner.Nd get attributes of an existing thread 361f1e884aSAlexey Zelkin.Sh LIBRARY 37ec7452f1SRuslan Ermilov.Lb libpthread 381f1e884aSAlexey Zelkin.Sh SYNOPSIS 391f1e884aSAlexey Zelkin.In pthread_np.h 401f1e884aSAlexey Zelkin.Ft int 41f7ed1917SMax Khon.Fn pthread_attr_get_np "pthread_t pid" "pthread_attr_t *dst" 421f1e884aSAlexey Zelkin.Sh DESCRIPTION 431f1e884aSAlexey ZelkinThe 441f1e884aSAlexey Zelkin.Fn pthread_attr_get_np 45*6211cd4bSOlivier Certnerfunction is used to retrieve the attributes of the specified thread into an 46*6211cd4bSOlivier Certnerexisting 47e1993839SRuslan Ermilov.Vt pthread_attr_t 48e1993839SRuslan Ermilovstructure. 49*6211cd4bSOlivier CertnerThe attributes' values are the current ones for the target thread, except for 50*6211cd4bSOlivier Certnerthe stack top address if not properly aligned for the architecture, since in 51*6211cd4bSOlivier Certnerthis case its value has been adjusted internally before use. 52c18f0ff7SAlexey Zelkin.Pp 53*6211cd4bSOlivier CertnerArgument 54*6211cd4bSOlivier Certner.Fa dst 55*6211cd4bSOlivier Certnermust be a pointer to a valid attributes object 56*6211cd4bSOlivier Certner.Po 57*6211cd4bSOlivier Certnerit was initialized at some point by 581f1e884aSAlexey Zelkin.Xr pthread_attr_init 3 59*6211cd4bSOlivier Certnerand was not destroyed since then 60*6211cd4bSOlivier Certner.Pc . 61*6211cd4bSOlivier CertnerAfter a successful call to 62*6211cd4bSOlivier Certner.Fn pthread_attr_get_np , 63*6211cd4bSOlivier Certnerthe individual attributes' values can be retrieved as usual via the 64*6211cd4bSOlivier Certnercorresponding accessor functions as documented in 65*6211cd4bSOlivier Certner.Xr pthread_attr 3 . 66*6211cd4bSOlivier CertnerAfter a failed call to 67*6211cd4bSOlivier Certner.Fn pthread_attr_get_np , 68*6211cd4bSOlivier Certnerthe object pointed to by 69*6211cd4bSOlivier Certner.Fa dst 70*6211cd4bSOlivier Certneris left unmodified, and can continue to be used as if the failed call never 71*6211cd4bSOlivier Certnerhappened. 729cbda590SRuslan Ermilov.Sh RETURN VALUES 739cbda590SRuslan ErmilovIf successful, 749cbda590SRuslan Ermilov.Fn pthread_attr_get_np 759cbda590SRuslan Ermilovfunction returns 0. 769cbda590SRuslan ErmilovOtherwise, an error number is returned to indicate the error. 771f1e884aSAlexey Zelkin.Sh EXAMPLES 78*6211cd4bSOlivier CertnerThis function retrieves the stack size of the thread specified by the 79*6211cd4bSOlivier Certner.Fa pid 80*6211cd4bSOlivier Certnerargument: 811f1e884aSAlexey Zelkin.Bd -literal 821f1e884aSAlexey Zelkinsize_t 83*6211cd4bSOlivier Certnermy_thread_stack_size(pthread_t tid) 841f1e884aSAlexey Zelkin{ 851f1e884aSAlexey Zelkin pthread_attr_t attr; 861f1e884aSAlexey Zelkin size_t size; 871f1e884aSAlexey Zelkin 881f1e884aSAlexey Zelkin pthread_attr_init(&attr); 89*6211cd4bSOlivier Certner pthread_attr_get_np(tid, &attr); 901f1e884aSAlexey Zelkin pthread_attr_getstacksize(&attr, &size); 911f1e884aSAlexey Zelkin pthread_attr_destroy(&attr); 921f1e884aSAlexey Zelkin return (size); 931f1e884aSAlexey Zelkin} 941f1e884aSAlexey Zelkin.Ed 951f1e884aSAlexey Zelkin.Sh ERRORS 969d09157aSPhilippe CharnierThe 971f1e884aSAlexey Zelkin.Fn pthread_attr_get_np 989d09157aSPhilippe Charnierfunction will fail if: 991f1e884aSAlexey Zelkin.Bl -tag -width Er 1001f1e884aSAlexey Zelkin.It Bq Er EINVAL 101*6211cd4bSOlivier CertnerOne of the arguments has an invalid value. 102a8aad864SJilles Tjoelker.It Bq Er ESRCH 1031f1e884aSAlexey ZelkinNo thread could be found corresponding to that specified by the given 1041f1e884aSAlexey Zelkinthread ID. 105*6211cd4bSOlivier Certner.It Bq Er ENOMEM 106*6211cd4bSOlivier CertnerThere was not enough memory to allocate additional storage needed by the attributes 107*6211cd4bSOlivier Certnerobject's implementation. 1081f1e884aSAlexey Zelkin.El 1091f1e884aSAlexey Zelkin.Sh SEE ALSO 110*6211cd4bSOlivier Certner.Xr pthread_attr 3 , 1111f1e884aSAlexey Zelkin.Xr pthread_attr_destroy 3 , 1121f1e884aSAlexey Zelkin.Xr pthread_attr_getdetachstate 3 , 1131f1e884aSAlexey Zelkin.Xr pthread_attr_getinheritsched 3 , 1141f1e884aSAlexey Zelkin.Xr pthread_attr_getschedparam 3 , 1151f1e884aSAlexey Zelkin.Xr pthread_attr_getschedpolicy 3 , 116e1993839SRuslan Ermilov.Xr pthread_attr_getscope 3 , 117c18f0ff7SAlexey Zelkin.Xr pthread_attr_getstack 3 , 118e1993839SRuslan Ermilov.Xr pthread_attr_getstackaddr 3 , 119e1993839SRuslan Ermilov.Xr pthread_attr_getstacksize 3 , 120df7d7638SFelix Johnson.Xr pthread_attr_init 3 , 121df7d7638SFelix Johnson.Xr pthread_np 3 122597cf128SAlexey Zelkin.Sh AUTHORS 123597cf128SAlexey ZelkinThe 124ace5be68SRuslan Ermilov.Fn pthread_attr_get_np 125ace5be68SRuslan Ermilovfunction and this manual page were written by 126*6211cd4bSOlivier Certner.An Alexey Zelkin Aq Mt phantom@FreeBSD.org , 127*6211cd4bSOlivier Certnerand the latter was revised by 128*6211cd4bSOlivier Certner.An Olivier Certner Aq Mt olce@FreeBSD.org . 129