Workaround for gcc 4.2.x.

g++ 4.2 (and possibly earlier) apparently call a copy
constructor when passing a temporary to a function
that takes a const reference. Added code to allow
copy-constructing the AI*Access classes for this
compiler.

g++-4.2.x also bails out when it encounters files that
do not end on a newline. So, also added those where
they were missing.
This commit is contained in:
Aleric Inglewood
2011-05-09 20:22:04 +02:00
parent 75ff0fc04d
commit 81550aa6de
17 changed files with 55 additions and 18 deletions

View File

@@ -723,4 +723,4 @@ BOOL LLAudioDecodeMgr::addDecodeRequest(const LLUUID &uuid)
}
return FALSE;
}
}

View File

@@ -36,6 +36,11 @@
#include "llthread.h"
#include "llerror.h"
// g++ 4.2.x (and before?) have the bug that when you try to pass a temporary
// to a function taking a const reference, it still calls the copy constructor.
// Define this to hack around that.
#define AI_NEED_ACCESS_CC (defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ < 3)) || (__GNUC__ < 4)))
template<typename T> struct AIReadAccessConst;
template<typename T> struct AIReadAccess;
template<typename T> struct AIWriteAccess;
@@ -66,6 +71,10 @@ protected:
// Accessors.
T const* ptr() const { return reinterpret_cast<T const*>(mMemory); }
T* ptr() { return reinterpret_cast<T*>(mMemory); }
#if AI_NEED_ACCESS_CC
int mAccessCopyCount;
#endif
};
/**
@@ -239,12 +248,18 @@ struct AIReadAccessConst
mState(readlocked)
{
mWrapper.mRWLock.rdlock();
#if AI_NEED_ACCESS_CC
mWrapper.mAccessCopyCount = 1;
#endif
}
//! Destruct the AI*Access object.
// These should never be dynamically allocated, so there is no need to make this virtual.
~AIReadAccessConst()
{
#if AI_NEED_ACCESS_CC
if (--(this->mWrapper.mAccessCopyCount) > 0) return;
#endif
if (mState == readlocked)
mWrapper.mRWLock.rdunlock();
else if (mState == writelocked)
@@ -267,9 +282,14 @@ protected:
AIThreadSafe<T>& mWrapper; //!< Reference to the object that we provide access to.
state_type const mState; //!< The lock state that mWrapper is in.
#if !AI_NEED_ACCESS_CC
private:
// Disallow copy constructing directly.
AIReadAccessConst(AIReadAccessConst const&);
#else
public:
AIReadAccessConst(AIReadAccessConst const& orig) : mWrapper(orig.mWrapper), mState(orig.mState) { mWrapper.mAccessCopyCount++; }
#endif
};
/**
@@ -461,7 +481,13 @@ template<typename T>
struct AIAccess
{
//! Construct a AIAccess from a non-constant AIThreadSafeSimple.
AIAccess(AIThreadSafeSimple<T>& wrapper) : mWrapper(wrapper) { this->mWrapper.mMutex.lock(); }
AIAccess(AIThreadSafeSimple<T>& wrapper) : mWrapper(wrapper)
{
this->mWrapper.mMutex.lock();
#if AI_NEED_ACCESS_CC
this->mWrapper.mAccessCopyCount = 1;
#endif
}
//! Access the underlaying object for (read and) write access.
T* operator->() const { return this->mWrapper.ptr(); }
@@ -469,14 +495,25 @@ struct AIAccess
//! Access the underlaying object for (read and) write access.
T& operator*() const { return *this->mWrapper.ptr(); }
~AIAccess() { this->mWrapper.mMutex.unlock(); }
~AIAccess()
{
#if AI_NEED_ACCESS_CC
if (--(this->mWrapper.mAccessCopyCount) > 0) return;
#endif
this->mWrapper.mMutex.unlock();
}
protected:
AIThreadSafeSimple<T>& mWrapper; //!< Reference to the object that we provide access to.
#if !AI_NEED_ACCESS_CC
private:
// Disallow copy constructing directly.
AIAccess(AIAccess const&);
#else
public:
AIAccess(AIAccess const& orig) : mWrapper(orig.mWrapper) { this->mWrapper.mAccessCopyCount++; }
#endif
};
#endif

View File

@@ -238,4 +238,4 @@ void ASFloaterContactGroups::populateGroupList()
}
}
}
}
}

View File

@@ -92,4 +92,4 @@ email for me right now, also in all cap.
my father not very understand of free softwares
and he make a fun of RMS.
*/
*/

View File

@@ -100,4 +100,4 @@ protected:
BOOL mSpellDisplay;
};
#endif
#endif

View File

@@ -66,4 +66,4 @@ DSA *get_dsa2048()
if ((dsa->p == NULL) || (dsa->q == NULL) || (dsa->g == NULL))
{ DSA_free(dsa); return(NULL); }
return(dsa);
}
}

View File

@@ -590,4 +590,4 @@ EDSA::~EDSA()
{
delete mDSAImpl;
mDSAImpl = NULL;
}
}

View File

@@ -186,4 +186,4 @@ EmeraldBoobState EmeraldBoobUtils::idleUpdate(const EmeraldGlobalBoobConfig &con
newState.boobGrav = llclamp(newState.boobGrav, -1.5f, 2.0f);
return newState;
}
}

View File

@@ -2771,4 +2771,4 @@ void LLPanelObject::onPasteRotClip(void* user_data)
calcp->setVar(LLCalc::Y_ROT, mClipboardRot.mV[VY]);
calcp->setVar(LLCalc::Z_ROT, mClipboardRot.mV[VZ]);
self->sendRotation(FALSE);
}
}

View File

@@ -770,4 +770,4 @@ void LLPhysicsMotion::reset()
mCharacter->setVisualParamWeight((*iter).mParam,(*iter).mParam->getDefaultWeight());
}
}
}
}

View File

@@ -1789,4 +1789,4 @@ void LLPreviewGesture::onDonePreview(LLMultiGesture* gesture, void* data)
self->mPreviewGesture = NULL;
self->refresh();
}
}

View File

@@ -2669,4 +2669,4 @@ void LLLiveLSLEditor::saveAs()
fclose(fp);
fp = NULL;
}
// </edit>
// </edit>

View File

@@ -182,4 +182,4 @@ void LLSavedSettingsGlue::setColor4(const std::string &name, LLColor4 value)
gSavedSettings.setColor4(name, value);
else
gSavedPerAccountSettings.setColor4(name, value);
}*/
}*/

View File

@@ -626,4 +626,4 @@ void QToolAlign::align()
LLSelectMgr::getInstance()->sendMultipleUpdate(UPD_POSITION);
}
}

View File

@@ -46,4 +46,4 @@ private:
BOOL mForce;
};
#endif // Q_QTOOLALIGN_H
#endif // Q_QTOOLALIGN_H

View File

@@ -75,4 +75,4 @@ private:
static bool doDelete;
static std::stringstream sstr;
static int countingDone;
};
};

View File

@@ -178,4 +178,4 @@ void wlfPanel_AdvSettings::onChangePresetName(LLUICtrl* ctrl, void * userData)
current_preset = combo_box->getSelectedValue().asString();
LLWaterParamManager::instance()->loadPreset(current_preset);
}
}
}