---
name: "hwloc_cpuset_from_glibc_sched_affinity"
section: "3"
platform: "linux"
package: "hwloc"
version: "2.15.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/hwlocality_glibc_sched"
---

# hwloc\_cpuset\_from\_glibc\_sched\_affinity(3)

Interoperability with glibc sched affinity

Part of [hwlocality\_glibc\_sched(3)](/hwlocality_glibc_sched/3.md).

## NAME

hwlocality\_glibc\_sched - Interoperability with glibc sched affinity

## SYNOPSIS

### Functions

int **hwloc\_cpuset\_to\_glibc\_sched\_affinity** (**hwloc\_topology\_t** topology, **hwloc\_const\_cpuset\_t** hwlocset, cpu\_set\_t \*schedset, size\_t schedsetsize)\
 int **hwloc\_cpuset\_from\_glibc\_sched\_affinity** (**hwloc\_topology\_t** topology, **hwloc\_cpuset\_t** hwlocset, const cpu\_set\_t \*schedset, size\_t schedsetsize)\

## Detailed Description

This interface offers ways to convert between hwloc cpusets and glibc cpusets such as those manipulated by sched\_getaffinity() or pthread\_attr\_setaffinity\_np().

**Note**

Topology topology must match the current machine.

## Function Documentation

### int hwloc\_cpuset\_from\_glibc\_sched\_affinity (hwloc\_topology\_t topology, hwloc\_cpuset\_t hwlocset, const cpu\_set\_t \* schedset, size\_t schedsetsize) \[inline\]

Convert glibc sched affinity CPU set schedset into hwloc CPU set. This function may be used before calling sched\_setaffinity or any other function that takes a cpu\_set\_t as input parameter.

schedsetsize should be sizeof(cpu\_set\_t) unless schedset was dynamically allocated with CPU\_ALLOC

**Returns**

0 on success.

\-1 with errno set to ENOMEM if some internal reallocation failed.

### int hwloc\_cpuset\_to\_glibc\_sched\_affinity (hwloc\_topology\_t topology, hwloc\_const\_cpuset\_t hwlocset, cpu\_set\_t \* schedset, size\_t schedsetsize) \[inline\]

Convert hwloc CPU set toposet into glibc sched affinity CPU set schedset. This function may be used before calling sched\_setaffinity or any other function that takes a cpu\_set\_t as input parameter.

schedsetsize should be sizeof(cpu\_set\_t) unless schedset was dynamically allocated with CPU\_ALLOC

**Returns**

0\.

## Author

Generated automatically by Doxygen for Hardware Locality (hwloc) from the source code.
