]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/pthread_attr_setstacksize.3
membarrier.2: Remove redundant mention of return value of MEMBARRIER_CMD_SHARED
[thirdparty/man-pages.git] / man3 / pthread_attr_setstacksize.3
CommitLineData
5a8b01e1
MK
1.\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
2.\" <mtk.manpages@gmail.com>
3.\"
93015253 4.\" %%%LICENSE_START(VERBATIM)
5a8b01e1
MK
5.\" Permission is granted to make and distribute verbatim copies of this
6.\" manual provided the copyright notice and this permission notice are
7.\" preserved on all copies.
8.\"
9.\" Permission is granted to copy and distribute modified versions of this
10.\" manual under the conditions for verbatim copying, provided that the
11.\" entire resulting derived work is distributed under the terms of a
12.\" permission notice identical to this one.
13.\"
14.\" Since the Linux kernel and libraries are constantly changing, this
15.\" manual page may be incorrect or out-of-date. The author(s) assume no
16.\" responsibility for errors or omissions, or for damages resulting from
17.\" the use of the information contained herein. The author(s) may not
18.\" have taken the same level of care in the production of this manual,
19.\" which is licensed free of charge, as they might when working
20.\" professionally.
21.\"
22.\" Formatted or processed versions of this manual, if unaccompanied by
23.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 24.\" %%%LICENSE_END
5a8b01e1 25.\"
460495ca 26.TH PTHREAD_ATTR_SETSTACKSIZE 3 2015-08-08 "Linux" "Linux Programmer's Manual"
5a8b01e1
MK
27.SH NAME
28pthread_attr_setstacksize, pthread_attr_getstacksize \- set/get stack size
29attribute in thread attributes object
30.SH SYNOPSIS
31.nf
32.B #include <pthread.h>
33
34.BI "int pthread_attr_setstacksize(pthread_attr_t *" attr \
35", size_t " stacksize );
e59f5f58 36.BI "int pthread_attr_getstacksize(const pthread_attr_t *" attr \
5a8b01e1
MK
37", size_t *" stacksize );
38.sp
39Compile and link with \fI\-pthread\fP.
6030f2d8 40.fi
5a8b01e1
MK
41.SH DESCRIPTION
42The
630a1725 43.BR pthread_attr_setstacksize ()
5a8b01e1
MK
44function sets the stack size attribute of the
45thread attributes object referred to by
46.I attr
47to the value specified in
48.IR stacksize .
49
50The stack size attribute determines the minimum size (in bytes) that
51will be allocated for threads created using the thread attributes object
52.IR attr .
53
54The
55.BR pthread_attr_getstacksize ()
56function returns the stack size attribute of the
57thread attributes object referred to by
58.I attr
59in the buffer pointed to by
60.IR stacksize .
61.SH RETURN VALUE
62On success, these functions return 0;
c7094399 63on error, they return a nonzero error number.
5a8b01e1
MK
64.SH ERRORS
65.BR pthread_attr_setstacksize ()
66can fail with the following error:
67.TP
68.B EINVAL
69The stack size is less than
70.BR PTHREAD_STACK_MIN
71(16384) bytes.
c2befb6a
MK
72.PP
73On some systems,
74.\" e.g., MacOS
75.BR pthread_attr_setstacksize ()
76can fail with the error
77.B EINVAL
78if
79.I stacksize
80is not a multiple of the system page size.
5a8b01e1
MK
81.SH VERSIONS
82These functions are provided by glibc since version 2.1.
18cbeb88 83.SH ATTRIBUTES
f247f80c
PH
84For an explanation of the terms used in this section, see
85.BR attributes (7).
86.TS
87allbox;
88lbw28 lb lb
89l l l.
90Interface Attribute Value
91T{
92.BR pthread_attr_setstacksize (),
18cbeb88 93.BR pthread_attr_getstacksize ()
f247f80c
PH
94T} Thread safety MT-Safe
95.TE
5a8b01e1 96.SH CONFORMING TO
87d8ecf9 97POSIX.1-2001, POSIX.1-2008.
5a8b01e1
MK
98.SH NOTES
99For details on the default stack size of new threads, see
100.BR pthread_create (3).
101
102A thread's stack size is fixed at the time of thread creation.
103Only the main thread can dynamically grow its stack.
104
105The
106.BR pthread_attr_setstack (3)
107function allows an application to set both the size and location
108of a caller-allocated stack that is to be used by a thread.
109.SH BUGS
110As at glibc 2.8,
111if the specified
112.I stacksize
113is not a multiple of
114.BR STACK_ALIGN
115(16 bytes on most architectures), it may be rounded
5fab2e7c 116.IR downward ,
87d8ecf9 117in violation of POSIX.1, which says that the allocated stack will
5a8b01e1
MK
118be at least
119.I stacksize
120bytes.
22cb459d
MK
121.SH EXAMPLE
122See
123.BR pthread_create (3).
5a8b01e1
MK
124.SH SEE ALSO
125.BR getrlimit (2),
126.BR pthread_attr_init (3),
127.BR pthread_attr_setguardsize (3),
128.BR pthread_attr_setstack (3),
129.BR pthread_create (3),
130.BR pthreads (7)