Friday, April 26, 2013

pthread_attr_getstackaddr example c c++


NAME

pthread_attr_getstackaddr, pthread_attr_setstackaddr - get and set the stackaddr attribute

SYNOPSIS

[THR TSA] [Option Start] #include <pthread.h>

[Option End]
[OB] [Option Start] int pthread_attr_getstackaddr(const pthread_attr_t *restrict attr,
       void **restrict
 stackaddr);
int pthread_attr_setstackaddr(pthread_attr_t *
attr, void *stackaddr); [Option End]

DESCRIPTION

The pthread_attr_getstackaddr() and pthread_attr_setstackaddr() functions, respectively, shall get and set the thread creation stackaddrattribute in the attr object.
The stackaddr attribute specifies the location of storage to be used for the created thread's stack. The size of the storage shall be at least {PTHREAD_STACK_MIN}.

RETURN VALUE

Upon successful completion, pthread_attr_getstackaddr() and pthread_attr_setstackaddr() shall return a value of 0; otherwise, an error number shall be returned to indicate the error.
The pthread_attr_getstackaddr() function stores the stackaddr attribute value in stackaddr if successful.

ERRORS of (pthread_attr_getstackaddr, pthread_attr_setstackaddr)

These functions may fail if:
[EINVAL]
The value specified by attr does not refer to an initialized thread attribute object.
These functions shall not return an error code of [EINTR].
Example of (pthread_attr_getstackaddr, pthread_attr_setstackaddr)


int pthread_attr_getstackaddr(pthread_attr_t *tattr,void * *stackaddr);
#include <pthread.h>

pthread_attr_t tattr;
void *base;
int ret;

/* getting a new address */
ret = pthread_attr_getstackaddr (&tattr, *base);