From ba24ef73934c2a84dc505cdffad5e41e904aec4b Mon Sep 17 00:00:00 2001 From: Garrett Wollman Date: Fri, 29 Jul 2011 21:33:10 -0400 Subject: [PATCH] util: simplify thread-name interface It appears that we don't actually need an interface to set the name of an arbitrary thread (which Mac OS can't do), so remove the afs_pthread_setname() interface and promote afs_pthread_setname_self() to the status of primary. Change-Id: I2d915d8165dac9ccfe0cb99630db657cb1473389 Reviewed-on: http://gerrit.openafs.org/5121 Reviewed-by: Derrick Brashear Tested-by: BuildBot --- src/util/afsutil_prototypes.h | 4 ---- src/util/pthread_threadname.c | 17 +++++------------ 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/src/util/afsutil_prototypes.h b/src/util/afsutil_prototypes.h index ff0f30c..c1f425a 100644 --- a/src/util/afsutil_prototypes.h +++ b/src/util/afsutil_prototypes.h @@ -138,11 +138,7 @@ extern int parseNetFiles(afs_uint32 addrbuf[], afs_uint32 maskbuf[], /* pthread_threadname.c */ #if defined(AFS_PTHREAD_ENV) && !defined(AFS_NT40_ENV) -extern void afs_pthread_setname(pthread_t thread, const char *threadname); extern void afs_pthread_setname_self(const char *threadname); -#elif defined(AFS_NT40_ENV) -# define afs_pthread_setname(thread, threadname) (void)0 -# define afs_pthread_setname_self(threadname) (void)0 #else /* Allow unconditional references to afs_pthread_setname_self to * reduce #ifdef spaghetti. diff --git a/src/util/pthread_threadname.c b/src/util/pthread_threadname.c index fbb2b80..b085b4a 100644 --- a/src/util/pthread_threadname.c +++ b/src/util/pthread_threadname.c @@ -35,31 +35,24 @@ # endif void -afs_pthread_setname(pthread_t thread, const char *threadname) +afs_pthread_setname_self(const char *threadname) { # if defined(HAVE_PTHREAD_SET_NAME_NP) /* FreeBSD style */ - pthread_set_name_np(thread, threadname); + pthread_set_name_np(pthread_self(), threadname); # elif defined(HAVE_PTHREAD_SETNAME_NP) # if PTHREAD_SETNAME_NP_ARGS == 3 /* DECthreads style */ - pthread_setname_np(thread, threadname, (void *)0); + pthread_setname_np(pthread_self(), threadname, (void *)0); # elif PTHREAD_SETNAME_NP_ARGS == 2 /* GNU libc on Linux style */ - pthread_setname_np(thread, threadname); + pthread_setname_np(pthread_self(), threadname); # elif PTHREAD_SETNAME_NP_ARGS == 1 /* Mac OS style */ - if (thread == pthread_self()) - pthread_setname_np(threadname); + pthread_setname_np(threadname); # else # error "Could not identify your pthread_setname_np() implementation" # endif # endif } - -void -afs_pthread_setname_self(const char *threadname) -{ - afs_pthread_setname(pthread_self(), threadname); -} #endif -- 1.9.4