PTHREAD_ATTR_GETSTACK(3)   POSIX Programmer's Manual  PTHREAD_ATTR_GETSTACK(3)



PPRROOLLOOGG
       This manual page is part of the POSIX Programmer's Manual.  The OS
       implementation of this interface may differ (consult the corresponding
       OS manual page for details of OS behavior), or the interface may not be
       implemented on OS.


NNAAMMEE
       pthread_attr_getstack, pthread_attr_setstack -- get and set stack
       attributes

SSYYNNOOPPSSIISS
       #include <pthread.h>

       int pthread_attr_getstack(const pthread_attr_t *restrict _a_t_t_r,
           void **restrict _s_t_a_c_k_a_d_d_r, size_t *restrict _s_t_a_c_k_s_i_z_e);
       int pthread_attr_setstack(pthread_attr_t *_a_t_t_r, void *_s_t_a_c_k_a_d_d_r,
           size_t _s_t_a_c_k_s_i_z_e);

DDEESSCCRRIIPPTTIIOONN
       The _p_t_h_r_e_a_d___a_t_t_r___g_e_t_s_t_a_c_k() and _p_t_h_r_e_a_d___a_t_t_r___s_e_t_s_t_a_c_k() functions,
       respectively, shall get and set the thread creation stack attributes
       _s_t_a_c_k_a_d_d_r and _s_t_a_c_k_s_i_z_e in the _a_t_t_r object.

       The stack attributes specify the area of storage to be used for the
       created thread's stack. The base (lowest addressable byte) of the
       storage shall be _s_t_a_c_k_a_d_d_r, and the size of the storage shall be
       _s_t_a_c_k_s_i_z_e bytes. The _s_t_a_c_k_s_i_z_e shall be at least {PTHREAD_STACK_MIN}.
       The _p_t_h_r_e_a_d___a_t_t_r___s_e_t_s_t_a_c_k() function may fail with [[EEIINNVVAALL]] if
       _s_t_a_c_k_a_d_d_r does not meet implementation-defined alignment requirements.
       All pages within the stack described by _s_t_a_c_k_a_d_d_r and _s_t_a_c_k_s_i_z_e shall
       be both readable and writable by the thread.

       If the _p_t_h_r_e_a_d___a_t_t_r___g_e_t_s_t_a_c_k() function is called before the _s_t_a_c_k_a_d_d_r
       attribute has been set, the behavior is unspecified.

       The behavior is undefined if the value specified by the _a_t_t_r argument
       to _p_t_h_r_e_a_d___a_t_t_r___g_e_t_s_t_a_c_k() or _p_t_h_r_e_a_d___a_t_t_r___s_e_t_s_t_a_c_k() does not refer to
       an initialized thread attributes object.

RREETTUURRNN VVAALLUUEE
       Upon successful completion, these functions shall return a value of 0;
       otherwise, an error number shall be returned to indicate the error.

       The _p_t_h_r_e_a_d___a_t_t_r___g_e_t_s_t_a_c_k() function shall store the stack attribute
       values in _s_t_a_c_k_a_d_d_r and _s_t_a_c_k_s_i_z_e if successful.

EERRRROORRSS
       The _p_t_h_r_e_a_d___a_t_t_r___s_e_t_s_t_a_c_k() function shall fail if:

       EEIINNVVAALL The value of _s_t_a_c_k_s_i_z_e is less than {PTHREAD_STACK_MIN} or
              exceeds an implementation-defined limit.

       The _p_t_h_r_e_a_d___a_t_t_r___s_e_t_s_t_a_c_k() function may fail if:

       EEIINNVVAALL The value of _s_t_a_c_k_a_d_d_r does not have proper alignment to be used
              as a stack, or ((cchhaarr **)_s_t_a_c_k_a_d_d_r + _s_t_a_c_k_s_i_z_e) lacks proper
              alignment.

       EEAACCCCEESS The stack page(s) described by _s_t_a_c_k_a_d_d_r and _s_t_a_c_k_s_i_z_e are not
              both readable and writable by the thread.

       These functions shall not return an error code of [[EEIINNTTRR]].

       _T_h_e _f_o_l_l_o_w_i_n_g _s_e_c_t_i_o_n_s _a_r_e _i_n_f_o_r_m_a_t_i_v_e_.

EEXXAAMMPPLLEESS
       None.

AAPPPPLLIICCAATTIIOONN UUSSAAGGEE
       These functions are appropriate for use by applications in an
       environment where the stack for a thread must be placed in some
       particular region of memory.

       While it might seem that an application could detect stack overflow by
       providing a protected page outside the specified stack region, this
       cannot be done portably. Implementations are free to place the thread's
       initial stack pointer anywhere within the specified region to
       accommodate the machine's stack pointer behavior and allocation
       requirements. Furthermore, on some architectures, such as the IA-64,
       ``overflow'' might mean that two separate stack pointers allocated
       within the region will overlap somewhere in the middle of the region.

       After a successful call to _p_t_h_r_e_a_d___a_t_t_r___s_e_t_s_t_a_c_k(), the storage area
       specified by the _s_t_a_c_k_a_d_d_r parameter is under the control of the
       implementation, as described in _S_e_c_t_i_o_n _2_._9_._8, _U_s_e _o_f _A_p_p_l_i_c_a_t_i_o_n_-
       _M_a_n_a_g_e_d _T_h_r_e_a_d _S_t_a_c_k_s.

       The specification of the _s_t_a_c_k_a_d_d_r attribute presents several
       ambiguities that make portable use of these functions impossible. For
       example, the standard allows implementations to impose arbitrary
       alignment requirements on _s_t_a_c_k_a_d_d_r.  Applications cannot assume that a
       buffer obtained from _m_a_l_l_o_c() is suitably aligned. Note that although
       the _s_t_a_c_k_s_i_z_e value passed to _p_t_h_r_e_a_d___a_t_t_r___s_e_t_s_t_a_c_k() must satisfy
       alignment requirements, the same is not true for
       _p_t_h_r_e_a_d___a_t_t_r___s_e_t_s_t_a_c_k_s_i_z_e() where the implementation must increase the
       specified size if necessary to achieve the proper alignment.

RRAATTIIOONNAALLEE
       If an implementation detects that the value specified by the _a_t_t_r
       argument to _p_t_h_r_e_a_d___a_t_t_r___g_e_t_s_t_a_c_k() or _p_t_h_r_e_a_d___a_t_t_r___s_e_t_s_t_a_c_k() does not
       refer to an initialized thread attributes object, it is recommended
       that the function should fail and report an [[EEIINNVVAALL]] error.

FFUUTTUURREE DDIIRREECCTTIIOONNSS
       None.

SSEEEE AALLSSOO
       _p_t_h_r_e_a_d___a_t_t_r___d_e_s_t_r_o_y(), _p_t_h_r_e_a_d___a_t_t_r___g_e_t_d_e_t_a_c_h_s_t_a_t_e(),
       _p_t_h_r_e_a_d___a_t_t_r___g_e_t_s_t_a_c_k_s_i_z_e(), _p_t_h_r_e_a_d___c_r_e_a_t_e()

       The Base Definitions volume of POSIX.1-2008, <<lliimmiittss..hh>>, <<pptthhrreeaadd..hh>>

CCOOPPYYRRIIGGHHTT
       Portions of this text are reprinted and reproduced in electronic form
       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
       -- Portable Operating System Interface (POSIX), The Open Group Base
       Specifications Issue 7, Copyright (C) 2013 by the Institute of
       Electrical and Electronics Engineers, Inc and The Open Group.  (This is
       POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
       event of any discrepancy between this version and the original IEEE and
       The Open Group Standard, the original IEEE and The Open Group Standard
       is the referee document. The original Standard can be obtained online
       at http://www.unix.org/online.html .

       Any typographical or formatting errors that appear in this page are
       most likely to have been introduced during the conversion of the source
       files to man page format. To report such errors, see
       https://www.kernel.org/doc/man-pages/reporting_bugs.html .



IEEE/The Open Group                  2013             PTHREAD_ATTR_GETSTACK(3)
