Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r53224 - in trunk: boost/wave boost/wave/cpplexer boost/wave/cpplexer/re2clex boost/wave/util libs/wave
From: hartmut.kaiser_at_[hidden]
Date: 2009-05-23 22:47:27


Author: hkaiser
Date: 2009-05-23 22:47:25 EDT (Sat, 23 May 2009)
New Revision: 53224
URL: http://svn.boost.org/trac/boost/changeset/53224

Log:
Wave: fixed another race condition
Text files modified:
   trunk/boost/wave/cpp_context.hpp | 36 ++++++++++++------------
   trunk/boost/wave/cpplexer/re2clex/cpp_re2c_lexer.hpp | 8 ++++
   trunk/boost/wave/cpplexer/token_cache.hpp | 2
   trunk/boost/wave/token_ids.hpp | 6 ++--
   trunk/boost/wave/util/cpp_iterator.hpp | 4 +-
   trunk/boost/wave/util/flex_string.hpp | 8 ++--
   trunk/boost/wave/wave_config.hpp | 58 ++++++++++++++++++++--------------------
   trunk/libs/wave/ChangeLog | 4 ++
   8 files changed, 67 insertions(+), 59 deletions(-)

Modified: trunk/boost/wave/cpp_context.hpp
==============================================================================
--- trunk/boost/wave/cpp_context.hpp (original)
+++ trunk/boost/wave/cpp_context.hpp 2009-05-23 22:47:25 EDT (Sat, 23 May 2009)
@@ -117,7 +117,7 @@
         token_sequence_type;
 // type of the policies
     typedef HooksT hook_policy_type;
-
+
 private:
 // stack of shared_ptr's to the pending iteration contexts
     typedef boost::shared_ptr<base_iteration_context<context, lexer_type> >
@@ -127,7 +127,7 @@
     typedef typename iteration_context_stack_type::size_type iter_size_type;
 
     context *this_() { return this; } // avoid warning in constructor
-
+
 public:
     context(target_iterator_type const &first_, target_iterator_type const &last_,
             char const *fname = "<Unknown>", HooksT const &hooks_ = HooksT())
@@ -153,11 +153,11 @@
     {
         macros.init_predefined_macros(fname);
     }
-
+
 // default copy constructor
 // default assignment operator
 // default destructor
-
+
 // iterator interface
     iterator_type begin()
     {
@@ -246,7 +246,7 @@
     typedef boost::wave::util::macromap<context> macromap_type;
     typedef typename macromap_type::name_iterator name_iterator;
     typedef typename macromap_type::const_name_iterator const_name_iterator;
-
+
     name_iterator macro_names_begin() { return macros.begin(); }
     name_iterator macro_names_end() { return macros.end(); }
     const_name_iterator macro_names_begin() const { return macros.begin(); }
@@ -261,7 +261,7 @@
         return macros.add_macro(name, has_params, parameters, definition,
             is_predefined);
     }
-
+
 // get the Wave version information
     static std::string get_version()
     {
@@ -269,7 +269,7 @@
         return util::to_string<std::string>(p.get_fullversion());
     }
     static std::string get_version_string()
- {
+ {
         boost::wave::util::predefined_macros p;
         return util::to_string<std::string>(p.get_versionstr());
     }
@@ -283,7 +283,7 @@
             reset_macro_definitions();
     }
     boost::wave::language_support get_language() const { return language; }
-
+
 // change and ask for maximal possible include nesting depth
     void set_max_include_nesting_depth(iter_size_type new_depth)
         { iter_ctxs.set_max_include_nesting_depth(new_depth); }
@@ -323,7 +323,7 @@
             has_been_initialized = true; // execute once
         }
     }
-
+
     template <typename IteratorT2>
     bool is_defined_macro(IteratorT2 const &begin, IteratorT2 const &end) const
         { return macros.is_defined(begin, end); }
@@ -334,7 +334,7 @@
     { return includes.find_include_file(s, d, is_system, current_file); }
     void set_current_directory(char const *path_)
         { includes.set_current_directory(path_); }
-
+
 // conditional compilation contexts
     bool get_if_block_status() const { return ifblocks.get_status(); }
     bool get_if_block_some_part_status() const
@@ -357,7 +357,7 @@
         { iter_ctxs.push(*this, act_pos, iter_ctx); }
 
     position_type &get_main_pos() { return macros.get_main_pos(); }
-
+
 ///////////////////////////////////////////////////////////////////////////////
 //
 // expand_tokensequence():
@@ -417,14 +417,14 @@
     void save(Archive & ar, const unsigned int version) const
     {
         using namespace boost::serialization;
-
+
         string_type cfg(BOOST_PP_STRINGIZE(BOOST_WAVE_CONFIG));
         string_type kwd(BOOST_WAVE_PRAGMA_KEYWORD);
         string_type strtype(BOOST_PP_STRINGIZE((BOOST_WAVE_STRINGTYPE)));
         ar & make_nvp("config", cfg);
         ar & make_nvp("pragma_keyword", kwd);
         ar & make_nvp("string_type", strtype);
-
+
         ar & make_nvp("language_options", language);
         ar & make_nvp("macro_definitions", macros);
         ar & make_nvp("include_settings", includes);
@@ -439,10 +439,10 @@
                 get_main_pos());
             return;
         }
-
+
         // check compatibility of the stored information
         string_type config, pragma_keyword, string_type_str;
-
+
         // BOOST_PP_STRINGIZE(BOOST_WAVE_CONFIG)
         ar & make_nvp("config", config);
         if (config != BOOST_PP_STRINGIZE(BOOST_WAVE_CONFIG)) {
@@ -450,7 +450,7 @@
                 incompatible_config, "BOOST_WAVE_CONFIG", get_main_pos());
             return;
         }
-
+
         // BOOST_WAVE_PRAGMA_KEYWORD
         ar & make_nvp("pragma_keyword", pragma_keyword);
         if (pragma_keyword != BOOST_WAVE_PRAGMA_KEYWORD) {
@@ -467,7 +467,7 @@
                 incompatible_config, "BOOST_WAVE_STRINGTYPE", get_main_pos());
             return;
         }
-
+
         try {
             // read in the useful bits
             ar & make_nvp("language_options", language);
@@ -491,7 +491,7 @@
 #if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
     std::string current_filename; // real name of current preprocessed file
 #endif
-
+
     boost::wave::util::if_block_stack ifblocks; // conditional compilation contexts
     boost::wave::util::include_paths includes; // lists of include directories to search
     iteration_context_stack_type iter_ctxs; // iteration contexts

Modified: trunk/boost/wave/cpplexer/re2clex/cpp_re2c_lexer.hpp
==============================================================================
--- trunk/boost/wave/cpplexer/re2clex/cpp_re2c_lexer.hpp (original)
+++ trunk/boost/wave/cpplexer/re2clex/cpp_re2c_lexer.hpp 2009-05-23 22:47:25 EDT (Sat, 23 May 2009)
@@ -2,7 +2,7 @@
     Boost.Wave: A Standard compliant C++ preprocessor library
 
     Re2C based C++ lexer
-
+
     http://www.boost.org/
 
     Copyright (c) 2001-2009 Hartmut Kaiser. Distributed under the Boost
@@ -103,7 +103,11 @@
     include_guards<token_type> guards;
 #endif
 
+#if BOOST_WAVE_SUPPORT_THREADING == 0
     static token_cache<string_type> const cache;
+#else
+ token_cache<string_type> const cache;
+#endif
 };
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -346,11 +350,13 @@
     lexer<IteratorT, PositionT, TokenT> re2c_lexer;
 };
 
+#if BOOST_WAVE_SUPPORT_THREADING == 0
 ///////////////////////////////////////////////////////////////////////////////
 template <typename IteratorT, typename PositionT, typename TokenT>
 token_cache<typename lexer<IteratorT, PositionT, TokenT>::string_type> const
     lexer<IteratorT, PositionT, TokenT>::cache =
         token_cache<typename lexer<IteratorT, PositionT, TokenT>::string_type>();
+#endif
 
 } // namespace re2clex
 

Modified: trunk/boost/wave/cpplexer/token_cache.hpp
==============================================================================
--- trunk/boost/wave/cpplexer/token_cache.hpp (original)
+++ trunk/boost/wave/cpplexer/token_cache.hpp 2009-05-23 22:47:25 EDT (Sat, 23 May 2009)
@@ -54,7 +54,7 @@
     {
         return cache[BASEID_FROM_TOKEN(id) - T_FIRST_TOKEN];
     }
-
+
 private:
     std::vector<StringT> cache;
 };

Modified: trunk/boost/wave/token_ids.hpp
==============================================================================
--- trunk/boost/wave/token_ids.hpp (original)
+++ trunk/boost/wave/token_ids.hpp 2009-05-23 22:47:25 EDT (Sat, 23 May 2009)
@@ -2,7 +2,7 @@
     Boost.Wave: A Standard compliant C++ preprocessor library
     The definition of a default set of token identifiers and related
     functions.
-
+
     http://www.boost.org/
 
     Copyright (c) 2001-2009 Hartmut Kaiser. Distributed under the Boost
@@ -36,7 +36,7 @@
 namespace wave {
 
 ///////////////////////////////////////////////////////////////////////////////
-// assemble tokenid's
+// assemble tokenids
 #define TOKEN_FROM_ID(id, cat) ((id) | (cat))
 #define ID_FROM_TOKEN(tok) ((tok) & ~TokenTypeMask)
 #define BASEID_FROM_TOKEN(tok) ((tok) & ~ExtTokenTypeMask)
@@ -288,7 +288,7 @@
 
     T_LAST_TOKEN_ID,
     T_LAST_TOKEN = ID_FROM_TOKEN(T_LAST_TOKEN_ID),
-
+
 // pseudo tokens to help streamlining macro replacement, these should not
 // returned from the lexer nor should these be returned from the pp-iterator
     T_NONREPLACABLE_IDENTIFIER = TOKEN_FROM_ID(T_LAST_TOKEN+1, IdentifierTokenType),

Modified: trunk/boost/wave/util/cpp_iterator.hpp
==============================================================================
--- trunk/boost/wave/util/cpp_iterator.hpp (original)
+++ trunk/boost/wave/util/cpp_iterator.hpp 2009-05-23 22:47:25 EDT (Sat, 23 May 2009)
@@ -626,7 +626,7 @@
         // adjust the current position (line and column)
         bool was_seen_newline = seen_newline || returned_from_include_file;
 
- // fetch the current token
+ // fetch the current token
             act_token = *iter_ctx->first;
             act_pos = act_token.get_position();
 
@@ -699,7 +699,7 @@
 #endif
                 ++iter_ctx->first;
             }
-
+
         } while ((iter_ctx->first != iter_ctx->last) ||
                  (returned_from_include_file = returned_from_include()));
 

Modified: trunk/boost/wave/util/flex_string.hpp
==============================================================================
--- trunk/boost/wave/util/flex_string.hpp (original)
+++ trunk/boost/wave/util/flex_string.hpp 2009-05-23 22:47:25 EDT (Sat, 23 May 2009)
@@ -2551,11 +2551,11 @@
     typename flex_string<E, T, A, S>::value_type delim)
 {
     size_t nread = 0;
- typename basic_istream<typename flex_string<E, T, A, S>::value_type,
+ typename std::basic_istream<typename flex_string<E, T, A, S>::value_type,
         typename flex_string<E, T, A, S>::traits_type>::sentry sentry(is, true);
 
     if (sentry) {
- basic_streambuf<typename flex_string<E, T, A, S>::value_type,
+ std::basic_streambuf<typename flex_string<E, T, A, S>::value_type,
             typename flex_string<E, T, A, S>::traits_type>* buf = is.rdbuf();
         str.clear();
 
@@ -2564,7 +2564,7 @@
             if (flex_string<E, T, A, S>::traits_type::eq_int_type(c1,
                 flex_string<E, T, A, S>::traits_type::eof()))
             {
- is.setstate(ios_base::eofbit);
+ is.setstate(std::ios_base::eofbit);
                 break;
             }
             else {
@@ -2580,7 +2580,7 @@
         }
     }
     if (nread == 0 || nread >= str.max_size())
- is.setstate(ios_base::failbit);
+ is.setstate(std::ios_base::failbit);
 
     return is;
 }

Modified: trunk/boost/wave/wave_config.hpp
==============================================================================
--- trunk/boost/wave/wave_config.hpp (original)
+++ trunk/boost/wave/wave_config.hpp 2009-05-23 22:47:25 EDT (Sat, 23 May 2009)
@@ -158,19 +158,43 @@
 #endif
 
 ///////////////////////////////////////////////////////////////////////////////
+// Configure Wave thread support, Boost.Spirit and Boost.Pool are configured
+// based on these settings automatically
+//
+// If BOOST_WAVE_SUPPORT_THREADING is not defined, Wave will use the global
+// Boost build settings (BOOST_HAS_THREADS), if it is defined its value
+// defines, whether threading will be enabled or not (should be set to '0'
+// or '1').
+#if !defined(BOOST_WAVE_SUPPORT_THREADING)
+#if defined(BOOST_HAS_THREADS)
+#define BOOST_WAVE_SUPPORT_THREADING 1
+#else
+#define BOOST_WAVE_SUPPORT_THREADING 0
+#endif
+#endif
+
+#if BOOST_WAVE_SUPPORT_THREADING != 0
+#define BOOST_SPIRIT_THREADSAFE 1
+#define PHOENIX_THREADSAFE 1
+#else
+// disable thread support in Boost.Pool
+#define BOOST_NO_MT 1
+#endif
+
+///////////////////////////////////////////////////////////////////////////////
 // Define the string type to be used to store the token values and the file
 // names inside a file_position template class
 //
 #if !defined(BOOST_WAVE_STRINGTYPE)
 
-#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) || \
- BOOST_WORKAROUND(__MWERKS__, < 0x3200) || \
- (defined(__DECCXX) && defined(__alpha)) || \
- defined(BOOST_WAVE_STRINGTYPE_USE_STDSTRING)
-
 // VC7 isn't able to compile the flex_string class, fall back to std::string
 // CW up to 8.3 chokes as well *sigh*
 // Tru64/CXX has linker problems when using flex_string
+#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) || \
+ BOOST_WORKAROUND(__MWERKS__, < 0x3200) || \
+ (defined(__DECCXX) && defined(__alpha)) || \
+ defined(BOOST_WAVE_STRINGTYPE_USE_STDSTRING)
+
 #define BOOST_WAVE_STRINGTYPE std::string
 #if !defined(BOOST_WAVE_STRINGTYPE_USE_STDSTRING)
 #define BOOST_WAVE_STRINGTYPE_USE_STDSTRING 1
@@ -366,30 +390,6 @@
 }}
 
 ///////////////////////////////////////////////////////////////////////////////
-// Configure Wave thread support, Boost.Spirit and Boost.Pool are configured
-// based on these settings automatically
-//
-// If BOOST_WAVE_SUPPORT_THREADING is not defined, Wave will use the global
-// Boost build settings (BOOST_HAS_THREADS), if it is defined its value
-// defines, whether threading will be enabled or not (should be set to '0'
-// or '1').
-#if !defined(BOOST_WAVE_SUPPORT_THREADING)
-#if defined(BOOST_HAS_THREADS)
-#define BOOST_WAVE_SUPPORT_THREADING 1
-#else
-#define BOOST_WAVE_SUPPORT_THREADING 0
-#endif
-#endif
-
-#if BOOST_WAVE_SUPPORT_THREADING != 0
-#define BOOST_SPIRIT_THREADSAFE 1
-#define PHOENIX_THREADSAFE 1
-#else
-// disable thread support in Boost.Pool
-#define BOOST_NO_MT 1
-#endif
-
-///////////////////////////////////////////////////////////////////////////////
 // Wave needs at least 4 parameters for phoenix actors
 #if !defined(PHOENIX_LIMIT)
 #define PHOENIX_LIMIT 6

Modified: trunk/libs/wave/ChangeLog
==============================================================================
--- trunk/libs/wave/ChangeLog (original)
+++ trunk/libs/wave/ChangeLog 2009-05-23 22:47:25 EDT (Sat, 23 May 2009)
@@ -33,7 +33,9 @@
 - Fixed a long standing race condition inhibiting to use Wave in multi threaded
   environments.
 - Removed old code related to pre Boost V1.31 (V1 of iterator library)
-- Incorporated the changes from latest version of the flex_string class.
+- Incorporated the changes from latest version of the flex_string class (#2946).
+- Fixed another race condition triggering problems using Wave in multi-threaded
+ environments.
 
 Boost V1.39.0
 - V2.0.1


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk