From 0f7572ad8cac5350749b2addacda06a2316569cb Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sun, 22 Aug 2004 01:16:00 +0000 Subject: [PATCH] work around gettid warning spam in valgrind --- .../src/archutils/Unix/LinuxThreadHelpers.cpp | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/stepmania/src/archutils/Unix/LinuxThreadHelpers.cpp b/stepmania/src/archutils/Unix/LinuxThreadHelpers.cpp index 15447d1bb1..66748a770b 100644 --- a/stepmania/src/archutils/Unix/LinuxThreadHelpers.cpp +++ b/stepmania/src/archutils/Unix/LinuxThreadHelpers.cpp @@ -121,15 +121,21 @@ int GetCurrentThreadId() { InitializePidThreadHelpers(); // for g_bUsingNPTL - pid_t ret = gettid(); + /* Don't keep calling gettid() if it's not supported; it'll make valgrind spam us. */ + static bool GetTidUnsupported = 0; + if( !GetTidUnsupported ) + { + pid_t ret = gettid(); - /* If this fails with ENOSYS, we're on a kernel before gettid. If we - * don't have NPTL, then just use getpid(). If we're on NPTL and don't - * have gettid(), something's wrong. */ - if( ret != -1 ) - return ret; + /* If this fails with ENOSYS, we're on a kernel before gettid, or we're + * under valgrind. If we don't have NPTL, then just use getpid(). If + * we're on NPTL and don't have gettid(), something's wrong. */ + if( ret != -1 ) + return ret; - ASSERT( !g_bUsingNPTL ); + ASSERT( !g_bUsingNPTL ); + GetTidUnsupported = true; + } return getpid(); }