]> git.proxmox.com Git - mirror_frr.git/commitdiff
lib: make pthread_set[_]name_np test OS agnostic
authorDavid Lamparter <equinox@opensourcerouting.org>
Tue, 4 Sep 2018 11:15:56 +0000 (13:15 +0200)
committerDavid Lamparter <equinox@opensourcerouting.org>
Sat, 8 Sep 2018 23:16:25 +0000 (01:16 +0200)
FreeBSD supports pthread_set_name_np() too.  Also, pthread_set_name_np()
returns void.  And NetBSD has pthread_setname_np() with an extra arg...

Signed-off-by: David Lamparter <equinox@diac24.net>
configure.ac
lib/frr_pthread.c

index 779c7ebb6a12eeefddbed5aca1a1c275a3a7840b..294d3bf3252e6e020fdc7142404d8785bb7a16f8 100755 (executable)
@@ -818,6 +818,7 @@ int main(int argc, char **argv) {
 AC_CHECK_HEADERS([pthread_np.h],,, [
 #include <pthread.h>
 ])
+AC_CHECK_FUNCS([pthread_setname_np pthread_set_name_np])
 
 dnl Utility macro to avoid retyping includes all the time
 m4_define([FRR_INCLUDES],
index 7cae889ca9b83461ea291bcb0913877b31fff6d9..d48b23f38a9a1804831cfa81f1541d03260adc9f 100644 (file)
@@ -166,10 +166,14 @@ int frr_pthread_set_name(struct frr_pthread *fpt, const char *name,
                pthread_mutex_lock(&fpt->mtx);
                snprintf(fpt->os_name, OS_THREAD_NAMELEN, "%s", os_name);
                pthread_mutex_unlock(&fpt->mtx);
-#ifdef GNU_LINUX
+#ifdef HAVE_PTHREAD_SETNAME_NP
+# ifdef GNU_LINUX
                ret = pthread_setname_np(fpt->thread, fpt->os_name);
-#elif defined(OPEN_BSD)
-               ret = pthread_set_name_np(fpt->thread, fpt->os_name);
+# else /* NetBSD */
+               ret = pthread_setname_np(fpt->thread, fpt->os_name, NULL);
+# endif
+#elif defined(HAVE_PTHREAD_SET_NAME_NP)
+               pthread_set_name_np(fpt->thread, fpt->os_name);
 #endif
        }