示例#1
0
bool CVolume::SetInUseOnTimer(int nms)
{
  m_nCountDown -= nms;
  bool bRtn = true;
  if(m_nCountDown <= 0)
  {
    bRtn = SetInUse();
    m_nCountDown = LOCK_READ_MS;
  }
  return bRtn;
}
示例#2
0
  int CreateKey(pthread_key_t* result, void (*key_destructor)(void*)) {
    // Take the first unallocated key.
    for (int key = 0; key < BIONIC_TLS_SLOTS; ++key) {
      if (!IsInUse(key)) {
        SetInUse(key, key_destructor);
        *result = key;
        return 0;
      }
    }

    // We hit PTHREAD_KEYS_MAX. POSIX says EAGAIN for this case.
    return EAGAIN;
  }
示例#3
0
  ScopedTlsMapAccess() {
    Lock();

    // If this is the first time the TLS map has been accessed,
    // mark the slots belonging to well-known keys as being in use.
    // This isn't currently necessary because the well-known keys
    // can only be accessed directly by bionic itself, do not have
    // destructors, and all the functions that touch the TLS map
    // start after the maximum well-known slot.
    if (!s_tls_map_.is_initialized) {
      for (pthread_key_t key = 0; key < TLS_SLOT_FIRST_USER_SLOT; ++key) {
        SetInUse(key, NULL);
      }
      s_tls_map_.is_initialized = true;
    }
  }
示例#4
0
文件: g_utils.cpp 项目: kikili/OpenJK
void G_InitGentity( gentity_t *e ) 
{
	e->inuse = qtrue;
	SetInUse(e);
	e->classname = "noclass";
	e->s.number = e - g_entities;

	ICARUS_FreeEnt( e );	//ICARUS information must be added after this point
	
	// remove any ghoul2 models here
	//let not gi.G2API_CleanGhoul2Models(e->ghoul2);

	//Navigational setups
	e->waypoint				= WAYPOINT_NONE;
	e->lastWaypoint			= WAYPOINT_NONE;
	e->lastValidWaypoint	= WAYPOINT_NONE;
}
示例#5
0
文件: g_utils.cpp 项目: BSzili/OpenJK
void G_InitGentity( gentity_t *e, qboolean bFreeG2 ) 
{
	e->inuse = qtrue;
	SetInUse(e);
	e->m_iIcarusID = IIcarusInterface::ICARUS_INVALID;
	e->classname = "noclass";
	e->s.number = e - g_entities;
	
	// remove any ghoul2 models here in case we're reusing
	if (bFreeG2 && e->ghoul2.IsValid())
	{
		gi.G2API_CleanGhoul2Models(e->ghoul2);
	}
	//Navigational setups
	e->waypoint				= WAYPOINT_NONE;
	e->lastWaypoint			= WAYPOINT_NONE;
}
示例#6
0
/*********************************************************************
* FindFreeSpace
*********************************************************************/
void * FindFreeSpace(void * pStart, size_t tSize)
{
BYTE _huge * pHeapStart;
BYTE _huge * pHeapEnd;
BYTE _huge * pWork;
BYTE _huge * pNext;
USHORT rc;

   pHeapStart = pStart;
   pHeapEnd = pHeapStart + HEAP_SIZE;

   rc = MY_PROBEBUF(PB_OPREAD, (PBYTE)pHeapStart, HEAP_SIZE);
   if (rc)
      {
      CritMessage("FAT32: Protection VIOLATION in FindFreeSpace (SYS%d)", rc);
      Message("FAT32: Protection VIOLATION in FindFreeSpace (SYS%d)", rc);
      return NULL;
      }

   pWork = pHeapStart;
   while (pWork < pHeapEnd)
      {
      if (BlockSize(pWork) >= tSize && IsBlockFree(pWork))
         {
         ULONG ulRemaining = BlockSize(pWork) - tSize;
         if (ulRemaining > sizeof (ULONG))
            {
            pNext = pWork + sizeof (ULONG) + tSize;
            SetBlockSize(pNext, BlockSize(pWork) - tSize - sizeof (ULONG));
            SetFree(pNext);
            SetBlockSize(pWork, tSize);
            }

         SetInUse(pWork);
         return pWork + sizeof (ULONG);
         }
      pWork += BlockSize(pWork) + sizeof (ULONG);
      }
   return NULL;
}
示例#7
0
/*********************************************************************
* FindFreeSpace
*********************************************************************/
void * FindFreeSpace(void * pStart, size_t tSize)
{
BYTE _huge * pHeapStart;
BYTE _huge * pHeapEnd;
BYTE _huge * pWork;
BYTE _huge * pNext;

   pHeapStart = pStart;
   pHeapEnd = pHeapStart + HEAP_SIZE;

   pWork = pHeapStart;
   while (pWork < pHeapEnd)
      {
      if (BlockSize(pWork) >= tSize && IsBlockFree(pWork))
         {
         ULONG ulRemaining = BlockSize(pWork) - tSize;
         if (ulRemaining > sizeof (ULONG))
            {
            pNext = pWork + sizeof (ULONG) + tSize;
            SetBlockSize(pNext, BlockSize(pWork) - tSize - sizeof (ULONG));
            SetFree(pNext);
            SetBlockSize(pWork, tSize);
            }
         else
            {
            printf("Remaining %lu bytes\n", ulRemaining);
            ulMem += ulRemaining;
            }

         SetInUse(pWork);
         return pWork + sizeof (ULONG);
         }
      pWork += BlockSize(pWork) + sizeof (ULONG);
      }
   return NULL;
}