This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 05/16] gcc: driver: add g_driver singleton


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]