revert RCU changes back to union-based solution to fix strict-aliasing; another -O3 warning cleaned up

git-svn-id: svn://localhost/ardour2/trunk@1545 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis
2007-03-01 19:49:00 +00:00
parent 12be8e527d
commit 5a05deb4b5
2 changed files with 19 additions and 11 deletions

View File

@@ -1095,7 +1095,13 @@ AudioDiskstream::_do_refill (Sample* mixdown_buffer, float* gain_buffer)
assert(mixdown_buffer);
assert(gain_buffer);
vector.buf[0] = 0;
vector.len[0] = 0;
vector.buf[1] = 0;
vector.len[1] = 0;
channels.front().playback_buf->get_write_vector (&vector);
if ((total_space = vector.len[0] + vector.len[1]) == 0) {
return 0;

View File

@@ -10,21 +10,23 @@ template<class T>
class RCUManager
{
public:
RCUManager (T* new_rcu_value) {
m_rcu_value = new boost::shared_ptr<T> (new_rcu_value);
}
virtual ~RCUManager() { delete m_rcu_value; }
boost::shared_ptr<T> reader () const { return *((boost::shared_ptr<T> *) g_atomic_pointer_get ((volatile gpointer*) &m_rcu_value)); }
RCUManager (T* new_rcu_value) {
x.m_rcu_value = new boost::shared_ptr<T> (new_rcu_value);
}
virtual ~RCUManager() { delete x.m_rcu_value; }
boost::shared_ptr<T> reader () const { return *((boost::shared_ptr<T> *) g_atomic_pointer_get (&x.gptr)); }
virtual boost::shared_ptr<T> write_copy () = 0;
virtual bool update (boost::shared_ptr<T> new_value) = 0;
volatile gpointer* pointer() const { return (volatile gpointer*) &m_rcu_value; }
protected:
volatile boost::shared_ptr<T>* m_rcu_value;
union {
boost::shared_ptr<T>* m_rcu_value;
volatile gpointer gptr;
} x;
};
@@ -57,7 +59,7 @@ public:
// store the current
current_write_old = (boost::shared_ptr<T>*) RCUManager<T>::m_rcu_value;
current_write_old = RCUManager<T>::x.m_rcu_value;
boost::shared_ptr<T> new_copy (new T(**current_write_old));
@@ -73,7 +75,7 @@ public:
// update, checking that nobody beat us to it
bool ret = g_atomic_pointer_compare_and_exchange (RCUManager<T>::pointer(),
bool ret = g_atomic_pointer_compare_and_exchange (&RCUManager<T>::x.gptr,
(gpointer) current_write_old,
(gpointer) new_spp);