AC_DEFINE(
HAVE_PTHREAD_SETNAME_NP_1ARG, 1,
[Define to 1 if pthread_setname_np takes a single argument.])
+ else
+ AC_CACHE_CHECK(
+ [whether pthread_setname_np takes three arguments],
+ [emacs_cv_pthread_setname_np_3arg],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include <pthread.h>]],
+ [[pthread_setname_np (0, "%s", "a");]])],
+ [emacs_cv_pthread_setname_np_3arg=yes],
+ [emacs_cv_pthread_setname_np_3arg=no])])
+ if test "$emacs_cv_pthread_setname_np_3arg" = "yes"; then
+ AC_DEFINE(
+ HAVE_PTHREAD_SETNAME_NP_3ARG, 1,
+ [Define to 1 if pthread_setname_np takes three arguments.])
+ fi
fi
fi
char p_name[TASK_COMM_LEN];
strncpy (p_name, name, TASK_COMM_LEN - 1);
p_name[TASK_COMM_LEN - 1] = '\0';
- #ifdef HAVE_PTHREAD_SETNAME_NP_1ARG
+# ifdef HAVE_PTHREAD_SETNAME_NP_1ARG
pthread_setname_np (p_name);
- #else
+# elif defined HAVE_PTHREAD_SETNAME_NP_3ARG
+ pthread_setname_np (pthread_self (), "%s", p_name);
+# else
pthread_setname_np (pthread_self (), p_name);
- #endif
+# endif
#endif
}