Skip to content

Commit 060604c

Browse files
committed
API: add hwloc_get_info_by_name()
It takes a struct hwloc_infos_s (while hwloc_obj_get_info_by_name() takes an object). Signed-off-by: Brice Goglin <[email protected]>
1 parent 6e41289 commit 060604c

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

doc/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ man3_object_info_attrsdir = $(man3dir)
349349
man3_object_info_attrs_DATA = \
350350
$(DOX_MAN_DIR)/man3/hwlocality_info_attr.3 \
351351
$(DOX_MAN_DIR)/man3/hwloc_obj_get_info_by_name.3 \
352+
$(DOX_MAN_DIR)/man3/hwloc_get_info_by_name.3 \
352353
$(DOX_MAN_DIR)/man3/hwloc_obj_add_info.3
353354

354355
man3_cpubindingdir = $(man3dir)

include/hwloc.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,14 @@ HWLOC_DECLSPEC int hwloc_type_sscanf(const char *string,
11351135
* @{
11361136
*/
11371137

1138-
/** \brief Search the given name in object infos and return the corresponding value.
1138+
/** \brief Search the given name in the object array of infos and return the corresponding value.
1139+
*
1140+
* Identical to hwloc_get_info_by_name() but operates on the infos of the given object.
1141+
*/
1142+
static __hwloc_inline const char *
1143+
hwloc_obj_get_info_by_name(hwloc_obj_t obj, const char *name) __hwloc_attribute_pure;
1144+
1145+
/** \brief Search the given name in the array of infos and return the corresponding value.
11391146
*
11401147
* If multiple info attributes match the given name, only the first one is returned.
11411148
*
@@ -1145,7 +1152,7 @@ HWLOC_DECLSPEC int hwloc_type_sscanf(const char *string,
11451152
* \note The string should not be freed by the caller, it belongs to the hwloc library.
11461153
*/
11471154
static __hwloc_inline const char *
1148-
hwloc_obj_get_info_by_name(hwloc_obj_t obj, const char *name) __hwloc_attribute_pure;
1155+
hwloc_get_info_by_name(struct hwloc_infos_s *infos, const char *name) __hwloc_attribute_pure;
11491156

11501157
/** \brief Add the given name and value pair to the given object info attributes.
11511158
*

include/hwloc/inlines.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright © 2009 CNRS
3-
* Copyright © 2009-2022 Inria. All rights reserved.
3+
* Copyright © 2009-2023 Inria. All rights reserved.
44
* Copyright © 2009-2012 Université Bordeaux
55
* Copyright © 2009-2010 Cisco Systems, Inc. All rights reserved.
66
* See COPYING in top-level directory.
@@ -108,18 +108,23 @@ hwloc_get_root_obj (hwloc_topology_t topology)
108108
}
109109

110110
static __hwloc_inline const char *
111-
hwloc_obj_get_info_by_name(hwloc_obj_t obj, const char *name)
111+
hwloc_get_info_by_name(struct hwloc_infos_s *infos, const char *name)
112112
{
113113
unsigned i;
114-
struct hwloc_infos_s *infos = &obj->infos;
115-
for(i=0; i<obj->infos.count; i++) {
114+
for(i=0; i<infos->count; i++) {
116115
struct hwloc_info_s *info = &infos->array[i];
117116
if (!strcmp(info->name, name))
118117
return info->value;
119118
}
120119
return NULL;
121120
}
122121

122+
static __hwloc_inline const char *
123+
hwloc_obj_get_info_by_name(hwloc_obj_t obj, const char *name)
124+
{
125+
return hwloc_get_info_by_name(&obj->infos, name);
126+
}
127+
123128
static __hwloc_inline void *
124129
hwloc_alloc_membind_policy(hwloc_topology_t topology, size_t len, hwloc_const_cpuset_t set, hwloc_membind_policy_t policy, int flags)
125130
{

include/hwloc/rename.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ extern "C" {
216216
#define hwloc_type_sscanf HWLOC_NAME(type_sscanf)
217217

218218
#define hwloc_obj_get_info_by_name HWLOC_NAME(obj_get_info_by_name)
219+
#define hwloc_get_info_by_name HWLOC_NAME(get_info_by_name)
219220
#define hwloc_obj_add_info HWLOC_NAME(obj_add_info)
220221

221222
#define HWLOC_CPUBIND_PROCESS HWLOC_NAME_CAPS(CPUBIND_PROCESS)

0 commit comments

Comments
 (0)