xref: /openbsd-src/lib/libpthread/man/pthread_attr_setstack.3 (revision 0abccc37ae616c654d8c1a75cd149f63652b4ba0)
1*0abccc37Sotto.\" $OpenBSD: pthread_attr_setstack.3,v 1.6 2020/12/03 07:05:03 otto Exp $
211ddadc0Sguenther.\" Manual page derived from TOG's UNIX98 documentation.
311ddadc0Sguenther.\"
411ddadc0Sguenther.\"  David Leonard, 2000. Public Domain.
511ddadc0Sguenther.\"
6*0abccc37Sotto.Dd $Mdocdate: December 3 2020 $
730fcf885Sjmc.Dt PTHREAD_ATTR_SETSTACK 3
811ddadc0Sguenther.Os
911ddadc0Sguenther.Sh NAME
1011ddadc0Sguenther.Nm pthread_attr_setstack ,
1111ddadc0Sguenther.Nm pthread_attr_getstack
1211ddadc0Sguenther.Nd set and get stack attributes
1311ddadc0Sguenther.Sh SYNOPSIS
1486f9d4cdStedu.In pthread.h
1511ddadc0Sguenther.Ft int
1611ddadc0Sguenther.Fn pthread_attr_setstack "pthread_attr_t *attr" "void *stackaddr" "size_t stacksize"
1711ddadc0Sguenther.Ft int
1811ddadc0Sguenther.Fn pthread_attr_getstack "const pthread_attr_t *attr" "void **stackaddr" "size_t *stacksize"
1911ddadc0Sguenther.Sh DESCRIPTION
2011ddadc0SguentherThe functions
2111ddadc0Sguenther.Fn pthread_attr_setstack
2211ddadc0Sguentherand
2311ddadc0Sguenther.Fn pthread_attr_getstack ,
2411ddadc0Sguentherrespectively, set and get the thread
2511ddadc0Sguenthercreation
2611ddadc0Sguenther.Va stackaddr
2711ddadc0Sguentherand
2811ddadc0Sguenther.Va stacksize
2911ddadc0Sguentherattributes in the
3011ddadc0Sguenther.Fa attr
3111ddadc0Sguentherobject.
3211ddadc0Sguenther.Pp
3311ddadc0SguentherThe stack attributes specify the area of storage to be used for the
3411ddadc0Sguenthercreated thread's stack.
3511ddadc0SguentherThe base (lowest addressable byte) of the storage shall be
3611ddadc0Sguenther.Va stackaddr ,
3711ddadc0Sguentherand the size of the storage shall be
3811ddadc0Sguenther.Va stacksize
3911ddadc0Sguentherbytes.
4011ddadc0SguentherThe stacksize shall be at least
4111ddadc0Sguenther.Dv PTHREAD_STACK_MIN .
42003f5e42Sderaadt.Pp
43003f5e42SderaadtOn
44003f5e42Sderaadt.Ox
45003f5e42Sderaadtthe provided stack must be page-aligned.
46003f5e42SderaadtIt will be replaced (meaning zeroed) with a new
47003f5e42Sderaadt.Ar MAP_ANON | Ar MAP_STACK
48003f5e42Sderaadtmapping.
49*0abccc37SottoThe passed memory object should not be deallocated or reused,
50*0abccc37Sottoeven when the thread using it has terminated.
51*0abccc37SottoIf there is no need for a specific memory object as stack,
52*0abccc37Sottothe
53*0abccc37Sotto.Xr pthread_attr_setstacksize 3
54*0abccc37Sottofunction should be used.
5511ddadc0Sguenther.Sh RETURN VALUES
5611ddadc0SguentherUpon successful completion,
5711ddadc0Sguenther.Fn pthread_attr_setstack
5811ddadc0Sguentherand
5911ddadc0Sguenther.Fn pthread_attr_getstack
6011ddadc0Sguentherreturn a value of 0.
6111ddadc0SguentherOtherwise, an error number is returned to indicate the error.
6211ddadc0Sguenther.Pp
6311ddadc0SguentherThe
6411ddadc0Sguenther.Fn pthread_attr_getstack
6511ddadc0Sguentherfunction stores the
6611ddadc0Sguenther.Va stackaddr
6711ddadc0Sguentherattribute value in
6811ddadc0Sguenther.Fa stackaddr
6911ddadc0Sguentherand the
7011ddadc0Sguenther.Va stacksize
7111ddadc0Sguentherattribute value in
7211ddadc0Sguenther.Fa stacksize
7311ddadc0Sguentherif successful.
7411ddadc0Sguenther.Sh ERRORS
7511ddadc0SguentherThe
7611ddadc0Sguenther.Fn pthread_attr_setstack
7711ddadc0Sguentherfunction will fail if:
7811ddadc0Sguenther.Bl -tag -width Er
7911ddadc0Sguenther.It Bq Er EINVAL
8011ddadc0SguentherThe value of
8111ddadc0Sguenther.Fa stacksize
8211ddadc0Sguentheris less than
8311ddadc0Sguenther.Dv PTHREAD_STACK_MIN
8411ddadc0Sguentheror exceeds a system-imposed limit or the value of
8511ddadc0Sguenther.Fa stackaddr
8611ddadc0Sguentheris
8711ddadc0Sguenther.Dv NULL .
8811ddadc0Sguenther.El
8911ddadc0Sguenther.Pp
9011ddadc0SguentherThese functions will not return an error code of
9111ddadc0Sguenther.Bq Er EINTR .
9211ddadc0Sguenther.Sh SEE ALSO
9311ddadc0Sguenther.Xr pthread_attr_init 3 ,
9411ddadc0Sguenther.Xr pthread_attr_setdetachstate 3 ,
9591063d07Sguenther.Xr pthread_attr_setguardsize 3 ,
9611ddadc0Sguenther.Xr pthread_attr_setstackaddr 3 ,
9711ddadc0Sguenther.Xr pthread_attr_setstacksize 3 ,
9811ddadc0Sguenther.Xr pthread_create 3 ,
9911ddadc0Sguenther.Xr pthreads 3
10011ddadc0Sguenther.Sh STANDARDS
10111ddadc0Sguenther.Fn pthread_attr_setstack
10211ddadc0Sguentherand
10311ddadc0Sguenther.Fn pthread_attr_getstack
10411ddadc0Sguentherconform to ISO/IEC 9945-1 ANSI/IEEE
10511ddadc0Sguenther.Pq Dq Tn POSIX
10611ddadc0SguentherStd 1003.1, 2004 Edition.
107