util: simplify thread-name interface
authorGarrett Wollman <wollman@csail.mit.edu>
Sat, 30 Jul 2011 01:33:10 +0000 (21:33 -0400)
committerDerrick Brashear <shadow@dementix.org>
Wed, 14 Dec 2011 15:56:39 +0000 (07:56 -0800)
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 <shadow@dementix.org>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

src/util/afsutil_prototypes.h
src/util/pthread_threadname.c

index ff0f30c..c1f425a 100644 (file)
@@ -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.
index fbb2b80..b085b4a 100644 (file)
 # 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