---
name: "hwloc_obj_cpuset_snprintf"
section: "3"
platform: "linux"
package: "libhwloc-doc"
version: "1.11.12-3"
release: "Debian 10 (Buster)"
platforms: ["linux"]
url: "https://new.carta.tech/hwlocality_object_strings"
---

# hwloc\_obj\_cpuset\_snprintf(3)

Part of [hwlocality\_object\_strings(3)](/hwlocality_object_strings/3.md).

## NAME

hwlocality\_object\_strings

## SYNOPSIS

### Functions

const char \* **hwloc\_obj\_type\_string** (**hwloc\_obj\_type\_t** type)\
 int **hwloc\_obj\_type\_snprintf** (char \*restrict string, size\_t size, **hwloc\_obj\_t** obj, int verbose)\
 int **hwloc\_obj\_attr\_snprintf** (char \*restrict string, size\_t size, **hwloc\_obj\_t** obj, const char \*restrict separator, int verbose)\
 int **hwloc\_obj\_cpuset\_snprintf** (char \*restrict str, size\_t size, size\_t nobj, const **hwloc\_obj\_t** \*restrict objs)\
 int **hwloc\_obj\_type\_sscanf** (const char \*string, **hwloc\_obj\_type\_t** \*typep, int \*depthattrp, void \*typeattrp, size\_t typeattrsize)\

## Detailed Description

## Function Documentation

### int hwloc\_obj\_attr\_snprintf (char \*restrict string, size\_t size, hwloc\_obj\_t obj, const char \*restrict separator, int verbose)

Stringify the attributes of a given topology object into a human-readable form. Attribute values are separated by `separator`.

Only the major attributes are printed in non-verbose mode.

If `size` is 0, `string` may safely be `NULL`.

**Returns:**

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

### int hwloc\_obj\_cpuset\_snprintf (char \*restrict str, size\_t size, size\_t nobj, const hwloc\_obj\_t \*restrict objs)

Stringify the cpuset containing a set of objects. If `size` is 0, `string` may safely be `NULL`.

**Returns:**

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

### int hwloc\_obj\_type\_snprintf (char \*restrict string, size\_t size, hwloc\_obj\_t obj, int verbose)

Stringify the type of a given topology object into a human-readable form. Contrary to **hwloc\_obj\_type\_string()**, this function includes object-specific attributes (such as the Group depth, the Bridge type, or OS device type) in the output, and it requires the caller to provide the output buffer.

The output is guaranteed to be the same for all objects of a same topology level.

If `size` is 0, `string` may safely be `NULL`.

**Returns:**

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

### int hwloc\_obj\_type\_sscanf (const char \* string, hwloc\_obj\_type\_t \* typep, int \* depthattrp, void \* typeattrp, size\_t typeattrsize)

Return an object type and attributes from a type string. Convert strings such as 'Package' or 'Cache' into the corresponding types. Matching is case-insensitive, and only the first letters are actually required to match.

This function is guaranteed to match any string returned by **hwloc\_obj\_type\_string()** or **hwloc\_obj\_type\_snprintf()**.

Types that have specific attributes, for instance caches and groups, may be returned in `depthattrp` and `typeattrp`. They are ignored when these pointers are `NULL`.

For instance 'L2i' or 'L2iCache' would return type HWLOC\_OBJ\_CACHE in `typep`, 2 in `depthattrp`, and HWLOC\_OBJ\_CACHE\_TYPE\_INSTRUCTION in `typeattrp` (this last pointer should point to a hwloc\_obj\_cache\_type\_t). 'Group3' would return type HWLOC\_OBJ\_GROUP type and 3 in `depthattrp`. Attributes that are not specified in the string (for instance 'Group' without a depth, or 'L2Cache' without a cache type) are set to -1.

`typeattrp` is only filled if the size specified in `typeattrsize` is large enough. It is currently only used for caches, and the required size is at least the size of hwloc\_obj\_cache\_type\_t.

**Returns:**

0 if a type was correctly identified, otherwise -1.

**Note:**

This is an extended version of the now deprecated hwloc\_obj\_type\_of\_string()

### const char\* hwloc\_obj\_type\_string (hwloc\_obj\_type\_t type)

Return a constant stringified object type. This function is the basic way to convert a generic type into a string.

**hwloc\_obj\_type\_snprintf()** may return a more precise output for a specific object, but it requires the caller to provide the output buffer.

## Author

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