This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] gold: conditionalize declaration of conditionally-used field Once::was_run_lock_.
- From: Roland McGrath <mcgrathr at google dot com>
- To: "binutils at sourceware dot org" <binutils at sourceware dot org>
- Date: Fri, 11 Oct 2013 10:48:57 -0700
- Subject: [PATCH] gold: conditionalize declaration of conditionally-used field Once::was_run_lock_.
- Authentication-results: sourceware.org; auth=none
There is no point in having the member when it's not going to be used.
(And some C++ compilers like to warn about the case.)
OK for trunk and 2.24?
Thanks,
Roland
gold/
* gold-threads.h (Once): Conditionalize member was_run_lock_ on
[__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4], matching its only use.
* gold-threads.cc (Once::Once): Likewise conditionalize initializer.
--- a/gold/gold-threads.cc
+++ b/gold/gold-threads.cc
@@ -1,6 +1,6 @@
// gold-threads.cc -- thread support for gold
-// Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+// Copyright 2006, 2007, 2008, 2009, 2010, 2013 Free Software Foundation, Inc.
// Written by Ian Lance Taylor <iant@google.com>.
// This file is part of gold.
@@ -335,7 +335,10 @@ c_run_once(void)
// Class Once.
Once::Once()
- : was_run_(false), was_run_lock_(0)
+ : was_run_(false)
+#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
+ , was_run_lock_(0)
+#endif
{
#ifndef ENABLE_THREADS
this->once_ = NULL;
--- a/gold/gold-threads.h
+++ b/gold/gold-threads.h
@@ -1,6 +1,6 @@
// gold-threads.h -- thread support for gold -*- C++ -*-
-// Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+// Copyright 2006, 2007, 2008, 2009, 2010, 2013 Free Software Foundation, Inc.
// Written by Ian Lance Taylor <iant@google.com>.
// This file is part of gold.
@@ -223,8 +223,10 @@ class Once
private:
// True if we have already run the function.
bool was_run_;
+#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
// Internal compare-and-swap lock on was_run_;
uint32_t was_run_lock_;
+#endif
// The lock to run the function only once.
Once_initialize* once_;
};