Skip to content

Commit

Permalink
Fix API of likwid_device_get_available
Browse files Browse the repository at this point in the history
likwid_device_get_available now returns the length of the list returned.
Previously the user didn't know how long the returned list was, so the
function was defacto useless.
  • Loading branch information
ipatix committed Nov 15, 2024
1 parent 513fdbb commit 686d9c4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/includes/likwid.h
Original file line number Diff line number Diff line change
Expand Up @@ -3379,13 +3379,14 @@ const char *likwid_device_type_name(LikwidDeviceType type) __attribute__ ((visib
@param [in] device Likwid device
*/
void likwid_device_fmt_pci(char *buf, size_t size, LikwidDevice_t device) __attribute__ ((visibility ("default") ));
/*! \brief Get available device strings
/*! \brief Get available device strings. If an error occurs, the out parameters are kept unchanged.
@params [in] type Likwid device type
@params [out] string list of all available devices for the type specified
@params [out] number of list entries.
@return error code (<0 on failure)
*/
int likwid_device_get_available(LikwidDeviceType type, char ***id_list) __attribute__((visibility ("default") ));
int likwid_device_get_available(LikwidDeviceType type, char ***id_list, size_t *id_list_count) __attribute__((visibility ("default") ));

/** @}*/

Expand Down
3 changes: 2 additions & 1 deletion src/likwid_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ void likwid_device_fmt_pci(char *buf, size_t size, LikwidDevice_t device)
snprintf(buf, size, "%08x:%02x:%02x.%01x", dom, bus, dev, func);
}

int likwid_device_get_available(LikwidDeviceType type, char ***id_list)
int likwid_device_get_available(LikwidDeviceType type, char ***id_list, size_t *id_list_count)
{
if (type <= DEVICE_TYPE_INVALID || type >= MAX_DEVICE_TYPE || !id_list)
return -EINVAL;
Expand Down Expand Up @@ -587,5 +587,6 @@ int likwid_device_get_available(LikwidDeviceType type, char ***id_list)
}

*id_list = name_list;
*id_list_count = id_count;
return 0;
}

0 comments on commit 686d9c4

Please sign in to comment.