This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH 05/16] gcc: driver: add g_driver singleton
- From: David Malcolm <dmalcolm at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org, binutils at sourceware dot org
- Cc: David Malcolm <dmalcolm at redhat dot com>
- Date: Mon, 1 Jun 2015 17:04:13 -0400
- Subject: [PATCH 05/16] gcc: driver: add g_driver singleton
- Authentication-results: sourceware.org; auth=none
- References: <1433192664-50156-1-git-send-email-dmalcolm at redhat dot com>
gcc/ChangeLog:
* gcc.c (g_driver): New.
(driver::driver): Set "g_driver".
(driver::~driver): Unset "g_driver".
---
gcc/gcc.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/gcc/gcc.c b/gcc/gcc.c
index 7314317..46e750d 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -45,6 +45,9 @@ compilation is specified by a string called a "spec". */
#include "filenames.h"
#include "timevar.h"
+/* Singleton instance of "driver" class. */
+static driver *g_driver;
+
/* Manage the manipulation of env vars. We poison getenv and putenv, so that
@@ -7029,6 +7032,9 @@ driver::driver (bool can_finalize, bool debug, timer *t) :
decoded_options (NULL),
m_timer (t)
{
+ gcc_assert (g_driver == NULL);
+ g_driver = this;
+
env.init (can_finalize, debug);
}
@@ -7036,6 +7042,9 @@ driver::~driver ()
{
XDELETEVEC (explicit_link_files);
XDELETEVEC (decoded_options);
+
+ gcc_assert (g_driver == this);
+ g_driver = NULL;
}
/* driver::main is implemented as a series of driver:: method calls. */
--
1.8.5.3