aboutsummaryrefslogtreecommitdiff
path: root/build2/algorithm.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-06-16 17:58:54 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-06-16 17:58:54 +0200
commit1c75d32ee310f02d2c04ab427ad300222cc40d86 (patch)
treedb66e512a9a4dc77973b846d8a038768480b0120 /build2/algorithm.cxx
parent5c8de4f515c99d894bec764a6793352c9cad0825 (diff)
Fix bug (forward-declared inline function)
Diffstat (limited to 'build2/algorithm.cxx')
-rw-r--r--build2/algorithm.cxx26
1 files changed, 26 insertions, 0 deletions
diff --git a/build2/algorithm.cxx b/build2/algorithm.cxx
index 9310644..a55b885 100644
--- a/build2/algorithm.cxx
+++ b/build2/algorithm.cxx
@@ -19,6 +19,32 @@ using namespace butl;
namespace build2
{
+ const target*
+ search_existing (const prerequisite& p)
+ {
+ assert (phase == run_phase::match); // Could be relaxed.
+
+ const target* r (p.target.load (memory_order_consume));
+
+ if (r == nullptr)
+ {
+ const prerequisite_key& pk (p.key ());
+ r = pk.proj ? import_existing (pk) : search_existing_target (pk);
+
+ if (r != nullptr)
+ {
+ const target* e (nullptr);
+ if (!p.target.compare_exchange_strong (
+ e, r,
+ memory_order_release,
+ memory_order_consume))
+ assert (e == r);
+ }
+ }
+
+ return r;
+ }
+
const target&
search (const target& t, const prerequisite_key& pk)
{