diff options
Diffstat (limited to 'indra/llcommon')
32 files changed, 231 insertions, 305 deletions
| diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index debb42fb5f..1459b9ada2 100755 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -306,7 +306,7 @@ if (LL_TESTS)    LL_ADD_INTEGRATION_TEST(llunits "" "${test_libs}")    LL_ADD_INTEGRATION_TEST(stringize "" "${test_libs}")    LL_ADD_INTEGRATION_TEST(lleventdispatcher "" "${test_libs}") -  LL_ADD_INTEGRATION_TEST(lleventcoro "" "${test_libs};${BOOST_CONTEXT_LIBRARY};${BOOST_COROUTINE_LIBRARY};${BOOST_SYSTEM_LIBRARY}") +  LL_ADD_INTEGRATION_TEST(lleventcoro "" "${test_libs};${BOOST_CONTEXT_LIBRARY};${BOOST_THREAD_LIBRARY};${BOOST_COROUTINE_LIBRARY};${BOOST_SYSTEM_LIBRARY}")    LL_ADD_INTEGRATION_TEST(llprocess "" "${test_libs}")    LL_ADD_INTEGRATION_TEST(llleap "" "${test_libs}")    LL_ADD_INTEGRATION_TEST(llstreamqueue "" "${test_libs}") diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index 22cd861c72..8119b14887 100755 --- a/indra/llcommon/llerror.cpp +++ b/indra/llcommon/llerror.cpp @@ -126,7 +126,7 @@ namespace {  			mFile.close();  		} -		bool okay() { return mFile; } +		bool okay() { return mFile.good(); }  		virtual void recordMessage(LLError::ELevel level,  									const std::string& message) diff --git a/indra/llcommon/lleventcoro.h b/indra/llcommon/lleventcoro.h index a42af63b65..abbeeaa373 100755 --- a/indra/llcommon/lleventcoro.h +++ b/indra/llcommon/lleventcoro.h @@ -67,7 +67,7 @@ public:      LLEventPumpOrPumpName() {}      operator LLEventPump& () const { return *mPump; }      LLEventPump& getPump() const { return *mPump; } -    operator bool() const { return mPump; } +    operator bool() const { return bool(mPump); }      bool operator!() const { return ! mPump; }  private: @@ -102,6 +102,9 @@ LLVoidListener<LISTENER> voidlistener(const LISTENER& listener)  namespace LLEventDetail  { +    /// Implementation for listenerNameForCoro(), see below +    LL_COMMON_API std::string listenerNameForCoroImpl(const void* self_id); +      /**       * waitForEventOn() permits a coroutine to temporarily listen on an       * LLEventPump any number of times. We don't really want to have to ask @@ -129,9 +132,6 @@ namespace LLEventDetail          return listenerNameForCoroImpl(self.get_id());      } -    /// Implementation for listenerNameForCoro() -    LL_COMMON_API std::string listenerNameForCoroImpl(const void* self_id); -      /**       * Implement behavior described for postAndWait()'s @a replyPumpNamePath       * parameter: diff --git a/indra/llcommon/llfile.cpp b/indra/llcommon/llfile.cpp index 259187c52f..304d702979 100755 --- a/indra/llcommon/llfile.cpp +++ b/indra/llcommon/llfile.cpp @@ -807,7 +807,7 @@ std::streamsize llstdio_filebuf::xsgetn(char_type* __s, std::streamsize __n)  	return __ret;  } -std::streamsize llstdio_filebuf::xsputn(char_type* __s, std::streamsize __n) +std::streamsize llstdio_filebuf::xsputn(const char_type* __s, std::streamsize __n)  {  	// Optimization in the always_noconv() case, to be generalized in the  	// future: when __n is sufficiently large we write directly instead of @@ -919,6 +919,7 @@ llifstream::llifstream(const char* _Filename,  #endif +#if llstream_LLFILE  // explicit  llifstream::llifstream(_Filet *_File,  		ios_base::openmode _Mode, size_t _Size) : @@ -942,6 +943,7 @@ llifstream::llifstream(int __fd,  	this->init(&_M_filebuf);  }  #endif +#endif // llstream_LLFILE  bool llifstream::is_open() const  {	// test if C stream has been opened @@ -1039,6 +1041,7 @@ llofstream::llofstream(const char* _Filename,  }  #endif +#if llstream_LLFILE  // explicit  llofstream::llofstream(_Filet *_File,  			ios_base::openmode _Mode, size_t _Size) : @@ -1062,6 +1065,7 @@ llofstream::llofstream(int __fd,  	this->init(&_M_filebuf);  }  #endif +#endif // llstream_LLFILE  bool llofstream::is_open() const  {	// test if C stream has been opened diff --git a/indra/llcommon/llfile.h b/indra/llcommon/llfile.h index f56b22bf9a..44a1e42fa5 100755 --- a/indra/llcommon/llfile.h +++ b/indra/llcommon/llfile.h @@ -86,6 +86,12 @@ public:  	static  const char * tmpdir();  }; +// Remove ll[io]fstream support for [LL]FILE*, preparing to remove dependency +// on GNU's standard library. +#if ! defined(llstream_LLFILE) +#define llstream_LLFILE 0 +#endif +  /**   *  @brief Provides a layer of compatibility for C/POSIX.   * @@ -188,7 +194,7 @@ protected:  	/*virtual*/ int sync();  	std::streamsize xsgetn(char_type*, std::streamsize); -	std::streamsize xsputn(char_type*, std::streamsize); +	std::streamsize xsputn(const char_type*, std::streamsize);  #endif  }; @@ -228,6 +234,7 @@ public:  	explicit llifstream(const char* _Filename,  			ios_base::openmode _Mode = ios_base::in); +#if llstream_LLFILE  	/**  	 *  @brief  Create a stream using an open c file stream.  	 *  @param  File  An open @c FILE*. @@ -253,6 +260,7 @@ public:  			//size_t _Size = static_cast<size_t>(BUFSIZ));  			size_t _Size = static_cast<size_t>(1));  #endif +#endif // llstream_LLFILE  	/**  	 *  @brief  The destructor does nothing. @@ -263,6 +271,7 @@ public:  	virtual ~llifstream() {}  	// Members: +#if llstream_LLFILE  	/**  	 *  @brief  Accessing the underlying buffer.  	 *  @return  The current basic_filebuf buffer. @@ -271,6 +280,7 @@ public:  	*/  	llstdio_filebuf* rdbuf() const  	{ return const_cast<llstdio_filebuf*>(&_M_filebuf); } +#endif // llstream_LLFILE  	/**  	 *  @brief  Wrapper to test for an open file. @@ -340,6 +350,7 @@ public:  	explicit llofstream(const char* _Filename,  			ios_base::openmode _Mode = ios_base::out|ios_base::trunc); +#if llstream_LLFILE  	/**  	 *  @brief  Create a stream using an open c file stream.  	 *  @param  File  An open @c FILE*. @@ -365,6 +376,7 @@ public:  			//size_t _Size = static_cast<size_t>(BUFSIZ));  			size_t _Size = static_cast<size_t>(1));  #endif +#endif // llstream_LLFILE  	/**  	 *  @brief  The destructor does nothing. @@ -375,6 +387,7 @@ public:  	virtual ~llofstream() {}  	// Members: +#if llstream_LLFILE  	/**  	 *  @brief  Accessing the underlying buffer.  	 *  @return  The current basic_filebuf buffer. @@ -383,6 +396,7 @@ public:  	*/  	llstdio_filebuf* rdbuf() const  	{ return const_cast<llstdio_filebuf*>(&_M_filebuf); } +#endif // llstream_LLFILE  	/**  	 *  @brief  Wrapper to test for an open file. diff --git a/indra/llcommon/llframetimer.cpp b/indra/llcommon/llframetimer.cpp index 1af2cb8afd..1e9920746b 100755 --- a/indra/llcommon/llframetimer.cpp +++ b/indra/llcommon/llframetimer.cpp @@ -37,7 +37,6 @@ U64 LLFrameTimer::sTotalTime = 0;  F64 LLFrameTimer::sTotalSeconds = 0.0;  S32 LLFrameTimer::sFrameCount = 0;  U64 LLFrameTimer::sFrameDeltaTime = 0; -const F64 USEC_PER_SECOND = 1000000.0;  const F64 USEC_TO_SEC_F64 = 0.000001;  // static diff --git a/indra/llcommon/llhash.h b/indra/llcommon/llhash.h index c077ebe93f..4b58e81565 100755 --- a/indra/llcommon/llhash.h +++ b/indra/llcommon/llhash.h @@ -27,26 +27,7 @@  #ifndef LL_LLHASH_H  #define LL_LLHASH_H -#include "llpreprocessor.h" // for GCC_VERSION - -#if (LL_WINDOWS) -#include <hash_map> -#include <algorithm> -#elif LL_DARWIN || LL_LINUX -#  if GCC_VERSION >= 40300 // gcc 4.3 and up -#    include <backward/hashtable.h> -#  elif GCC_VERSION >= 30400 // gcc 3.4 and up -#    include <ext/hashtable.h> -#  elif __GNUC__ >= 3 -#    include <ext/stl_hashtable.h> -#  else -#    include <hashtable.h> -#  endif -#elif LL_SOLARIS -#include <ext/hashtable.h> -#else -#error Please define your platform. -#endif +#include <boost/functional/hash.hpp>  // Warning - an earlier template-based version of this routine did not do  // the correct thing on Windows.   Since this is only used to get @@ -55,17 +36,17 @@  inline size_t llhash( const char * value )  { -#if LL_WINDOWS -	return stdext::hash_value(value); -#elif ( (defined _STLPORT_VERSION) || ((LL_LINUX) && (__GNUC__ <= 2)) ) -	std::hash<const char *> H; -	return H(value); -#elif LL_DARWIN || LL_LINUX || LL_SOLARIS -	__gnu_cxx::hash<const char *> H; -	return H(value); -#else -#error Please define your platform. -#endif +	// boost::hash is defined for std::string and for char, but there's no +	// special overload for const char*. The lazy approach would be to +	// instantiate a std::string and take its hash, but that might be more +	// overhead than our callers want. Or we could use boost::hash_range() -- +	// but that would require a preliminary pass over the value to determine +	// the end iterator. Instead, use boost::hash_combine() to hash individual +	// characters. +	std::size_t seed = 0; +	for ( ; *value; ++value) +		boost::hash_combine(seed, *value); +	return seed;  }  #endif diff --git a/indra/llcommon/llinitparam.h b/indra/llcommon/llinitparam.h index 7aa87fcd0e..c65b05f610 100755 --- a/indra/llcommon/llinitparam.h +++ b/indra/llcommon/llinitparam.h @@ -435,7 +435,7 @@ namespace LLInitParam  		typedef self_t type_value_t;  		TypeValuesHelper(const std::string& val) -		:	TypeValuesHelper(val) +		:	base_t(val)  		{}  		void operator ()(const std::string& name) @@ -1123,7 +1123,7 @@ namespace LLInitParam  		void set(const value_t& val, bool flag_as_provided = true)  		{  			named_value_t::clearValueName(); -			setValue(val); +			named_value_t::setValue(val);  			setProvided(flag_as_provided);  		} @@ -1287,7 +1287,7 @@ namespace LLInitParam  		// assign block contents to this param-that-is-a-block  		void set(const value_t& val, bool flag_as_provided = true)  		{ -			setValue(val); +			named_value_t::setValue(val);  			named_value_t::clearValueName();  			setProvided(flag_as_provided);  		} @@ -2054,7 +2054,7 @@ namespace LLInitParam  			Optional& operator =(const value_t& val)  			{ -				set(val); +				super_t::set(val);  				return *this;  			} @@ -2084,7 +2084,7 @@ namespace LLInitParam  			Mandatory& operator =(const value_t& val)  			{ -				set(val); +				super_t::set(val);  				return *this;  			} @@ -2120,7 +2120,7 @@ namespace LLInitParam  			Multiple& operator =(const container_t& val)  			{ -				set(val); +				super_t::set(val);  				return *this;  			} diff --git a/indra/llcommon/llpredicate.h b/indra/llcommon/llpredicate.h index a0e970a799..e6c56a5711 100644 --- a/indra/llcommon/llpredicate.h +++ b/indra/llcommon/llpredicate.h @@ -139,9 +139,9 @@ namespace LLPredicate  		Rule()  		{} -		void require(ENUM e) +		void require(ENUM e, bool match)  		{ -			mRule.set(e, require); +			mRule.set(e, match);  		}  		void allow(ENUM e) diff --git a/indra/llcommon/llpreprocessor.h b/indra/llcommon/llpreprocessor.h index 309165da7f..2c4bcc91f6 100755 --- a/indra/llcommon/llpreprocessor.h +++ b/indra/llcommon/llpreprocessor.h @@ -101,6 +101,11 @@  #endif +#if LL_WINDOWS +# define LL_THREAD_LOCAL __declspec(thread) +#else +# define LL_THREAD_LOCAL __thread +#endif  // Static linking with apr on windows needs to be declared.  #if LL_WINDOWS && !LL_COMMON_LINK_SHARED diff --git a/indra/llcommon/llprocessor.cpp b/indra/llcommon/llprocessor.cpp index 69043dc173..e3e1d0c391 100755 --- a/indra/llcommon/llprocessor.cpp +++ b/indra/llcommon/llprocessor.cpp @@ -204,21 +204,6 @@ namespace     		return "Unknown";  	} -	std::string compute_CPUFamilyName(const char* cpu_vendor, int composed_family)  -	{ -		const char* intel_string = "GenuineIntel"; -		const char* amd_string = "AuthenticAMD"; -		if(!strncmp(cpu_vendor, intel_string, strlen(intel_string))) -		{ -			return intel_CPUFamilyName(composed_family); -		} -		else if(!strncmp(cpu_vendor, amd_string, strlen(amd_string))) -		{ -			return amd_CPUFamilyName(composed_family); -		} -		return "Unknown"; -	} -  	std::string compute_CPUFamilyName(const char* cpu_vendor, int family, int ext_family)   	{  		const char* intel_string = "GenuineIntel"; @@ -793,7 +778,7 @@ private:  			setInfo(eFamily, family);  		} -		setInfo(eFamilyName, compute_CPUFamilyName(cpuinfo["vendor_id"].c_str(), family)); +		setInfo(eFamilyName, compute_CPUFamilyName(cpuinfo["vendor_id"].c_str(), family, 0));  		// setInfo(eExtendedModel, getSysctlInt("machdep.cpu.extmodel"));  		// setInfo(eBrandID, getSysctlInt("machdep.cpu.brand")); diff --git a/indra/llcommon/llrefcount.h b/indra/llcommon/llrefcount.h index 72011d04a0..3836a9b5fb 100755 --- a/indra/llcommon/llrefcount.h +++ b/indra/llcommon/llrefcount.h @@ -151,29 +151,25 @@ private:   * intrusive pointer support for LLThreadSafeRefCount   * this allows you to use boost::intrusive_ptr with any LLThreadSafeRefCount-derived type   */ -namespace boost -{ -	inline void intrusive_ptr_add_ref(LLThreadSafeRefCount* p)  -	{ -		p->ref(); -	} - -	inline void intrusive_ptr_release(LLThreadSafeRefCount* p)  -	{ -		p->unref();  -	} -	inline void intrusive_ptr_add_ref(LLRefCount* p)  -	{ -		p->ref(); -	} +inline void intrusive_ptr_add_ref(LLThreadSafeRefCount* p)  +{ +	p->ref(); +} -	inline void intrusive_ptr_release(LLRefCount* p)  -	{ -		p->unref();  -	} -}; +inline void intrusive_ptr_release(LLThreadSafeRefCount* p)  +{ +	p->unref();  +} +inline void intrusive_ptr_add_ref(LLRefCount* p)  +{ +	p->ref(); +} +inline void intrusive_ptr_release(LLRefCount* p)  +{ +	p->unref();  +}  #endif diff --git a/indra/llcommon/llsd.cpp b/indra/llcommon/llsd.cpp index d8bbb3a74f..57aa7d9c07 100755 --- a/indra/llcommon/llsd.cpp +++ b/indra/llcommon/llsd.cpp @@ -789,10 +789,7 @@ namespace  {  	inline LLSD::Impl& safe(LLSD::Impl* impl)  		{ return LLSD::Impl::safe(impl); } -		 -	inline const LLSD::Impl& safe(const LLSD::Impl* impl) -		{ return LLSD::Impl::safe(impl); } -		 +  	inline ImplMap& makeMap(LLSD::Impl*& var)  		{ return safe(var).makeMap(var); } diff --git a/indra/llcommon/llsdparam.h b/indra/llcommon/llsdparam.h index 1542f95e68..09f1bdf1e3 100755 --- a/indra/llcommon/llsdparam.h +++ b/indra/llcommon/llsdparam.h @@ -106,7 +106,6 @@ private:  	Parser::name_stack_t	mNameStack;  	const LLSD*				mCurReadSD;  	LLSD*					mWriteRootSD; -	LLSD*					mCurWriteSD;  }; diff --git a/indra/llcommon/llsdutil.cpp b/indra/llcommon/llsdutil.cpp index 562fd26658..6ad4a97149 100755 --- a/indra/llcommon/llsdutil.cpp +++ b/indra/llcommon/llsdutil.cpp @@ -572,7 +572,7 @@ std::string llsd_matches(const LLSD& prototype, const LLSD& data, const std::str      return match_types(prototype.type(), TypeVector(), data.type(), pfx);  } -bool llsd_equals(const LLSD& lhs, const LLSD& rhs, unsigned bits) +bool llsd_equals(const LLSD& lhs, const LLSD& rhs, int bits)  {      // We're comparing strict equality of LLSD representation rather than      // performing any conversions. So if the types aren't equal, the LLSD diff --git a/indra/llcommon/llsdutil.h b/indra/llcommon/llsdutil.h index d0b536c39a..99cb79aa54 100755 --- a/indra/llcommon/llsdutil.h +++ b/indra/llcommon/llsdutil.h @@ -126,7 +126,7 @@ LL_COMMON_API std::string llsd_matches(const LLSD& prototype, const LLSD& data,  /// Deep equality. If you want to compare LLSD::Real values for approximate  /// equality rather than bitwise equality, pass @a bits as for  /// is_approx_equal_fraction(). -LL_COMMON_API bool llsd_equals(const LLSD& lhs, const LLSD& rhs, unsigned bits=-1); +LL_COMMON_API bool llsd_equals(const LLSD& lhs, const LLSD& rhs, int bits=-1);  // Simple function to copy data out of input & output iterators if  // there is no need for casting. diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp index 76979f29f6..617969ab2a 100755 --- a/indra/llcommon/llstring.cpp +++ b/indra/llcommon/llstring.cpp @@ -1397,7 +1397,7 @@ void LLStringUtilBase<T>::testHarness()  	s2.erase( 4, 1 );  	llassert( s2 == "hell"); -	s2.insert( 0, 'y' ); +	s2.insert( 0, "y" );  	llassert( s2 == "yhell");  	s2.erase( 1, 3 );  	llassert( s2 == "yl"); diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp index 06e118aa44..1a66612e87 100755 --- a/indra/llcommon/llsys.cpp +++ b/indra/llcommon/llsys.cpp @@ -99,8 +99,6 @@ const char MEMINFO_FILE[] = "/proc/meminfo";  extern int errno;  #endif - -static const S32 CPUINFO_BUFFER_SIZE = 16383;  LLCPUInfo gSysCPU;  // Don't log memory info any more often than this. It also serves as our @@ -672,8 +670,6 @@ const std::string& LLOSInfo::getOSVersionString() const  	return mOSVersionString;  } -const S32 STATUS_SIZE = 8192; -  //static  U32 LLOSInfo::getProcessVirtualSizeKB()  { @@ -681,6 +677,7 @@ U32 LLOSInfo::getProcessVirtualSizeKB()  #if LL_WINDOWS  #endif  #if LL_LINUX +#   define STATUS_SIZE 2048	  	LLFILE* status_filep = LLFile::fopen("/proc/self/status", "rb");  	if (status_filep)  	{ diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp index 51c89e1eaf..c3f235c6ee 100755 --- a/indra/llcommon/llthread.cpp +++ b/indra/llcommon/llthread.cpp @@ -92,13 +92,7 @@ void set_thread_name( DWORD dwThreadID, const char* threadName)  //   //---------------------------------------------------------------------------- -#if LL_DARWIN -// statically allocated thread local storage not supported in Darwin executable formats -#elif LL_WINDOWS -U32 __declspec(thread) sThreadID = 0; -#elif LL_LINUX -U32 __thread sThreadID = 0; -#endif  +U32 LL_THREAD_LOCAL sThreadID = 0;  U32 LLThread::sIDIter = 0; @@ -115,9 +109,7 @@ LL_COMMON_API void assert_main_thread()  void LLThread::registerThreadID()  { -#if !LL_DARWIN  	sThreadID = ++sIDIter; -#endif  }  // @@ -134,9 +126,7 @@ void *APR_THREAD_FUNC LLThread::staticRun(apr_thread_t *apr_threadp, void *datap  	// for now, hard code all LLThreads to report to single master thread recorder, which is known to be running on main thread  	threadp->mRecorder = new LLTrace::ThreadRecorder(*LLTrace::get_master_thread_recorder()); -#if !LL_DARWIN  	sThreadID = threadp->mID; -#endif  	// Run the user supplied function  	threadp->run(); @@ -347,13 +337,7 @@ void LLThread::setQuitting()  // static  U32 LLThread::currentID()  { -#if LL_DARWIN -	// statically allocated thread local storage not supported in Darwin executable formats -	return (U32)apr_os_thread_current(); -#else  	return sThreadID; -#endif -  }  // static diff --git a/indra/llcommon/llthreadlocalstorage.h b/indra/llcommon/llthreadlocalstorage.h index ec3b52c8cb..3b5786023f 100644 --- a/indra/llcommon/llthreadlocalstorage.h +++ b/indra/llcommon/llthreadlocalstorage.h @@ -130,56 +130,19 @@ class LLThreadLocalSingletonPointer  public:  	LL_FORCE_INLINE static DERIVED_TYPE* getInstance()  	{ -#if LL_DARWIN -        createTLSKey(); -        return (DERIVED_TYPE*)pthread_getspecific(sInstanceKey); -#else  		return sInstance; -#endif  	}  	static void setInstance(DERIVED_TYPE* instance)  	{ -#if LL_DARWIN -        createTLSKey(); -        pthread_setspecific(sInstanceKey, (void*)instance); -#else  		sInstance = instance; -#endif  	}  private: - -#if LL_WINDOWS -	static __declspec(thread) DERIVED_TYPE* sInstance; -#elif LL_LINUX -	static __thread DERIVED_TYPE* sInstance; -#elif LL_DARWIN -    static void TLSError() -    { -        LL_ERRS() << "Could not create thread local storage" << LL_ENDL; -    } -    static void createTLSKey() -    { -        static S32 key_created = pthread_key_create(&sInstanceKey, NULL); -        if (key_created != 0) -        { -            LL_ERRS() << "Could not create thread local storage" << LL_ENDL; -        } -    } -    static pthread_key_t sInstanceKey; -#endif +	static LL_THREAD_LOCAL DERIVED_TYPE* sInstance;  }; -#if LL_WINDOWS -template<typename DERIVED_TYPE> -__declspec(thread) DERIVED_TYPE* LLThreadLocalSingletonPointer<DERIVED_TYPE>::sInstance = NULL; -#elif LL_LINUX -template<typename DERIVED_TYPE> -__thread DERIVED_TYPE* LLThreadLocalSingletonPointer<DERIVED_TYPE>::sInstance = NULL; -#elif LL_DARWIN  template<typename DERIVED_TYPE> -pthread_key_t LLThreadLocalSingletonPointer<DERIVED_TYPE>::sInstanceKey; -#endif +LL_THREAD_LOCAL DERIVED_TYPE* LLThreadLocalSingletonPointer<DERIVED_TYPE>::sInstance = NULL;  #endif // LL_LLTHREADLOCALSTORAGE_H diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp index ab105a82e6..76e892212a 100755 --- a/indra/llcommon/lltimer.cpp +++ b/indra/llcommon/lltimer.cpp @@ -39,14 +39,10 @@  #	error "architecture not supported"  #endif -  //  // Locally used constants  // -const F64 SEC_TO_MICROSEC = 1000000.f;  const U64 SEC_TO_MICROSEC_U64 = 1000000; -const F64 USEC_TO_SEC_F64 = 0.000001; -  //---------------------------------------------------------------------------  // Globals and statics diff --git a/indra/llcommon/lltraceaccumulators.h b/indra/llcommon/lltraceaccumulators.h index 42fad8a793..6f27b97dff 100644 --- a/indra/llcommon/lltraceaccumulators.h +++ b/indra/llcommon/lltraceaccumulators.h @@ -62,11 +62,11 @@ namespace LLTrace  		{}  	public: - -		AccumulatorBuffer(const AccumulatorBuffer& other = *getDefaultBuffer()) -		:	mStorageSize(0), +		AccumulatorBuffer() +			: mStorageSize(0),  			mStorage(NULL)  		{ +			const AccumulatorBuffer& other = *getDefaultBuffer();  			resize(sNextStorageSlot);  			for (S32 i = 0; i < sNextStorageSlot; i++)  			{ @@ -93,6 +93,18 @@ namespace LLTrace  			return mStorage[index];   		} + +		AccumulatorBuffer(const AccumulatorBuffer& other) +			: mStorageSize(0), +			mStorage(NULL) +		{ +			resize(sNextStorageSlot); +			for (S32 i = 0; i < sNextStorageSlot; i++) +			{ +				mStorage[i] = other.mStorage[i]; +			} +		} +  		void addSamples(const AccumulatorBuffer<ACCUMULATOR>& other, EBufferAppendType append_type)  		{  			llassert(mStorageSize >= sNextStorageSlot && other.mStorageSize >= sNextStorageSlot); diff --git a/indra/llcommon/llunittype.h b/indra/llcommon/llunittype.h index 0e05ecd683..ac8504ca61 100644 --- a/indra/llcommon/llunittype.h +++ b/indra/llcommon/llunittype.h @@ -87,6 +87,40 @@ struct LLUnit  	:	mValue(value)  	{} + +	LL_FORCE_INLINE static self_t convert(self_t v)  +	{  +		return v; +	} + +	template<typename FROM_STORAGE_TYPE> +	LL_FORCE_INLINE static self_t convert(LLUnit<FROM_STORAGE_TYPE, UNITS> v)  +	{ +		self_t result; +		result.mValue = (STORAGE_TYPE)v.value(); +		return result; +	} + +	template<typename FROM_UNITS> +	LL_FORCE_INLINE static self_t convert(LLUnit<STORAGE_TYPE, FROM_UNITS> v)  +	{ +		self_t result; +		STORAGE_TYPE divisor = ll_convert_units(v, result); +		result.mValue /= divisor; +		return result; +	} + +	template<typename FROM_STORAGE_TYPE, typename FROM_UNITS> +	LL_FORCE_INLINE static self_t convert(LLUnit<FROM_STORAGE_TYPE, FROM_UNITS> v)  +	{  +		typedef typename LLResultTypePromote<FROM_STORAGE_TYPE, STORAGE_TYPE>::type_t result_storage_t; +		LLUnit<result_storage_t, UNITS> result; +		result_storage_t divisor = ll_convert_units(v, result); +		result.value(result.value() / divisor); +		return self_t(result.value()); +	} + +  	// unit initialization and conversion  	template<typename OTHER_STORAGE_TYPE, typename OTHER_UNITS>  	LL_FORCE_INLINE LLUnit(LLUnit<OTHER_STORAGE_TYPE, OTHER_UNITS> other) @@ -183,38 +217,6 @@ struct LLUnit  		return mValue >= convert(other).value();  	} -	LL_FORCE_INLINE static self_t convert(self_t v)  -	{  -		return v; -	} - -	template<typename FROM_STORAGE_TYPE> -	LL_FORCE_INLINE static self_t convert(LLUnit<FROM_STORAGE_TYPE, UNITS> v)  -	{ -		self_t result; -		result.mValue = (STORAGE_TYPE)v.value(); -		return result; -	} - -	template<typename FROM_UNITS> -	LL_FORCE_INLINE static self_t convert(LLUnit<STORAGE_TYPE, FROM_UNITS> v)  -	{ -		self_t result; -		STORAGE_TYPE divisor = ll_convert_units(v, result); -		result.mValue /= divisor; -		return result; -	} - -	template<typename FROM_STORAGE_TYPE, typename FROM_UNITS> -	LL_FORCE_INLINE static self_t convert(LLUnit<FROM_STORAGE_TYPE, FROM_UNITS> v)  -	{  -		typedef typename LLResultTypePromote<FROM_STORAGE_TYPE, STORAGE_TYPE>::type_t result_storage_t; -		LLUnit<result_storage_t, UNITS> result; -		result_storage_t divisor = ll_convert_units(v, result); -		result.value(result.value() / divisor); -		return self_t(result.value()); -	} -  protected:  	storage_t mValue;  }; @@ -269,7 +271,7 @@ struct LLUnitImplicit : public LLUnit<STORAGE_TYPE, UNITS>  	template<typename OTHER_STORAGE_TYPE, typename OTHER_UNITS>  	LL_FORCE_INLINE void operator += (LLUnitImplicit<OTHER_STORAGE_TYPE, OTHER_UNITS> other)  	{ -        base_t::mValue += convert(other).value(); +        base_t::mValue += base_t::convert(other).value();  	}  	using base_t::operator -=; @@ -283,19 +285,19 @@ struct LLUnitImplicit : public LLUnit<STORAGE_TYPE, UNITS>  	template<typename OTHER_STORAGE_TYPE, typename OTHER_UNITS>  	LL_FORCE_INLINE void operator -= (LLUnitImplicit<OTHER_STORAGE_TYPE, OTHER_UNITS> other)  	{ -        base_t::mValue -= convert(other).value(); +        base_t::mValue -= base_t::convert(other).value();  	}  	template<typename OTHER_STORAGE_TYPE, typename OTHER_UNITS>  	LL_FORCE_INLINE bool operator == (LLUnit<OTHER_STORAGE_TYPE, OTHER_UNITS> other) const  	{ -		return base_t::mValue == convert(other).value(); +		return base_t::mValue == base_t::convert(other).value();  	}  	template<typename OTHER_STORAGE_TYPE, typename OTHER_UNITS>  	LL_FORCE_INLINE bool operator == (LLUnitImplicit<OTHER_STORAGE_TYPE, OTHER_UNITS> other) const  	{ -		return base_t::mValue == convert(other).value(); +		return base_t::mValue == base_t::convert(other).value();  	}  	template<typename STORAGE_T> @@ -313,7 +315,7 @@ struct LLUnitImplicit : public LLUnit<STORAGE_TYPE, UNITS>  	template<typename OTHER_STORAGE_TYPE, typename OTHER_UNITS>  	LL_FORCE_INLINE bool operator != (LLUnitImplicit<OTHER_STORAGE_TYPE, OTHER_UNITS> other) const  	{ -		return base_t::mValue != convert(other).value(); +		return base_t::mValue != base_t::convert(other).value();  	}  	template<typename STORAGE_T> @@ -325,13 +327,13 @@ struct LLUnitImplicit : public LLUnit<STORAGE_TYPE, UNITS>  	template<typename OTHER_STORAGE_TYPE, typename OTHER_UNITS>  	LL_FORCE_INLINE bool operator < (LLUnit<OTHER_STORAGE_TYPE, OTHER_UNITS> other) const  	{ -		return base_t::mValue < convert(other).value(); +		return base_t::mValue < base_t::convert(other).value();  	}  	template<typename OTHER_STORAGE_TYPE, typename OTHER_UNITS>  	LL_FORCE_INLINE bool operator < (LLUnitImplicit<OTHER_STORAGE_TYPE, OTHER_UNITS> other) const  	{ -		return base_t::mValue < convert(other).value(); +		return base_t::mValue < base_t::convert(other).value();  	}  	template<typename STORAGE_T> @@ -343,13 +345,13 @@ struct LLUnitImplicit : public LLUnit<STORAGE_TYPE, UNITS>  	template<typename OTHER_STORAGE_TYPE, typename OTHER_UNITS>  	LL_FORCE_INLINE bool operator <= (LLUnit<OTHER_STORAGE_TYPE, OTHER_UNITS> other) const  	{ -		return base_t::mValue <= convert(other).value(); +		return base_t::mValue <= base_t::convert(other).value();  	}  	template<typename OTHER_STORAGE_TYPE, typename OTHER_UNITS>  	LL_FORCE_INLINE bool operator <= (LLUnitImplicit<OTHER_STORAGE_TYPE, OTHER_UNITS> other) const  	{ -		return base_t::mValue <= convert(other).value(); +		return base_t::mValue <= base_t::convert(other).value();  	}  	template<typename STORAGE_T> @@ -361,13 +363,13 @@ struct LLUnitImplicit : public LLUnit<STORAGE_TYPE, UNITS>  	template<typename OTHER_STORAGE_TYPE, typename OTHER_UNITS>  	LL_FORCE_INLINE bool operator > (LLUnit<OTHER_STORAGE_TYPE, OTHER_UNITS> other) const  	{ -		return base_t::mValue > convert(other).value(); +		return base_t::mValue > base_t::convert(other).value();  	}  	template<typename OTHER_STORAGE_TYPE, typename OTHER_UNITS>  	LL_FORCE_INLINE bool operator > (LLUnitImplicit<OTHER_STORAGE_TYPE, OTHER_UNITS> other) const  	{ -		return base_t::mValue > convert(other).value(); +		return base_t::mValue > base_t::convert(other).value();  	}  	template<typename STORAGE_T> @@ -379,13 +381,13 @@ struct LLUnitImplicit : public LLUnit<STORAGE_TYPE, UNITS>  	template<typename OTHER_STORAGE_TYPE, typename OTHER_UNITS>  	LL_FORCE_INLINE bool operator >= (LLUnit<OTHER_STORAGE_TYPE, OTHER_UNITS> other) const  	{ -		return base_t::mValue >= convert(other).value(); +		return base_t::mValue >= base_t::convert(other).value();  	}  	template<typename OTHER_STORAGE_TYPE, typename OTHER_UNITS>  	LL_FORCE_INLINE bool operator >= (LLUnitImplicit<OTHER_STORAGE_TYPE, OTHER_UNITS> other) const  	{ -		return base_t::mValue >= convert(other).value(); +		return base_t::mValue >= base_t::convert(other).value();  	}  	template<typename STORAGE_T> diff --git a/indra/llcommon/stringize.h b/indra/llcommon/stringize.h index 2df008febb..a5a90d7297 100755 --- a/indra/llcommon/stringize.h +++ b/indra/llcommon/stringize.h @@ -30,7 +30,7 @@  #define LL_STRINGIZE_H  #include <sstream> -#include <boost/lambda/lambda.hpp> +#include <boost/phoenix/phoenix.hpp>  #include <llstring.h>  /** @@ -108,7 +108,7 @@ std::string stringize_f(Functor const & f)   * return out.str();   * @endcode   */ -#define STRINGIZE(EXPRESSION) (stringize_f(boost::lambda::_1 << EXPRESSION)) +#define STRINGIZE(EXPRESSION) (stringize_f(boost::phoenix::placeholders::arg1 << EXPRESSION))  /** @@ -144,7 +144,7 @@ void destringize_f(std::string const & str, Functor const & f)   * in >> item1 >> item2 >> item3 ... ;   * @endcode   */ -#define DESTRINGIZE(STR, EXPRESSION) (destringize_f((STR), (boost::lambda::_1 >> EXPRESSION))) +#define DESTRINGIZE(STR, EXPRESSION) (destringize_f((STR), (boost::phoenix::placeholders::arg1 >> EXPRESSION)))  #endif /* ! defined(LL_STRINGIZE_H) */ diff --git a/indra/llcommon/tests/lldependencies_test.cpp b/indra/llcommon/tests/lldependencies_test.cpp index 5395d785b6..b5e189a465 100755 --- a/indra/llcommon/tests/lldependencies_test.cpp +++ b/indra/llcommon/tests/lldependencies_test.cpp @@ -37,29 +37,14 @@  // associated header  #include "../lldependencies.h"  // other Linden headers -#include "../test/lltut.h" - -using boost::assign::list_of;  #if LL_WINDOWS  #pragma warning (disable : 4675) // "resolved by ADL" -- just as I want!  #endif -typedef LLDependencies<> StringDeps; -typedef StringDeps::KeyList StringList; - -// We use the very cool boost::assign::list_of() construct to specify vectors -// of strings inline. For reasons on which I'm not entirely clear, though, it -// needs a helper function. You can use list_of() to construct an implicit -// StringList (std::vector<std::string>) by conversion, e.g. for a function -// parameter -- but if you simply write StringList(list_of("etc.")), you get -// ambiguity errors. Shrug! -template<typename CONTAINER> -CONTAINER make(const CONTAINER& data) -{ -    return data; -} - +/***************************************************************************** +*   Display helpers: must be defined BEFORE lltut.h! +*****************************************************************************/  // Display an arbitary value as itself...  template<typename T>  std::ostream& display(std::ostream& out, const T& value) @@ -113,6 +98,31 @@ std::ostream& operator<<(std::ostream& out, const std::set<ENTRY>& set)      return out;  } +/***************************************************************************** +*   Now we can #include lltut.h +*****************************************************************************/ +#include "../test/lltut.h" + +/***************************************************************************** +*   Other helpers +*****************************************************************************/ +using boost::assign::list_of; + +typedef LLDependencies<> StringDeps; +typedef StringDeps::KeyList StringList; + +// We use the very cool boost::assign::list_of() construct to specify vectors +// of strings inline. For reasons on which I'm not entirely clear, though, it +// needs a helper function. You can use list_of() to construct an implicit +// StringList (std::vector<std::string>) by conversion, e.g. for a function +// parameter -- but if you simply write StringList(list_of("etc.")), you get +// ambiguity errors. Shrug! +template<typename CONTAINER> +CONTAINER make(const CONTAINER& data) +{ +    return data; +} +  const std::string& extract_key(const LLDependencies<>::value_type& entry)  {      return entry.first; diff --git a/indra/llcommon/tests/llerror_test.cpp b/indra/llcommon/tests/llerror_test.cpp index a5aaff10c5..f51279e817 100755 --- a/indra/llcommon/tests/llerror_test.cpp +++ b/indra/llcommon/tests/llerror_test.cpp @@ -38,6 +38,9 @@  namespace  { +#ifdef __clang__ +#   pragma clang diagnostic ignored "-Wunused-function" +#endif  	void test_that_error_h_includes_enough_things_to_compile_a_message()  	{  		LL_INFOS() << "!" << LL_ENDL; @@ -381,8 +384,6 @@ namespace  	};  	std::string logFromNamespace(bool id) { return Foo::logFromNamespace(id); } -	std::string logFromClassWithNoLogTypeMember(bool id) { ClassWithNoLogType c; return c.logFromMember(id); } -	std::string logFromClassWithNoLogTypeStatic(bool id) { return ClassWithNoLogType::logFromStatic(id); }  	std::string logFromClassWithLogTypeMember(bool id) { ClassWithLogType c; return c.logFromMember(id); }  	std::string logFromClassWithLogTypeStatic(bool id) { return ClassWithLogType::logFromStatic(id); } @@ -393,8 +394,8 @@ namespace  		if (n1 == std::string::npos)  		{  			std::stringstream ss; -			ss << message << ": " << "expected to find a copy of " << expected -				<< " in actual " << actual; +			ss << message << ": " << "expected to find a copy of '" << expected +			   << "' in actual '" << actual << "'";  			throw tut::failure(ss.str().c_str());  		}  	} @@ -435,9 +436,6 @@ namespace tut  		testLogName(mRecorder, logFromStatic);  		testLogName(mRecorder, logFromAnon);  		testLogName(mRecorder, logFromNamespace); -		//testLogName(mRecorder, logFromClassWithNoLogTypeMember, "ClassWithNoLogType"); -		//testLogName(mRecorder, logFromClassWithNoLogTypeStatic, "ClassWithNoLogType"); -			// XXX: figure out what the exepcted response is for these  		testLogName(mRecorder, logFromClassWithLogTypeMember, "ClassWithLogType");  		testLogName(mRecorder, logFromClassWithLogTypeStatic, "ClassWithLogType");  	} @@ -457,11 +455,6 @@ namespace  		return "bar";  	} -	void uberLogger() -	{ -		LL_INFOS() << "uber(" << outerLogger() << "," << innerLogger() << ")" << LL_ENDL; -	} -  	class LogWhileLogging  	{  	public: @@ -494,17 +487,10 @@ namespace tut  		ensure_message_contains(1, "outside(moo)");  		ensure_message_count(2); -		uberLogger(); -		ensure_message_contains(2, "inside"); -		ensure_message_contains(3, "inside"); -		ensure_message_contains(4, "outside(moo)"); -		ensure_message_contains(5, "uber(bar,moo)"); -		ensure_message_count(6); -  		metaLogger(); -		ensure_message_contains(6, "logging"); -		ensure_message_contains(7, "meta(baz)"); -		ensure_message_count(8); +		ensure_message_contains(2, "logging"); +		ensure_message_contains(3, "meta(baz)"); +		ensure_message_count(4);  	}  	template<> template<> diff --git a/indra/llcommon/tests/lleventcoro_test.cpp b/indra/llcommon/tests/lleventcoro_test.cpp index cb5e15eff2..2096807e53 100755 --- a/indra/llcommon/tests/lleventcoro_test.cpp +++ b/indra/llcommon/tests/lleventcoro_test.cpp @@ -94,7 +94,6 @@ using coroutines::coroutine;  template<typename Iter>  bool match(Iter first, Iter last, std::string match) {    std::string::iterator i = match.begin(); -  i != match.end();    for(; (first != last) && (i != match.end()); ++i) {      if (*first != *i)        return false; diff --git a/indra/llcommon/tests/llframetimer_test.cpp b/indra/llcommon/tests/llframetimer_test.cpp index 8ac1c91a3a..be372bb855 100755 --- a/indra/llcommon/tests/llframetimer_test.cpp +++ b/indra/llcommon/tests/llframetimer_test.cpp @@ -84,25 +84,34 @@ namespace tut  	template<> template<>  	void frametimer_object_t::test<3>()  	{ +		clock_t t1 = clock(); +		ms_sleep(200); +		clock_t t2 = clock(); +		clock_t elapsed = t2 - t1 + 1; +		std::cout << "Note: using clock(), ms_sleep() actually took " << (long)elapsed << "ms" << std::endl; +  		F64 seconds_since_epoch = LLFrameTimer::getTotalSeconds();  		seconds_since_epoch += 2.0;  		LLFrameTimer timer;  		timer.setExpiryAt(seconds_since_epoch); -		ensure("timer not expired on create", !timer.hasExpired()); -		int ii; -		for(ii = 0; ii < 10; ++ii) +		/* +		 * Note that the ms_sleep(200) below is only guaranteed to return +		 * in 200ms _or_more_, so it should be true that by the 10th +		 * iteration we've gotten to the 2 seconds requested above +		 * and the timer should expire, but it can expire in fewer iterations +		 * if one or more of the ms_sleep calls takes longer. +		 * (as it did when we moved to Mac OS X 10.10) +		 */ +		int iterations_until_expiration = 0; +		while ( !timer.hasExpired() )  		{ -			ms_sleep(150); -			LLFrameTimer::updateFrameTime();			 -		} -		ensure("timer not expired after a bit", !timer.hasExpired()); -		for(ii = 0; ii < 10; ++ii) -		{ -			ms_sleep(100); -			LLFrameTimer::updateFrameTime();			 +			ms_sleep(200); +			LLFrameTimer::updateFrameTime(); +			iterations_until_expiration++;  		} -		ensure("timer expired", timer.hasExpired()); +		ensure("timer took too long to expire", iterations_until_expiration <= 10);  	} +	  /*  	template<> template<>  	void frametimer_object_t::test<4>() diff --git a/indra/llcommon/tests/llleap_test.cpp b/indra/llcommon/tests/llleap_test.cpp index 9ea822cb8d..2d88e2c676 100755 --- a/indra/llcommon/tests/llleap_test.cpp +++ b/indra/llcommon/tests/llleap_test.cpp @@ -17,7 +17,7 @@  // std headers  // external library headers  #include <boost/assign/list_of.hpp> -#include <boost/lambda/lambda.hpp> +#include <boost/phoenix/core/argument.hpp>  #include <boost/foreach.hpp>  // other Linden headers  #include "../test/lltut.h" @@ -38,24 +38,7 @@ StringVec sv(const StringVec& listof) { return listof; }  #define sleep(secs) _sleep((secs) * 1000)  #endif -#if ! LL_WINDOWS  const size_t BUFFERED_LENGTH = 1023*1024; // try wrangling just under a megabyte of data -#else -// "Then there's Windows... sigh." The "very large message" test is flaky in a -// way that seems to point to either the OS (nonblocking writes to pipes) or -// possibly the apr_file_write() function. Poring over log messages reveals -// that at some point along the way apr_file_write() returns 11 (Resource -// temporarily unavailable, i.e. EAGAIN) and says it wrote 0 bytes -- even -// though it did write the chunk! Our next write attempt retries the same -// chunk, resulting in the chunk being duplicated at the child end, corrupting -// the data stream. Much as I would love to be able to fix it for real, such a -// fix would appear to require distinguishing bogus EAGAIN returns from real -// ones -- how?? Empirically this behavior is only observed when writing a -// "very large message". To be able to move forward at all, try to bypass this -// particular failure by adjusting the size of a "very large message" on -// Windows. -const size_t BUFFERED_LENGTH = 65336; -#endif  // LL_WINDOWS  void waitfor(const std::vector<LLLeap*>& instances, int timeout=60)  { @@ -109,7 +92,7 @@ namespace tut          llleap_data():              reader(".py",                     // This logic is adapted from vita.viewerclient.receiveEvent() -                   boost::lambda::_1 << +                   boost::phoenix::placeholders::arg1 <<                     "import re\n"                     "import os\n"                     "import sys\n" @@ -403,7 +386,7 @@ namespace tut          AckAPI api;          Result result;          NamedTempFile script("py", -                             boost::lambda::_1 << +                             boost::phoenix::placeholders::arg1 <<                               "from " << reader_module << " import *\n"                               // make a request on our little API                               "request(pump='" << api.getName() << "', data={})\n" @@ -441,7 +424,7 @@ namespace tut          ReqIDAPI api;          Result result;          NamedTempFile script("py", -                             boost::lambda::_1 << +                             boost::phoenix::placeholders::arg1 <<                               "import sys\n"                               "from " << reader_module << " import *\n"                               // Note that since reader imports llsd, this @@ -484,7 +467,7 @@ namespace tut          ReqIDAPI api;          Result result;          NamedTempFile script("py", -                             boost::lambda::_1 << +                             boost::phoenix::placeholders::arg1 <<                               "import sys\n"                               "from " << reader_module << " import *\n"                               // Generate a very large string value. diff --git a/indra/llcommon/tests/llprocess_test.cpp b/indra/llcommon/tests/llprocess_test.cpp index e4e766d51b..5ba343b183 100755 --- a/indra/llcommon/tests/llprocess_test.cpp +++ b/indra/llcommon/tests/llprocess_test.cpp @@ -85,7 +85,7 @@ static std::string readfile(const std::string& pathname, const std::string& desc      }      std::ifstream inf(pathname.c_str());      std::string output; -    tut::ensure(STRINGIZE("No output " << use_desc), std::getline(inf, output)); +    tut::ensure(STRINGIZE("No output " << use_desc), bool(std::getline(inf, output)));      std::string more;      while (std::getline(inf, more))      { @@ -154,7 +154,7 @@ struct PythonProcessLauncher      void launch()      {          mPy = LLProcess::create(mParams); -        tut::ensure(STRINGIZE("Couldn't launch " << mDesc << " script"), mPy); +        tut::ensure(STRINGIZE("Couldn't launch " << mDesc << " script"), bool(mPy));      }      /// Run Python script and wait for it to complete. @@ -873,7 +873,7 @@ namespace tut          std::string threw;                                              \          /* Both the following calls should work. */                     \          (PROCESS).GETPIPE(VALID);                                       \ -        ensure(#GETOPTPIPE "(" #VALID ") failed", (PROCESS).GETOPTPIPE(VALID)); \ +        ensure(#GETOPTPIPE "(" #VALID ") failed", bool((PROCESS).GETOPTPIPE(VALID))); \          /* pass obviously bogus PIPESLOT */                             \          CATCH_IN(threw, LLProcess::NoPipe, (PROCESS).GETPIPE(LLProcess::FILESLOT(4))); \          ensure_contains("didn't reject bad slot", threw, "no slot");    \ diff --git a/indra/llcommon/tests/llsdserialize_test.cpp b/indra/llcommon/tests/llsdserialize_test.cpp index b5893135ea..6fbb9abfc0 100755 --- a/indra/llcommon/tests/llsdserialize_test.cpp +++ b/indra/llcommon/tests/llsdserialize_test.cpp @@ -46,9 +46,10 @@ typedef U32 uint32_t;  #include "boost/range.hpp"  #include "boost/foreach.hpp"  #include "boost/function.hpp" -#include "boost/lambda/lambda.hpp" -#include "boost/lambda/bind.hpp" -namespace lambda = boost::lambda; +#include "boost/bind.hpp" +#include "boost/phoenix/bind/bind_function.hpp" +#include "boost/phoenix/core/argument.hpp" +using namespace boost::phoenix;  #include "../llsd.h"  #include "../llsdserialize.h" @@ -1612,6 +1613,20 @@ namespace tut                 "print 'Running on', sys.platform\n");      } +    // helper for test<3> +    static void writeLLSDArray(std::ostream& out, const LLSD& array) +    { +        BOOST_FOREACH(LLSD item, llsd::inArray(array)) +        { +            LLSDSerialize::toNotation(item, out); +            // It's important to separate with newlines because Python's llsd +            // module doesn't support parsing from a file stream, only from a +            // string, so we have to know how much of the file to read into a +            // string. +            out << '\n'; +        } +    } +      template<> template<>      void TestPythonCompatibleObject::test<3>()      { @@ -1639,26 +1654,16 @@ namespace tut              "        assert False, 'Too many data items'\n";          // Create an llsdXXXXXX file containing 'data' serialized to -        // notation. It's important to separate with newlines because Python's -        // llsd module doesn't support parsing from a file stream, only from a -        // string, so we have to know how much of the file to read into a -        // string. +        // notation.          NamedTempFile file("llsd",                             // NamedTempFile's boost::function constructor                             // takes a callable. To this callable it passes the                             // std::ostream with which it's writing the -                           // NamedTempFile. This lambda-based expression -                           // first calls LLSD::Serialize() with that ostream, -                           // then streams a newline to it, etc. -                           (lambda::bind(LLSDSerialize::toNotation, cdata[0], lambda::_1), -                            lambda::_1 << '\n', -                            lambda::bind(LLSDSerialize::toNotation, cdata[1], lambda::_1), -                            lambda::_1 << '\n', -                            lambda::bind(LLSDSerialize::toNotation, cdata[2], lambda::_1), -                            lambda::_1 << '\n')); +                           // NamedTempFile. +                           boost::bind(writeLLSDArray, _1, cdata));          python("read C++ notation", -               lambda::_1 << +               placeholders::arg1 <<                 import_llsd <<                 "def parse_each(iterable):\n"                 "    for item in iterable:\n" @@ -1679,7 +1684,7 @@ namespace tut          NamedTempFile file("llsd", "");          python("write Python notation", -               lambda::_1 << +               placeholders::arg1 <<                 "from __future__ import with_statement\n" <<                 import_llsd <<                 "DATA = [\n" diff --git a/indra/llcommon/tests/llstring_test.cpp b/indra/llcommon/tests/llstring_test.cpp index 93d3968dbf..a7aa347222 100755 --- a/indra/llcommon/tests/llstring_test.cpp +++ b/indra/llcommon/tests/llstring_test.cpp @@ -27,11 +27,11 @@   */  #include "linden_common.h" -#include "../test/lltut.h"  #include <boost/assign/list_of.hpp>  #include "../llstring.h" -#include "StringVec.h" +#include "StringVec.h"                  // must come BEFORE lltut.h +#include "../test/lltut.h"  using boost::assign::list_of; | 
