@@ -527,3 +527,50 @@ AC_DEFUN([OVS_ENABLE_SPARSE],
527527 [ if test $ovs_cv_gnu_make_if = yes; then
528528 CC='$(if $(C),REAL_CC="'"$CC"'" CHECK="$(SPARSE) -I $(top_srcdir)/include/sparse $(SPARSEFLAGS) $(SPARSE_EXTRA_INCLUDES) " cgcc $(CGCCFLAGS),'"$CC"')'
529529 fi] ) ] )
530+
531+ dnl OVS_PTHREAD_SET_NAME
532+ dnl
533+ dnl This checks for three known variants of pthreads functions for setting
534+ dnl the name of the current thread:
535+ dnl
536+ dnl glibc: int pthread_setname_np(pthread_t, const char *name);
537+ dnl NetBSD: int pthread_setname_np(pthread_t, const char *format, void *arg);
538+ dnl FreeBSD: int pthread_set_name_np(pthread_t, const char *name);
539+ dnl
540+ dnl For glibc and FreeBSD, the arguments are just a thread and its name. For
541+ dnl NetBSD, 'format' is a printf() format string and 'arg' is an argument to
542+ dnl provide to it.
543+ dnl
544+ dnl This macro defines:
545+ dnl
546+ dnl glibc: HAVE_GLIBC_PTHREAD_SETNAME_NP
547+ dnl NetBSD: HAVE_NETBSD_PTHREAD_SETNAME_NP
548+ dnl FreeBSD: HAVE_PTHREAD_SET_NAME_NP
549+ AC_DEFUN ( [ OVS_CHECK_PTHREAD_SET_NAME] ,
550+ [ AC_CHECK_FUNCS ( [ pthread_set_name_np] )
551+ if test $ac_cv_func_pthread_set_name_np != yes; then
552+ AC_CACHE_CHECK (
553+ [ for pthread_setname_np() variant] ,
554+ [ ovs_cv_pthread_setname_np] ,
555+ [ AC_LINK_IFELSE (
556+ [ AC_LANG_PROGRAM ( [ #include <pthread.h>
557+ ] , [ pthread_setname_np(pthread_self(), "name");] ) ] ,
558+ [ ovs_cv_pthread_setname_np=glibc] ,
559+ [ AC_LINK_IFELSE (
560+ [ AC_LANG_PROGRAM ( [ #include <pthread.h>
561+ ] , [ pthread_setname_np(pthread_self(), "%s", "name");] ) ] ,
562+ [ ovs_cv_pthread_setname_np=netbsd] ,
563+ [ ovs_cv_pthread_setname_np=none] ) ] ) ] )
564+ case $ovs_cv_pthread_setname_np in # (
565+ glibc)
566+ AC_DEFINE (
567+ [ HAVE_GLIBC_PTHREAD_SETNAME_NP] , [ 1] ,
568+ [ Define to 1 if pthread_setname_np() is available and takes 2 parameters (like glibc).] )
569+ ;; # (
570+ netbsd)
571+ AC_DEFINE (
572+ [ HAVE_NETBSD_PTHREAD_SETNAME_NP] , [ 1] ,
573+ [ Define to 1 if pthread_setname_np() is available and takes 3 parameters (like NetBSD).] )
574+ ;;
575+ esac
576+ fi] )
0 commit comments