Skip to content

Commit 669a1c0

Browse files
committed
cpukind: switch to struct hwloc_infos_s in the API
Signed-off-by: Brice Goglin <[email protected]>
1 parent 060604c commit 669a1c0

File tree

9 files changed

+127
-123
lines changed

9 files changed

+127
-123
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ Version 3.0.0
3636
root object together with other backends.
3737
+ The array and count of info attributes are now embedded in the new
3838
struct hwloc_infos_s.
39+
- hwloc_cpukinds_get_info() and hwloc_cpukinds_register() now manipulate
40+
infos as such a structure.
3941
* Tools
4042
+ lstopo has a new --osf option to tune the displaying of object
4143
attributes and units.

hwloc/cpukinds.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright © 2020-2022 Inria. All rights reserved.
2+
* Copyright © 2020-2023 Inria. All rights reserved.
33
* See COPYING in top-level directory.
44
*/
55

@@ -234,11 +234,10 @@ hwloc_internal_cpukinds_register(hwloc_topology_t topology, hwloc_cpuset_t cpuse
234234
int
235235
hwloc_cpukinds_register(hwloc_topology_t topology, hwloc_cpuset_t _cpuset,
236236
int forced_efficiency,
237-
unsigned nr_infos, struct hwloc_info_s *infos,
237+
struct hwloc_infos_s *infos,
238238
unsigned long flags)
239239
{
240240
hwloc_bitmap_t cpuset;
241-
struct hwloc_infos_s _infos;
242241
int err;
243242

244243
if (flags) {
@@ -258,9 +257,7 @@ hwloc_cpukinds_register(hwloc_topology_t topology, hwloc_cpuset_t _cpuset,
258257
if (forced_efficiency < 0)
259258
forced_efficiency = HWLOC_CPUKIND_EFFICIENCY_UNKNOWN;
260259

261-
_infos.array = infos;
262-
_infos.count = nr_infos;
263-
err = hwloc_internal_cpukinds_register(topology, cpuset, forced_efficiency, &_infos, HWLOC_CPUKINDS_REGISTER_FLAG_OVERWRITE_FORCED_EFFICIENCY);
260+
err = hwloc_internal_cpukinds_register(topology, cpuset, forced_efficiency, infos, HWLOC_CPUKINDS_REGISTER_FLAG_OVERWRITE_FORCED_EFFICIENCY);
264261
if (err < 0)
265262
return err;
266263

@@ -604,7 +601,7 @@ hwloc_cpukinds_get_info(hwloc_topology_t topology,
604601
unsigned id,
605602
hwloc_bitmap_t cpuset,
606603
int *efficiencyp,
607-
unsigned *nr_infosp, struct hwloc_info_s **infosp,
604+
struct hwloc_infos_s **infosp,
608605
unsigned long flags)
609606
{
610607
struct hwloc_internal_cpukind_s *kind;
@@ -627,10 +624,8 @@ hwloc_cpukinds_get_info(hwloc_topology_t topology,
627624
if (efficiencyp)
628625
*efficiencyp = kind->efficiency;
629626

630-
if (nr_infosp && infosp) {
631-
*nr_infosp = kind->infos.count;
632-
*infosp = kind->infos.array;
633-
}
627+
if (infosp)
628+
*infosp = &kind->infos;
634629
return 0;
635630
}
636631

include/hwloc/cpukinds.h

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright © 2020-2021 Inria. All rights reserved.
2+
* Copyright © 2020-2023 Inria. All rights reserved.
33
* See COPYING in top-level directory.
44
*/
55

@@ -118,12 +118,11 @@ hwloc_cpukinds_get_by_cpuset(hwloc_topology_t topology,
118118
* the efficiency of all kinds is set to \c -1,
119119
* and kinds are reported in no specific order.
120120
*
121-
* The array of info attributes (for instance the "CoreType",
121+
* If \p infosp is not \c NULL, it will receive a pointer to a structure
122+
* containing the array of info attributes (for instance "CoreType",
122123
* "FrequencyMaxMHz" or "FrequencyBaseMHz", see \ref topoattrs_cpukinds)
123-
* and its length are returned in \p infos or \p nr_infos.
124-
* The array belongs to the topology, it should not be freed or modified.
125-
*
126-
* If \p nr_infos or \p infos is \c NULL, no info is returned.
124+
* and its length.
125+
* This structure belongs to the hwloc library, it should not be freed or modified.
127126
*
128127
* \p flags must be \c 0 for now.
129128
*
@@ -136,7 +135,7 @@ hwloc_cpukinds_get_info(hwloc_topology_t topology,
136135
unsigned kind_index,
137136
hwloc_bitmap_t cpuset,
138137
int *efficiency,
139-
unsigned *nr_infos, struct hwloc_info_s **infos,
138+
struct hwloc_infos_s **infosp,
140139
unsigned long flags);
141140

142141
/** \brief Register a kind of CPU in the topology.
@@ -149,8 +148,8 @@ hwloc_cpukinds_get_info(hwloc_topology_t topology,
149148
* the ranking of all kinds if all of them have valid (and
150149
* different) efficiencies.
151150
*
152-
* The array \p infos of size \p nr_infos may be used to provide
153-
* info names and values describing this kind of PUs.
151+
* The array \p infos may be used to provide info names and values
152+
* describing this kind of PUs, or it may be \c NULL.
154153
*
155154
* \p flags must be \c 0 for now.
156155
*
@@ -180,7 +179,7 @@ HWLOC_DECLSPEC int
180179
hwloc_cpukinds_register(hwloc_topology_t topology,
181180
hwloc_bitmap_t cpuset,
182181
int forced_efficiency,
183-
unsigned nr_infos, struct hwloc_info_s *infos,
182+
struct hwloc_infos_s *infos,
184183
unsigned long flags);
185184

186185
/** @} */

0 commit comments

Comments
 (0)