if (ret != 0)
                        rte_exit(EXIT_FAILURE, "Cannot create print-stats thread\n");
                snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN, "print-stats");
-               ret = pthread_setname_np(tid, thread_name);
+               ret = rte_thread_setname(tid, thread_name);
                if (ret != 0)
                        RTE_LOG(ERR, VHOST_CONFIG, "Cannot set print-stats name\n");
        }
 
 
                /* Set thread_name for aid in debugging.  */
                snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN, "print-stats");
-               ret = pthread_setname_np(tid, thread_name);
+               ret = rte_thread_setname(tid, thread_name);
                if (ret != 0)
                        RTE_LOG(ERR, VHOST_CONFIG,
                                "Cannot set print-stats name\n");
 
 
                /* Set thread_name for aid in debugging. */
                snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN, "print-xen-stats");
-               ret = pthread_setname_np(tid, thread_name);
+               ret = rte_thread_setname(tid, thread_name);
                if (ret != 0)
                        RTE_LOG(ERR, VHOST_CONFIG,
                                "Cannot set print-stats name\n");
 
  */
 void rte_thread_get_affinity(rte_cpuset_t *cpusetp);
 
+/**
+ * Set thread names.
+ *
+ * Macro to wrap `pthread_setname_np()` with a glibc version check.
+ * Only glibc >= 2.12 supports this feature.
+ *
+ * This macro only used for Linux, BSD does direct libc call.
+ * BSD libc version of function is `pthread_set_name_np()`.
+ */
+#if defined(__DOXYGEN__)
+#define rte_thread_setname(...) pthread_setname_np(__VA_ARGS__)
+#endif
+
+#if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
+#if __GLIBC_PREREQ(2, 12)
+#define rte_thread_setname(...) pthread_setname_np(__VA_ARGS__)
+#else
+#define rte_thread_setname(...) 0
+#endif
+#endif
 
 #ifdef __cplusplus
 }
 
                /* Set thread_name for aid in debugging. */
                snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN,
                        "lcore-slave-%d", i);
-               ret = pthread_setname_np(lcore_config[i].thread_id,
+               ret = rte_thread_setname(lcore_config[i].thread_id,
                                                thread_name);
                if (ret != 0)
                        RTE_LOG(ERR, EAL,
 
                /* Set thread_name for aid in debugging. */
                snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN,
                        "eal-intr-thread");
-               ret_1 = pthread_setname_np(intr_thread, thread_name);
+               ret_1 = rte_thread_setname(intr_thread, thread_name);
                if (ret_1 != 0)
                        RTE_LOG(ERR, EAL,
                        "Failed to set thread name for interrupt handling\n");
 
 
        /* Set thread_name for aid in debugging. */
        snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN, "pci-vfio-sync");
-       ret = pthread_setname_np(socket_thread, thread_name);
+       ret = rte_thread_setname(socket_thread, thread_name);
        if (ret)
                RTE_LOG(ERR, EAL,
                        "Failed to set thread name for secondary processes!\n");
 
         * Set thread_name for aid in debugging.
         */
        snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN, "hpet-msb-inc");
-       ret = pthread_setname_np(msb_inc_thread_id, thread_name);
+       ret = rte_thread_setname(msb_inc_thread_id, thread_name);
        if (ret != 0)
                RTE_LOG(ERR, EAL,
                        "ERROR: Cannot set HPET timer thread name!\n");