pthread_attr_getukeyset_np or pthread_attr_setukeyset_np Subroutine

Purpose

Gets and sets the value of the active user-key-set attribute of a thread attributes object.

Library

Threads library (libpthreads.a)

Syntax

#include <pthread.h>
#include <sys/ukeys.h>

int pthread_attr_getukeyset_np (attr, ukeyset)
const pthread_attr_t *  attr;
ukeyset_t *  ukeyset;

Description

The ukeyset parameter specifies the active user-key-set for a thread that is created with this attributes object. By default, newly-created threads can only access (both read and write) memory pages that have been assigned the default user-key UKEY_PUBLIC. User-key-sets are not inherited across the pthread_create subroutine.

The pthread_attr_getukeyset_np subroutine gets the user-key-set attribute, while the pthread_attr_setukeyset_np subroutine sets the user-key-set attribute in the thread attributes object specified by the attr parameter.

Both the pthread_attr_getukeyset_np and the pthread_attr_setukeyset_np subroutines fail unless the ukey_enable subroutine has been previously successfully run by a thread in the process. Refer to the Storage Protect Keys article for more details.

Parameters

Table 1. Parameters
Item Description
attr Specifies the thread attributes object.
ukeyset Points to a location where the user-key-set attribute value is stored.

Return Values

The pthread_attr_getukeyset_np and pthread_attr_setukeyset_np subroutines return a value of 0 on success. Otherwise, an error code is returned.

Errors Codes

The pthread_attr_getukeyset_np and pthread_attr_setukeyset_np subroutines are unsuccessful if the following are true:

Table 2. Error Codes
Item Description
EINVAL The attribute object specified by the attr parameter is invalid or the address pointed to by the ukeyset parameter is not aligned to hold a user-key-set.
ENOSYS Process is not a user-key-enabled process.

In addition, the pthread_attr_setukeyset_np subroutine is unsuccessful if the following is true:

Item Description
EINVAL The user-key-set value that is specified by the ukeyset parameter is not valid.

These functions will not return an error code of EINTR.