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:
@@ -723,4 +723,4 @@ BOOL LLAudioDecodeMgr::addDecodeRequest(const LLUUID &uuid)
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -238,4 +238,4 @@ void ASFloaterContactGroups::populateGroupList()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
*/
|
||||
|
||||
@@ -100,4 +100,4 @@ protected:
|
||||
BOOL mSpellDisplay;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -66,4 +66,4 @@ DSA *get_dsa2048()
|
||||
if ((dsa->p == NULL) || (dsa->q == NULL) || (dsa->g == NULL))
|
||||
{ DSA_free(dsa); return(NULL); }
|
||||
return(dsa);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -590,4 +590,4 @@ EDSA::~EDSA()
|
||||
{
|
||||
delete mDSAImpl;
|
||||
mDSAImpl = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,4 +186,4 @@ EmeraldBoobState EmeraldBoobUtils::idleUpdate(const EmeraldGlobalBoobConfig &con
|
||||
newState.boobGrav = llclamp(newState.boobGrav, -1.5f, 2.0f);
|
||||
|
||||
return newState;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -770,4 +770,4 @@ void LLPhysicsMotion::reset()
|
||||
mCharacter->setVisualParamWeight((*iter).mParam,(*iter).mParam->getDefaultWeight());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1789,4 +1789,4 @@ void LLPreviewGesture::onDonePreview(LLMultiGesture* gesture, void* data)
|
||||
self->mPreviewGesture = NULL;
|
||||
|
||||
self->refresh();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2669,4 +2669,4 @@ void LLLiveLSLEditor::saveAs()
|
||||
fclose(fp);
|
||||
fp = NULL;
|
||||
}
|
||||
// </edit>
|
||||
// </edit>
|
||||
|
||||
@@ -182,4 +182,4 @@ void LLSavedSettingsGlue::setColor4(const std::string &name, LLColor4 value)
|
||||
gSavedSettings.setColor4(name, value);
|
||||
else
|
||||
gSavedPerAccountSettings.setColor4(name, value);
|
||||
}*/
|
||||
}*/
|
||||
|
||||
@@ -626,4 +626,4 @@ void QToolAlign::align()
|
||||
|
||||
|
||||
LLSelectMgr::getInstance()->sendMultipleUpdate(UPD_POSITION);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,4 +46,4 @@ private:
|
||||
BOOL mForce;
|
||||
};
|
||||
|
||||
#endif // Q_QTOOLALIGN_H
|
||||
#endif // Q_QTOOLALIGN_H
|
||||
|
||||
@@ -75,4 +75,4 @@ private:
|
||||
static bool doDelete;
|
||||
static std::stringstream sstr;
|
||||
static int countingDone;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -178,4 +178,4 @@ void wlfPanel_AdvSettings::onChangePresetName(LLUICtrl* ctrl, void * userData)
|
||||
current_preset = combo_box->getSelectedValue().asString();
|
||||
LLWaterParamManager::instance()->loadPreset(current_preset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user