void ChangeList::addSubRefd(const UInt32 uiContainerId,
                                  bool   ignoreLevel  )
{
#ifdef OSG_ENABLE_VALGRIND_CHECKS
    VALGRIND_CHECK_VALUE_IS_DEFINED(uiContainerId);
#endif

#ifndef SILENT
    fprintf(stderr, "Add SubRef %u\n", uiContainerId);
#endif

    if(_bReadOnly == true)
        return;

    ContainerChangeEntry *pEntry = getNewEntry();

    if(_iSubRefLevel == 0 || ignoreLevel == true)
    {
        pEntry->uiEntryDesc   = ContainerChangeEntry::SubReference;
    }
    else
    {
        pEntry->uiEntryDesc   = ContainerChangeEntry::DepSubReference;
    }

    pEntry->uiContainerId = uiContainerId;
    pEntry->pList         = this;
}
UInt32 FieldContainerFactoryBase::registerContainer(
    const ContainerPtr &pContainer)
{
#ifdef OSG_ENABLE_VALGRIND_CHECKS
    VALGRIND_CHECK_VALUE_IS_DEFINED(pContainer);
#endif

    _pStoreLock->acquire();

    UInt32 returnValue =  _nextContainerId++;

#ifdef OSG_MT_CPTR_ASPECT
    ContainerHandlerP pHandler = NULL;

    if(pContainer != NULL)
        pHandler = pContainer->getAspectStore();

    _containerStore.insert(
        ContainerStore::value_type(returnValue, pHandler));
#else
    _containerStore.insert(
        ContainerStore::value_type(returnValue, pContainer));
#endif

    _pStoreLock->release();

    return returnValue;
}
OSG_BEGIN_NAMESPACE

#define SILENT
#define SILENT_CPTR

#if 1
void ChangeList::addAddRefd(const UInt32 uiContainerId)
{
#ifdef OSG_ENABLE_VALGRIND_CHECKS
    VALGRIND_CHECK_VALUE_IS_DEFINED(uiContainerId);
#endif

#ifndef SILENT
    fprintf(stderr, "Add AddRef %u\n",
            uiContainerId);
#endif

    if(_bReadOnly == true)
        return;

    ContainerChangeEntry *pEntry = getNewEntry();

    pEntry->uiEntryDesc   = ContainerChangeEntry::AddReference;
    pEntry->uiContainerId = uiContainerId;
    pEntry->pList         = this;
}
void ContainerChangeEntry::commitChanges(UInt32 AdditionalChangeOrigin)
{
#ifdef OSG_ENABLE_VALGRIND_CHECKS
    VALGRIND_CHECK_VALUE_IS_DEFINED(uiContainerId);
#endif
    FieldContainer *pTmp =
        FieldContainerFactory::the()->getContainer(uiContainerId);

    if(pTmp != NULL)
    {
#ifndef SILENT
        fprintf(stderr, "Commit for %u %s\n",
                uiContainerId, pTmp->getType().getCName());
#endif
        
        BitVector tmpChanges;
        //OSG_ASSERT(NULL !=  bvUncommittedChanges);

        if (NULL != bvUncommittedChanges)
        { 
#ifdef OSG_ENABLE_MEMORY_DEBUGGING
           OSG_ASSERT(*bvUncommittedChanges != 0xDEADBEEF);
#endif
           tmpChanges             = *bvUncommittedChanges; 
           whichField            |= *bvUncommittedChanges;
           *bvUncommittedChanges  = TypeTraits<BitVector>::BitsClear;

           pTmp->changed      (tmpChanges, ChangedOrigin::Commit | AdditionalChangeOrigin, 0);
        }
    }
}
void ChangeList::addCreated(const UInt32 uiContainerId, 
                                  BitVector bFlags    )
{
#ifdef OSG_ENABLE_VALGRIND_CHECKS
    VALGRIND_CHECK_VALUE_IS_DEFINED(uiContainerId);
#endif

#ifndef SILENT
    FieldContainer *fcPtr =  
        FieldContainerFactory::the()->getContainer(uiContainerId);

    fprintf(stderr, "Add Create %u : %d : %s\n",
            uiContainerId,
            fcPtr != NULL ? fcPtr->getTypeId() : -1,
            fcPtr != NULL ? fcPtr->getType  ().getCName() : "Unknow");
#endif
    if(_bReadOnly == true)
        return;

    ContainerChangeEntry *pEntry = getNewCreatedEntry();

    pEntry->uiEntryDesc   = ContainerChangeEntry::Create;
    pEntry->uiContainerId = uiContainerId;
    pEntry->whichField    = bFlags;
}
Example #6
0
	peer_class* peer_class_pool::at(peer_class_t c)
	{
#ifdef TORRENT_USE_VALGRIND
		VALGRIND_CHECK_VALUE_IS_DEFINED(c);
#endif
		if (c >= m_peer_classes.size()) return 0;
		return m_peer_classes[c].get();
	}
Example #7
0
	void peer_class_pool::incref(peer_class_t c)
	{
#ifdef TORRENT_USE_VALGRIND
		VALGRIND_CHECK_VALUE_IS_DEFINED(c);
#endif
		TORRENT_ASSERT(c < m_peer_classes.size());
		TORRENT_ASSERT(m_peer_classes[c].get());

		++m_peer_classes[c]->references;
	}
Example #8
0
	void peer_class_pool::decref(peer_class_t c)
	{
#ifdef TORRENT_USE_VALGRIND
		VALGRIND_CHECK_VALUE_IS_DEFINED(c);
#endif
		TORRENT_ASSERT(c < m_peer_classes.size());
		TORRENT_ASSERT(m_peer_classes[c].get());

		--m_peer_classes[c]->references;
		if (m_peer_classes[c]->references) return;
		m_peer_classes[c].reset();
		m_free_list.push_back(c);
	}
	boost::int64_t counters::operator[](int i) const
	{
		TORRENT_ASSERT(i >= 0);
		TORRENT_ASSERT(i < num_counters);
#ifdef TORRENT_USE_VALGRIND
		VALGRIND_CHECK_VALUE_IS_DEFINED(m_stats_counter[i]);
#endif

#if BOOST_ATOMIC_LLONG_LOCK_FREE == 2
		return m_stats_counter[i].load(boost::memory_order_relaxed);
#else
		mutex::scoped_lock l(m_mutex);
		return m_stats_counter[i];
#endif
	}
int VG_WRAP_FUNCTION_ZU(VG_Z_LIBC_SONAME, setenv)
(const char* name, const char* value, int overwrite)
{
    OrigFn fn;
    Word result;
    const char* p;
    VALGRIND_GET_ORIG_FN(fn);
    if (name)
        for (p = name; *p; p++)
            __asm__ __volatile__("" ::: "memory");
    if (value)
        for (p = value; *p; p++)
            __asm__ __volatile__("" ::: "memory");
    VALGRIND_CHECK_VALUE_IS_DEFINED (overwrite);
    CALL_FN_W_WWW(result, fn, name, value, overwrite);
    return result;
}
int VG_WRAP_FUNCTION_ZU(VG_Z_LIBC_SONAME, setenv)
    (const char* name, const char* value, int overwrite)
{
    OrigFn fn;
    Word result;
    const char* p;
    VALGRIND_GET_ORIG_FN(fn);
    /* Now by walking over the string we magically produce
       traces when hitting undefined memory. */
    if (name)
        for (p = name; *p; p++)
            __asm__ __volatile__("" ::: "memory");
    if (value)
        for (p = value; *p; p++)
            __asm__ __volatile__("" ::: "memory");
    VALGRIND_CHECK_VALUE_IS_DEFINED (overwrite);
    CALL_FN_W_WWW(result, fn, name, value, overwrite);
    return result;
}