Cut-over to inline assembly to tame the optimizer
parent
79ec88f5a6
commit
5f2c32af37
17
smartptr.h
17
smartptr.h
|
|
@ -45,21 +45,18 @@ private:
|
||||||
void operator=(const simple_ptr<T>& rhs); // assignment not allowed
|
void operator=(const simple_ptr<T>& rhs); // assignment not allowed
|
||||||
};
|
};
|
||||||
|
|
||||||
#if GCC_OPTIMIZE_AWARE
|
// Set m_p to NULL so double destruction (which might occur in Singleton) will be harmless
|
||||||
# pragma GCC push_options
|
|
||||||
# pragma GCC optimize ("-O0")
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// set m_p to NULL so double destruction (which might occur in Singleton) will be harmless
|
|
||||||
template <class T> simple_ptr<T>::~simple_ptr()
|
template <class T> simple_ptr<T>::~simple_ptr()
|
||||||
{
|
{
|
||||||
delete m_p;
|
delete m_p;
|
||||||
m_p = NULL;
|
m_p = NULL;
|
||||||
}
|
|
||||||
|
#ifdef __GNUC__
|
||||||
#if GCC_OPTIMIZE_AWARE
|
// From Andrew Haley (GCC Dev), to tame the optimizer so the assignment is always performed.
|
||||||
# pragma GCC pop_options
|
// See "Disable optimizations in one function" on the GCC mailing list.
|
||||||
|
asm volatile ("" : : : "memory");
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
template <class T> class member_ptr
|
template <class T> class member_ptr
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue