---
name: "hwloc_cpuset_not"
section: "3"
platform: "linux"
package: "libhwloc-doc"
version: "1.0.2-2"
release: "Debian 6.0 (Squeeze)"
platforms: ["linux"]
url: "https://new.carta.tech/hwlocality_cpuset"
---

# hwloc\_cpuset\_not(3)

Part of [hwlocality\_cpuset(3)](/hwlocality_cpuset/3.md).

## NAME

The Cpuset API -

### Defines

\#define **hwloc\_cpuset\_foreach\_begin**(cpu, set)\
 *Loop macro iterating on CPU set* `set`*.*  #define **hwloc\_cpuset\_foreach\_end**()\
 *End of loop. Needs a terminating ';'.*

### Typedefs

typedef struct hwloc\_cpuset\_s \* **hwloc\_cpuset\_t**\
 *Set of CPUs represented as an opaque pointer to an internal bitmask.*  typedef struct hwloc\_cpuset\_s \* **hwloc\_const\_cpuset\_t**\

### Functions

HWLOC\_DECLSPEC **hwloc\_cpuset\_t** **hwloc\_cpuset\_alloc** (void) \_\_hwloc\_attribute\_malloc\
 *Allocate a new empty CPU set.*  HWLOC\_DECLSPEC void **hwloc\_cpuset\_free** (**hwloc\_cpuset\_t** set)\
 *Free CPU set* `set`*.*  HWLOC\_DECLSPEC **hwloc\_cpuset\_t** **hwloc\_cpuset\_dup** (**hwloc\_const\_cpuset\_t** set) \_\_hwloc\_attribute\_malloc\
 *Duplicate CPU set* `set` *by allocating a new CPU set and copying* `set's` *contents.*  HWLOC\_DECLSPEC void **hwloc\_cpuset\_copy** (**hwloc\_cpuset\_t** dst, **hwloc\_const\_cpuset\_t** src)\
 *Copy the contents of CPU set* `src` *into the already allocated CPU set* `dst`*.*  HWLOC\_DECLSPEC int **hwloc\_cpuset\_snprintf** (char \*\_\_hwloc\_restrict buf, size\_t buflen, **hwloc\_const\_cpuset\_t** set)\
 *Stringify a cpuset.*  HWLOC\_DECLSPEC int **hwloc\_cpuset\_asprintf** (char \*\*strp, **hwloc\_const\_cpuset\_t** set)\
 *Stringify a cpuset into a newly allocated string.*  HWLOC\_DECLSPEC int **hwloc\_cpuset\_from\_string** (**hwloc\_cpuset\_t** set, const char \*\_\_hwloc\_restrict string)\
 *Parse a cpuset string and stores it in CPU set* `set`*.*  HWLOC\_DECLSPEC void **hwloc\_cpuset\_zero** (**hwloc\_cpuset\_t** set)\
 *Empty the CPU set* `set`*.*  HWLOC\_DECLSPEC void **hwloc\_cpuset\_fill** (**hwloc\_cpuset\_t** set)\
 *Fill CPU set* `set` *with all possible CPUs (even if those CPUs don't exist or are otherwise unavailable).*  HWLOC\_DECLSPEC void **hwloc\_cpuset\_from\_ulong** (**hwloc\_cpuset\_t** set, unsigned long mask)\
 *Setup CPU set* `set` *from unsigned long* `mask`*.*  HWLOC\_DECLSPEC void **hwloc\_cpuset\_from\_ith\_ulong** (**hwloc\_cpuset\_t** set, unsigned i, unsigned long mask)\
 *Setup CPU set* `set` *from unsigned long* `mask` *used as* `i` *-th subset.*  HWLOC\_DECLSPEC unsigned long **hwloc\_cpuset\_to\_ulong** (**hwloc\_const\_cpuset\_t** set) \_\_hwloc\_attribute\_pure\
 *Convert the beginning part of CPU set* `set` *into unsigned long* `mask`*.*  HWLOC\_DECLSPEC unsigned long **hwloc\_cpuset\_to\_ith\_ulong** (**hwloc\_const\_cpuset\_t** set, unsigned i) \_\_hwloc\_attribute\_pure\
 *Convert the* `i` *-th subset of CPU set* `set` *into unsigned long mask.*  HWLOC\_DECLSPEC void **hwloc\_cpuset\_cpu** (**hwloc\_cpuset\_t** set, unsigned cpu)\
 *Empty the CPU set* `set` *and add CPU* `cpu`*.*  HWLOC\_DECLSPEC void **hwloc\_cpuset\_all\_but\_cpu** (**hwloc\_cpuset\_t** set, unsigned cpu)\
 *Empty the CPU set* `set` *and add all but the CPU* `cpu`*.*  HWLOC\_DECLSPEC void **hwloc\_cpuset\_set** (**hwloc\_cpuset\_t** set, unsigned cpu)\
 *Add CPU* `cpu` *in CPU set* `set`*.*  HWLOC\_DECLSPEC void **hwloc\_cpuset\_set\_range** (**hwloc\_cpuset\_t** set, unsigned begincpu, unsigned endcpu)\
 *Add CPUs from* `begincpu` *to* `endcpu` *in CPU set* `set`*.*  HWLOC\_DECLSPEC void **hwloc\_cpuset\_clr** (**hwloc\_cpuset\_t** set, unsigned cpu)\
 *Remove CPU* `cpu` *from CPU set* `set`*.*  HWLOC\_DECLSPEC void **hwloc\_cpuset\_clr\_range** (**hwloc\_cpuset\_t** set, unsigned begincpu, unsigned endcpu)\
 *Remove CPUs from* `begincpu` *to* `endcpu` *in CPU set* `set`*.*  HWLOC\_DECLSPEC int **hwloc\_cpuset\_isset** (**hwloc\_const\_cpuset\_t** set, unsigned cpu) \_\_hwloc\_attribute\_pure\
 *Test whether CPU* `cpu` *is part of set* `set`*.*  HWLOC\_DECLSPEC int **hwloc\_cpuset\_iszero** (**hwloc\_const\_cpuset\_t** set) \_\_hwloc\_attribute\_pure\
 *Test whether set* `set` *is empty.*  HWLOC\_DECLSPEC int **hwloc\_cpuset\_isfull** (**hwloc\_const\_cpuset\_t** set) \_\_hwloc\_attribute\_pure\
 *Test whether set* `set` *is completely full.*  HWLOC\_DECLSPEC int **hwloc\_cpuset\_isequal** (**hwloc\_const\_cpuset\_t** set1, **hwloc\_const\_cpuset\_t** set2) \_\_hwloc\_attribute\_pure\
 *Test whether set* `set1` *is equal to set* `set2`*.*  HWLOC\_DECLSPEC int **hwloc\_cpuset\_intersects** (**hwloc\_const\_cpuset\_t** set1, **hwloc\_const\_cpuset\_t** set2) \_\_hwloc\_attribute\_pure\
 *Test whether sets* `set1` *and* `set2` *intersects.*  HWLOC\_DECLSPEC int **hwloc\_cpuset\_isincluded** (**hwloc\_const\_cpuset\_t** sub\_set, **hwloc\_const\_cpuset\_t** super\_set) \_\_hwloc\_attribute\_pure\
 *Test whether set* `sub_set` *is part of set* `super_set`*.*  HWLOC\_DECLSPEC void **hwloc\_cpuset\_or** (**hwloc\_cpuset\_t** res, **hwloc\_const\_cpuset\_t** set1, **hwloc\_const\_cpuset\_t** set2)\
 *Or sets* `set1` *and* `set2` *and store the result in set* `res`*.*  HWLOC\_DECLSPEC void **hwloc\_cpuset\_and** (**hwloc\_cpuset\_t** res, **hwloc\_const\_cpuset\_t** set1, **hwloc\_const\_cpuset\_t** set2)\
 *And sets* `set1` *and* `set2` *and store the result in set* `res`*.*  HWLOC\_DECLSPEC void **hwloc\_cpuset\_andnot** (**hwloc\_cpuset\_t** res, **hwloc\_const\_cpuset\_t** set1, **hwloc\_const\_cpuset\_t** set2)\
 *And set* `set1` *and the negation of* `set2` *and store the result in set* `res`*.*  HWLOC\_DECLSPEC void **hwloc\_cpuset\_xor** (**hwloc\_cpuset\_t** res, **hwloc\_const\_cpuset\_t** set1, **hwloc\_const\_cpuset\_t** set2)\
 *Xor sets* `set1` *and* `set2` *and store the result in set* `res`*.*  HWLOC\_DECLSPEC void **hwloc\_cpuset\_not** (**hwloc\_cpuset\_t** res, **hwloc\_const\_cpuset\_t** set)\
 *Negate set* `set` *and store the result in set* `res`*.*  HWLOC\_DECLSPEC int **hwloc\_cpuset\_first** (**hwloc\_const\_cpuset\_t** set) \_\_hwloc\_attribute\_pure\
 *Compute the first CPU (least significant bit) in CPU set* `set`*.*  HWLOC\_DECLSPEC int **hwloc\_cpuset\_last** (**hwloc\_const\_cpuset\_t** set) \_\_hwloc\_attribute\_pure\
 *Compute the last CPU (most significant bit) in CPU set* `set`*.*  HWLOC\_DECLSPEC int **hwloc\_cpuset\_next** (**hwloc\_const\_cpuset\_t** set, unsigned prev\_cpu) \_\_hwloc\_attribute\_pure\
 *Compute the next CPU in CPU set* `set` *which is after CPU* `prev_cpu`*.*  HWLOC\_DECLSPEC void **hwloc\_cpuset\_singlify** (**hwloc\_cpuset\_t** set)\
 *Keep a single CPU among those set in CPU set* `set`*.*  HWLOC\_DECLSPEC int **hwloc\_cpuset\_compare\_first** (**hwloc\_const\_cpuset\_t** set1, **hwloc\_const\_cpuset\_t** set2) \_\_hwloc\_attribute\_pure\
 *Compare CPU sets* `set1` *and* `set2` *using their lowest index CPU.*  HWLOC\_DECLSPEC int **hwloc\_cpuset\_compare** (**hwloc\_const\_cpuset\_t** set1, **hwloc\_const\_cpuset\_t** set2) \_\_hwloc\_attribute\_pure\
 *Compare CPU sets* `set1` *and* `set2` *using their highest index CPU.*  HWLOC\_DECLSPEC int **hwloc\_cpuset\_weight** (**hwloc\_const\_cpuset\_t** set) \_\_hwloc\_attribute\_pure\
 *Compute the 'weight' of CPU set* `set` *(i.e., number of CPUs that are in the set).*

## Detailed Description

For use in hwloc itself, a hwloc\_cpuset\_t represents a set of logical processors.

**Note:**

cpusets are indexed by OS logical processor number.

## Define Documentation

### #define hwloc\_cpuset\_foreach\_begin(cpu, set)

Loop macro iterating on CPU set `set`. `cpu` is the loop variable; it should be an unsigned int. The first iteration will set `cpu` to the lowest index CPU in the set. Successive iterations will iterate through, in order, all remaining CPUs that in the set. To be specific: each iteration will return a value for `cpu` such that hwloc\_cpuset\_isset(set, cpu) is true.

### #define hwloc\_cpuset\_foreach\_end()

End of loop. Needs a terminating ';'. **See also:**

**hwloc\_cpuset\_foreach\_begin**

## Typedef Documentation

### typedef struct hwloc\_cpuset\_s\* hwloc\_const\_cpuset\_t

### typedef struct hwloc\_cpuset\_s\* hwloc\_cpuset\_t

Set of CPUs represented as an opaque pointer to an internal bitmask.

## Function Documentation

### HWLOC\_DECLSPEC void hwloc\_cpuset\_all\_but\_cpu (hwloc\_cpuset\_t set, unsigned cpu)

Empty the CPU set `set` and add all but the CPU `cpu`.

### HWLOC\_DECLSPEC hwloc\_cpuset\_t hwloc\_cpuset\_alloc (void)

Allocate a new empty CPU set. **Returns:**

A valid CPU set or NULL.

The CPU set should be freed by a corresponding call to **hwloc\_cpuset\_free()**.

### HWLOC\_DECLSPEC void hwloc\_cpuset\_and (hwloc\_cpuset\_t res, hwloc\_const\_cpuset\_t set1, hwloc\_const\_cpuset\_t set2)

And sets `set1` and `set2` and store the result in set `res`.

### HWLOC\_DECLSPEC void hwloc\_cpuset\_andnot (hwloc\_cpuset\_t res, hwloc\_const\_cpuset\_t set1, hwloc\_const\_cpuset\_t set2)

And set `set1` and the negation of `set2` and store the result in set `res`.

### HWLOC\_DECLSPEC int hwloc\_cpuset\_asprintf (char \*\* strp, hwloc\_const\_cpuset\_t set)

Stringify a cpuset into a newly allocated string. **Returns:**

the number of character that were actually written (not including the ending \\0).

### HWLOC\_DECLSPEC void hwloc\_cpuset\_clr (hwloc\_cpuset\_t set, unsigned cpu)

Remove CPU `cpu` from CPU set `set`.

### HWLOC\_DECLSPEC void hwloc\_cpuset\_clr\_range (hwloc\_cpuset\_t set, unsigned begincpu, unsigned endcpu)

Remove CPUs from `begincpu` to `endcpu` in CPU set `set`.

### HWLOC\_DECLSPEC int hwloc\_cpuset\_compare (hwloc\_const\_cpuset\_t set1, hwloc\_const\_cpuset\_t set2)

Compare CPU sets `set1` and `set2` using their highest index CPU. Higher most significant bit is higher. The empty CPU set is considered lower than anything.

### HWLOC\_DECLSPEC int hwloc\_cpuset\_compare\_first (hwloc\_const\_cpuset\_t set1, hwloc\_const\_cpuset\_t set2)

Compare CPU sets `set1` and `set2` using their lowest index CPU. Smaller least significant bit is smaller. The empty CPU set is considered higher than anything.

### HWLOC\_DECLSPEC void hwloc\_cpuset\_copy (hwloc\_cpuset\_t dst, hwloc\_const\_cpuset\_t src)

Copy the contents of CPU set `src` into the already allocated CPU set `dst`.

### HWLOC\_DECLSPEC void hwloc\_cpuset\_cpu (hwloc\_cpuset\_t set, unsigned cpu)

Empty the CPU set `set` and add CPU `cpu`.

### HWLOC\_DECLSPEC hwloc\_cpuset\_t hwloc\_cpuset\_dup (hwloc\_const\_cpuset\_t set)

Duplicate CPU set `set` by allocating a new CPU set and copying `set's` contents.

### HWLOC\_DECLSPEC void hwloc\_cpuset\_fill (hwloc\_cpuset\_t set)

Fill CPU set `set` with all possible CPUs (even if those CPUs don't exist or are otherwise unavailable).

### HWLOC\_DECLSPEC int hwloc\_cpuset\_first (hwloc\_const\_cpuset\_t set)

Compute the first CPU (least significant bit) in CPU set `set`. **Returns:**

\-1 if no CPU is set.

### HWLOC\_DECLSPEC void hwloc\_cpuset\_free (hwloc\_cpuset\_t set)

Free CPU set `set`.

### HWLOC\_DECLSPEC void hwloc\_cpuset\_from\_ith\_ulong (hwloc\_cpuset\_t set, unsigned i, unsigned long mask)

Setup CPU set `set` from unsigned long `mask` used as `i` -th subset.

### HWLOC\_DECLSPEC int hwloc\_cpuset\_from\_string (hwloc\_cpuset\_t set, const char \*\_\_hwloc\_restrict string)

Parse a cpuset string and stores it in CPU set `set`. Must start and end with a digit.

### HWLOC\_DECLSPEC void hwloc\_cpuset\_from\_ulong (hwloc\_cpuset\_t set, unsigned long mask)

Setup CPU set `set` from unsigned long `mask`.

### HWLOC\_DECLSPEC int hwloc\_cpuset\_intersects (hwloc\_const\_cpuset\_t set1, hwloc\_const\_cpuset\_t set2)

Test whether sets `set1` and `set2` intersects.

### HWLOC\_DECLSPEC int hwloc\_cpuset\_isequal (hwloc\_const\_cpuset\_t set1, hwloc\_const\_cpuset\_t set2)

Test whether set `set1` is equal to set `set2`.

### HWLOC\_DECLSPEC int hwloc\_cpuset\_isfull (hwloc\_const\_cpuset\_t set)

Test whether set `set` is completely full.

### HWLOC\_DECLSPEC int hwloc\_cpuset\_isincluded (hwloc\_const\_cpuset\_t sub\_set, hwloc\_const\_cpuset\_t super\_set)

Test whether set `sub_set` is part of set `super_set`.

### HWLOC\_DECLSPEC int hwloc\_cpuset\_isset (hwloc\_const\_cpuset\_t set, unsigned cpu)

Test whether CPU `cpu` is part of set `set`.

### HWLOC\_DECLSPEC int hwloc\_cpuset\_iszero (hwloc\_const\_cpuset\_t set)

Test whether set `set` is empty.

### HWLOC\_DECLSPEC int hwloc\_cpuset\_last (hwloc\_const\_cpuset\_t set)

Compute the last CPU (most significant bit) in CPU set `set`. **Returns:**

\-1 if no CPU is set.

### HWLOC\_DECLSPEC int hwloc\_cpuset\_next (hwloc\_const\_cpuset\_t set, unsigned prev\_cpu)

Compute the next CPU in CPU set `set` which is after CPU `prev_cpu`. **Returns:**

\-1 if no CPU with higher index is set.

### HWLOC\_DECLSPEC void hwloc\_cpuset\_not (hwloc\_cpuset\_t res, hwloc\_const\_cpuset\_t set)

Negate set `set` and store the result in set `res`.

### HWLOC\_DECLSPEC void hwloc\_cpuset\_or (hwloc\_cpuset\_t res, hwloc\_const\_cpuset\_t set1, hwloc\_const\_cpuset\_t set2)

Or sets `set1` and `set2` and store the result in set `res`.

### HWLOC\_DECLSPEC void hwloc\_cpuset\_set (hwloc\_cpuset\_t set, unsigned cpu)

Add CPU `cpu` in CPU set `set`.

### HWLOC\_DECLSPEC void hwloc\_cpuset\_set\_range (hwloc\_cpuset\_t set, unsigned begincpu, unsigned endcpu)

Add CPUs from `begincpu` to `endcpu` in CPU set `set`.

### HWLOC\_DECLSPEC void hwloc\_cpuset\_singlify (hwloc\_cpuset\_t set)

Keep a single CPU among those set in CPU set `set`. May be useful before binding so that the process does not have a chance of migrating between multiple logical CPUs in the original mask.

### HWLOC\_DECLSPEC int hwloc\_cpuset\_snprintf (char \*\_\_hwloc\_restrict buf, size\_t buflen, hwloc\_const\_cpuset\_t set)

Stringify a cpuset. Up to `buflen` characters may be written in buffer `buf`.

**Returns:**

the number of character that were actually written if not truncating, or that would have been written (not including the ending \\0).

### HWLOC\_DECLSPEC unsigned long hwloc\_cpuset\_to\_ith\_ulong (hwloc\_const\_cpuset\_t set, unsigned i)

Convert the `i` -th subset of CPU set `set` into unsigned long mask.

### HWLOC\_DECLSPEC unsigned long hwloc\_cpuset\_to\_ulong (hwloc\_const\_cpuset\_t set)

Convert the beginning part of CPU set `set` into unsigned long `mask`.

### HWLOC\_DECLSPEC int hwloc\_cpuset\_weight (hwloc\_const\_cpuset\_t set)

Compute the 'weight' of CPU set `set` (i.e., number of CPUs that are in the set). **Returns:**

the number of CPUs that are in the set.

### HWLOC\_DECLSPEC void hwloc\_cpuset\_xor (hwloc\_cpuset\_t res, hwloc\_const\_cpuset\_t set1, hwloc\_const\_cpuset\_t set2)

Xor sets `set1` and `set2` and store the result in set `res`.

### HWLOC\_DECLSPEC void hwloc\_cpuset\_zero (hwloc\_cpuset\_t set)

Empty the CPU set `set`.

## Author

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