---
name: "hwloc_cpuset_to_linux_libnuma_ulongs"
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_linux_libnuma_ulongs"
---

# hwloc\_cpuset\_to\_linux\_libnuma\_ulongs(3)

Interoperability with Linux libnuma unsigned long masks

Part of [hwlocality\_linux\_libnuma\_ulongs(3)](/hwlocality_linux_libnuma_ulongs/3.md).

## NAME

hwlocality\_linux\_libnuma\_ulongs - Interoperability with Linux libnuma unsigned long masks

## SYNOPSIS

### Functions

int **hwloc\_cpuset\_to\_linux\_libnuma\_ulongs** (**hwloc\_topology\_t** topology, **hwloc\_const\_cpuset\_t** cpuset, unsigned long \*mask, unsigned long \*maxnode)\
 int **hwloc\_nodeset\_to\_linux\_libnuma\_ulongs** (**hwloc\_topology\_t** topology, **hwloc\_const\_nodeset\_t** nodeset, unsigned long \*mask, unsigned long \*maxnode)\
 int **hwloc\_cpuset\_from\_linux\_libnuma\_ulongs** (**hwloc\_topology\_t** topology, **hwloc\_cpuset\_t** cpuset, const unsigned long \*mask, unsigned long maxnode)\
 int **hwloc\_nodeset\_from\_linux\_libnuma\_ulongs** (**hwloc\_topology\_t** topology, **hwloc\_nodeset\_t** nodeset, const unsigned long \*mask, unsigned long maxnode)\

## Detailed Description

This interface helps converting between Linux libnuma unsigned long masks and hwloc cpusets and nodesets.

**Note**

Topology topology must match the current machine.

The behavior of libnuma is undefined if the kernel is not NUMA-aware. (when CONFIG\_NUMA is not set in the kernel configuration). This helper and libnuma may thus not be strictly compatible in this case, which may be detected by checking whether numa\_available() returns -1.

## Function Documentation

### int hwloc\_cpuset\_from\_linux\_libnuma\_ulongs (hwloc\_topology\_t topology, hwloc\_cpuset\_t cpuset, const unsigned long \* mask, unsigned long maxnode) \[inline\]

Convert the array of unsigned long mask into hwloc CPU set. mask is a array of unsigned long that will be read. maxnode contains the maximal node number that may be read in mask.

This function may be used after calling get\_mempolicy or any other function that takes an array of unsigned long as output parameter (and possibly a maximal node number as input parameter).

**Returns**

0 on success.

\-1 on error, for instance if failing an internal reallocation.

### int hwloc\_cpuset\_to\_linux\_libnuma\_ulongs (hwloc\_topology\_t topology, hwloc\_const\_cpuset\_t cpuset, unsigned long \* mask, unsigned long \* maxnode) \[inline\]

Convert hwloc CPU set cpuset into the array of unsigned long mask. mask is the array of unsigned long that will be filled. maxnode contains the maximal node number that may be stored in mask. maxnode will be set to the maximal node number that was found, plus one.

This function may be used before calling set\_mempolicy, mbind, migrate\_pages or any other function that takes an array of unsigned long and a maximal node number as input parameter.

**Returns**

0\.

**Note**

On heterogeneous memory platforms, we may return multiple local NUMA nodes even if libnuma reports only one (usually the first one).

### int hwloc\_nodeset\_from\_linux\_libnuma\_ulongs (hwloc\_topology\_t topology, hwloc\_nodeset\_t nodeset, const unsigned long \* mask, unsigned long maxnode) \[inline\]

Convert the array of unsigned long mask into hwloc NUMA node set. mask is a array of unsigned long that will be read. maxnode contains the maximal node number that may be read in mask.

This function may be used after calling get\_mempolicy or any other function that takes an array of unsigned long as output parameter (and possibly a maximal node number as input parameter).

**Returns**

0 on success.

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

### int hwloc\_nodeset\_to\_linux\_libnuma\_ulongs (hwloc\_topology\_t topology, hwloc\_const\_nodeset\_t nodeset, unsigned long \* mask, unsigned long \* maxnode) \[inline\]

Convert hwloc NUMA node set nodeset into the array of unsigned long mask. mask is the array of unsigned long that will be filled. maxnode contains the maximal node number that may be stored in mask. maxnode will be set to the maximal node number that was found, plus one.

This function may be used before calling set\_mempolicy, mbind, migrate\_pages or any other function that takes an array of unsigned long and a maximal node number as input parameter.

**Returns**

0\.

## Author

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