Introduce rte_thread_getname() API to get the thread name
and implement it for Linux and FreeBSD.
FreeBSD does not support getting the thread name.
One of the consumers of this API will be the trace subsystem where
it used as an informative purpose.
Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: David Marchand <david.marchand@redhat.com>
pthread_set_name_np(id, name);
return 0;
}
+
+int rte_thread_getname(pthread_t id, char *name, size_t len)
+{
+ RTE_SET_USED(id);
+ RTE_SET_USED(name);
+ RTE_SET_USED(len);
+
+ return -ENOTSUP;
+}
*/
int rte_thread_setname(pthread_t id, const char *name);
+/**
+ * Get thread name.
+ *
+ * @note It fails with glibc < 2.12.
+ *
+ * @param id
+ * Thread id.
+ * @param name
+ * Thread name to set.
+ * @param len
+ * Thread name buffer length.
+ * @return
+ * On success, return 0; otherwise return a negative value.
+ */
+__rte_experimental
+int rte_thread_getname(pthread_t id, char *name, size_t len);
+
/**
* Create a control thread.
*
RTE_SET_USED(name);
return -ret;
}
+
+int rte_thread_getname(pthread_t id, char *name, size_t len)
+{
+ int ret = ENOSYS;
+#if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
+#if __GLIBC_PREREQ(2, 12)
+ ret = pthread_getname_np(id, name, len);
+#endif
+#endif
+ RTE_SET_USED(id);
+ RTE_SET_USED(name);
+ RTE_SET_USED(len);
+ return -ret;
+
+}
# added in 20.05
rte_log_can_log;
+ rte_thread_getname;
};