posix-next API 0.1.0
Out-of-tree Zephyr POSIX module
Loading...
Searching...
No Matches
POSIX_NON_PORTABLE

POSIX Non-Portable (GNU extension) option group. More...

Data Structures

struct  cpu_set_t
 Set of CPUs for pthread_getaffinity_np() and pthread_setaffinity_np() (GNU extension). More...
 

Macros

#define CPU_SETSIZE   32
 Number of CPUs a cpu_set_t can name (GNU extension).
 
#define CPU_ZERO(set)   __cpu_zero(set)
 Remove every CPU from set (GNU extension).
 
#define CPU_SET(cpu, set)
 Add CPU cpu to set (GNU extension).
 
#define CPU_CLR(cpu, set)
 Remove CPU cpu from set (GNU extension).
 
#define CPU_ISSET(cpu, set)    (((size_t)(cpu) < CPU_SETSIZE) && (((set)->__bits[__CPU_WORD(cpu)] & __CPU_BIT(cpu)) != 0))
 Test whether CPU cpu is in set (GNU extension).
 
#define CPU_COUNT(set)   __cpu_count(set)
 Number of CPUs in set (GNU extension).
 
#define CPU_EQUAL(a, b)   __cpu_equal(a, b)
 Test whether a and b name the same CPUs (GNU extension).
 

Functions

int pthread_getaffinity_np (pthread_t thread, size_t cpusetsize, cpu_set_t *cpuset)
 Get the set of CPUs a thread may run on (GNU extension).
 
int pthread_getname_np (pthread_t thread, char *name, size_t len)
 Get the name of a thread (GNU extension).
 
int pthread_setaffinity_np (pthread_t thread, size_t cpusetsize, const cpu_set_t *cpuset)
 Set the CPUs a thread may run on (GNU extension).
 
int pthread_setname_np (pthread_t thread, const char *name)
 Set the name of a thread (GNU extension).
 
int pthread_timedjoin_np (pthread_t thread, void **status, const struct timespec *abstime)
 Wait for a thread to terminate with an absolute timeout (GNU extension).
 
int pthread_tryjoin_np (pthread_t thread, void **status)
 Try to join a thread without blocking (GNU extension).
 

Detailed Description

POSIX Non-Portable (GNU extension) option group.

Covers pthread_getaffinity_np(), pthread_getname_np(), pthread_setaffinity_np(), pthread_setname_np(), pthread_timedjoin_np(), and pthread_tryjoin_np().

Macro Definition Documentation

◆ CPU_CLR

#define CPU_CLR (   cpu,
  set 
)
Value:
((void)(((size_t)(cpu) < CPU_SETSIZE) \
? ((set)->__bits[__CPU_WORD(cpu)] &= ~__CPU_BIT(cpu)) \
: 0U))
#define CPU_SETSIZE
Number of CPUs a cpu_set_t can name (GNU extension).
Definition cpuset.h:26

Remove CPU cpu from set (GNU extension).

Definition at line 90 of file cpuset.h.

◆ CPU_COUNT

#define CPU_COUNT (   set)    __cpu_count(set)

Number of CPUs in set (GNU extension).

Definition at line 106 of file cpuset.h.

◆ CPU_EQUAL

#define CPU_EQUAL (   a,
 
)    __cpu_equal(a, b)

Test whether a and b name the same CPUs (GNU extension).

Definition at line 112 of file cpuset.h.

◆ CPU_ISSET

#define CPU_ISSET (   cpu,
  set 
)     (((size_t)(cpu) < CPU_SETSIZE) && (((set)->__bits[__CPU_WORD(cpu)] & __CPU_BIT(cpu)) != 0))

Test whether CPU cpu is in set (GNU extension).

Definition at line 99 of file cpuset.h.

◆ CPU_SET

#define CPU_SET (   cpu,
  set 
)
Value:
((void)(((size_t)(cpu) < CPU_SETSIZE) \
? ((set)->__bits[__CPU_WORD(cpu)] |= __CPU_BIT(cpu)) \
: 0U))

Add CPU cpu to set (GNU extension).

Definition at line 81 of file cpuset.h.

◆ CPU_SETSIZE

#define CPU_SETSIZE   32

Number of CPUs a cpu_set_t can name (GNU extension).

Definition at line 26 of file cpuset.h.

◆ CPU_ZERO

#define CPU_ZERO (   set)    __cpu_zero(set)

Remove every CPU from set (GNU extension).

Definition at line 75 of file cpuset.h.

Function Documentation

◆ pthread_getaffinity_np()

int pthread_getaffinity_np ( pthread_t  thread,
size_t  cpusetsize,
cpu_set_t cpuset 
)

Get the set of CPUs a thread may run on (GNU extension).

Parameters
threadThread to query.
cpusetsizeSize of cpuset in bytes, at least sizeof(cpu_set_t).
cpusetOutput: the CPUs thread may run on.
Returns
0 on success, or a positive error number on failure.
See also
https://man7.org/linux/man-pages/man3/pthread_getaffinity_np.3.html

◆ pthread_getname_np()

int pthread_getname_np ( pthread_t  thread,
char *  name,
size_t  len 
)

Get the name of a thread (GNU extension).

Parameters
threadThread to query.
nameOutput buffer for the name.
lenSize of name buffer.
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_getname_np.html

◆ pthread_setaffinity_np()

int pthread_setaffinity_np ( pthread_t  thread,
size_t  cpusetsize,
const cpu_set_t cpuset 
)

Set the CPUs a thread may run on (GNU extension).

CPUs in cpuset that do not exist are ignored; at least one existing CPU must remain. Without CONFIG_SCHED_CPU_MASK only a set naming every CPU can be honored.

Parameters
threadThread to modify.
cpusetsizeSize of cpuset in bytes, at least sizeof(cpu_set_t).
cpusetThe CPUs thread may run on.
Return values
0on success.
EFAULTif cpuset is NULL.
EINVALif cpusetsize is too small or cpuset names no existing CPU.
ENOTSUPif the set cannot be honored in this configuration.
See also
https://man7.org/linux/man-pages/man3/pthread_setaffinity_np.3.html

◆ pthread_setname_np()

int pthread_setname_np ( pthread_t  thread,
const char *  name 
)

Set the name of a thread (GNU extension).

Parameters
threadThread to name.
nameNull-terminated name string (max 15 characters + NUL).
Returns
0 on success, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_setname_np.html

◆ pthread_timedjoin_np()

int pthread_timedjoin_np ( pthread_t  thread,
void **  status,
const struct timespec abstime 
)

Wait for a thread to terminate with an absolute timeout (GNU extension).

Parameters
threadThread to wait for.
statusOutput: exit value or PTHREAD_CANCELED.
abstimeAbsolute timeout (CLOCK_REALTIME).
Returns
0 on success, ETIMEDOUT on timeout, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_timedjoin_np.html

◆ pthread_tryjoin_np()

int pthread_tryjoin_np ( pthread_t  thread,
void **  status 
)

Try to join a thread without blocking (GNU extension).

Parameters
threadThread to try to join.
statusOutput: exit value if joined, or unchanged if not yet terminated.
Returns
0 if joined, EBUSY if the thread has not yet terminated, or a positive error number on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_tryjoin_np.html