summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authordeanm@google.com <deanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-22 17:22:49 +0000
committerdeanm@google.com <deanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-22 17:22:49 +0000
commit6413906c119090aa5d8ec4abfa83a6b65b51d404 (patch)
tree6090c413b02467b4a40f6d0bcc8ae75914972b2a /base
parentfe6135245ee7254459e37ae8663c2c98146e8d3c (diff)
downloadchromium_src-6413906c119090aa5d8ec4abfa83a6b65b51d404.zip
chromium_src-6413906c119090aa5d8ec4abfa83a6b65b51d404.tar.gz
chromium_src-6413906c119090aa5d8ec4abfa83a6b65b51d404.tar.bz2
Properly initialize PlatformThreadHandle. The Open Group Base Specifications Issue 6 states that pthread_t cannot be assumed to be a numeric type. It should be safe to value initialize it with (), even if it's a structure.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1226 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/platform_thread.h6
-rw-r--r--base/simple_thread.h4
2 files changed, 6 insertions, 4 deletions
diff --git a/base/platform_thread.h b/base/platform_thread.h
index 542716b..1feb72d 100644
--- a/base/platform_thread.h
+++ b/base/platform_thread.h
@@ -32,8 +32,10 @@
#include "base/basictypes.h"
-// PlatformThreadHandle should be a numeric type on all platforms, so it can
-// be initialized to 0. However, 0 cannot be assumed to be an invalid handle.
+// PlatformThreadHandle should not be assumed to be a numeric type, since the
+// standard intends to allow pthread_t to be a structure. This means you
+// should not initialize it to a value, like 0. If it's a member variable, the
+// constructor can safely "value initialize" using () in the initializer list.
#if defined(OS_WIN)
typedef void* PlatformThreadHandle; // HANDLE
#elif defined(OS_POSIX)
diff --git a/base/simple_thread.h b/base/simple_thread.h
index 44b397d..77754e9 100644
--- a/base/simple_thread.h
+++ b/base/simple_thread.h
@@ -98,11 +98,11 @@ class SimpleThread : public PlatformThread::Delegate {
// "my_thread/321". The thread will not be created until Start() is called.
SimpleThread(const Options& options, const std::string& name_prefix)
: name_prefix_(name_prefix), name_(name_prefix_), options_(options),
- thread_(0), event_(true, false), tid_(0), joined_(false) { }
+ thread_(), event_(true, false), tid_(0), joined_(false) { }
SimpleThread()
: name_prefix_("unnamed"), name_(name_prefix_),
- thread_(0), event_(true, false), tid_(0), joined_(false) { }
+ thread_(), event_(true, false), tid_(0), joined_(false) { }
virtual ~SimpleThread();