static Bool PVR2DAllocNormal(struct PVR2DPixmap *ppix)
{
	assert(!ppix->pvr2dmem);
	assert(ppix->shmid < 0);
	assert(!ppix->shmaddr);
	assert(!ppix->shmsize);
	assert(!ppix->mallocaddr);

	if (!ppix->mallocsize)
		return TRUE;

#if SGX_CACHE_SEGMENTS
	if (GetFromCache (ppix))
		return TRUE;
#endif

	ppix->mallocaddr = calloc(1, ppix->mallocsize);
	if (!ppix->mallocaddr)
		return FALSE;

	/* Allocating memory makes it CPU owned and dirty */
	ppix->owner = PVR2D_OWNER_CPU;
	ppix->bCPUWrites = TRUE;

	return TRUE;
}
static Bool PVR2DAllocSHM(struct PVR2DPixmap *ppix)
{
	CALLTRACE("%s: Start\n", __func__);

	assert(!ppix->pvr2dmem);
	assert(ppix->shmid < 0);
	assert(!ppix->shmaddr);
	assert(!ppix->mallocaddr);
	assert(!ppix->mallocsize);

	if (!ppix->shmsize)
		return TRUE;

	assert(ppix->shmsize == ALIGN(ppix->shmsize, page_size));

#if SGX_CACHE_SEGMENTS
	if (GetFromCache (ppix))
	    if (ppix->shmaddr)
			return TRUE;
#endif

	ppix->shmid = shmget(IPC_PRIVATE, ppix->shmsize, IPC_CREAT | 0666);

	if (ppix->shmid == -1) {
		perror("shmget failed");
		return FALSE;
	}

	/* lock the SHM segment. This prevents swapping out the memory.
	 * Cache flush/invalidate could cause unhandled page fault
	 * if shared memory was swapped out
	 */
	if (0 != shmctl(ppix->shmid, SHM_LOCK, 0))
		ErrorF("shmctl(SHM_LOCK) failed\n");

	ppix->shmaddr = shmat(ppix->shmid, NULL, 0);

	/*
	 * Mark the segment as destroyed immediately. POSIX doesn't allow
	 * shmat() after this, but Linux does. This is much nicer since
	 * the segment can't be leaked if the X server crashes.
	 */
	shmctl(ppix->shmid, IPC_RMID, NULL);

	if (!ppix->shmaddr) {
		perror("shmat failed");
		ppix->shmid = -1;
		return FALSE;
	}

	/* Allocating memory makes it CPU owned and dirty */
	ppix->owner = PVR2D_OWNER_CPU;
	ppix->bCPUWrites = TRUE;

	PERF_INCREMENT2(shm_bytes, ppix->shmsize);
	PERF_INCREMENT(shm_segments);

	return TRUE;
}
Esempio n. 3
0
	void testThreadedGet()
	{

		Cache cache( get, hash, 10000, new ObjectPool(10000) );
		
		parallel_for( blocked_range<size_t>( 0, 10000 ), GetFromCache( cache ) );

		BOOST_CHECK_EQUAL( size_t(500), cache.cachedComputations() );
	}
Esempio n. 4
0
ePACKTYPE CPFCManager::GetPFCType(const CStdString& strPath) {
  CURL urlPath(strPath);
  CStdString strFile = urlPath.GetHostName();

  sFileMap fileMap;

  if (GetFromCache(strFile, fileMap, true))
  { // already listed, just return it, else append to cache
    return fileMap.sHeader.PackType;
  }

  return RPF_PACK_TYPE_NONE;
}
Esempio n. 5
0
// TODO(brettw): this function does not handle long paths (filename > MAX_PATH)
// characters). This isn't supported very well by Windows right now, so it is
// moot, but we should keep this in mind for the future.
// static
bool PathService::Get(int key, FilePath* result)
{
    PathData* path_data = GetPathData();
    DCHECK(path_data);
    DCHECK(result);
    DCHECK_GE(key, base::DIR_CURRENT);

    // special case the current directory because it can never be cached
    if(key == base::DIR_CURRENT)
    {
        return base::GetCurrentDirectory(result);
    }

    if(GetFromCache(key, result))
    {
        return true;
    }

    if(GetFromOverrides(key, result))
    {
        return true;
    }

    FilePath path;

    // search providers for the requested path
    // NOTE: it should be safe to iterate here without the lock
    // since RegisterProvider always prepends.
    Provider* provider = path_data->providers;
    while(provider)
    {
        if(provider->func(key, &path))
        {
            break;
        }
        DCHECK(path.empty()) << "provider should not have modified path";
        provider = provider->next;
    }

    if(path.empty())
    {
        return false;
    }

    AddToCache(key, path);

    *result = path;
    return true;
}
Esempio n. 6
0
bool CPFCManager::GetEntriesList(const CStdString& strPath, VECFILEENTRY& items) {
  CURL urlPath(strPath);
  CStdString strFile = urlPath.GetHostName();

  CLog::Log(LOGDEBUG, "%s - Processing %s", __FUNCTION__, strFile.c_str());

  sFileMap fileMap;

  if (GetFromCache(strFile, fileMap, true))
  { // already listed, just return it, else append to cache
    items = fileMap.vecFiles;
    return true;
  }

  return false;
}
Esempio n. 7
0
/****************************************************************************
 * Function:	    void DisplayTopic(
 *                              Widget parent,
 *                              char *helpVolume,
 *                              char *locationId)
 *
 * Parameters:      
 *
 * Return Value:    Void.
 *
 * Purpose: 	    Creats and displays a new help dialog w/the requested help
 *                  volume and topic.
 *
 ****************************************************************************/
void DisplayTopic(
    Widget  parent,
    char    *helpVolume,
    char    *locationId)

{
  Arg	 	args[10];	
  int           n;

 CacheListStruct *pCurrentNode = NULL;
  Boolean       cachedNode = FALSE;


  /* Get a inuse node if we have one or a Cached one */
  cachedNode = GetFromCache(parent, &pCurrentNode);


  /* If we got a free one from the Cache, use it */
  /* Set Values on current free one, then map it */
  if (cachedNode)
    {
       n = 0;
       XtSetArg (args[n], XmNtitle, "HelpDemo Help");          n++;
       if (helpVolume != NULL)
         {
           XtSetArg (args[n],DtNhelpVolume,helpVolume);     n++; 
         }
       XtSetArg (args[n], DtNlocationId,locationId);        n++;
       XtSetValues(pCurrentNode->helpDialog, args, n);
  
       XtManageChild(pCurrentNode->helpDialog);    
       XtMapWidget(XtParent(pCurrentNode->helpDialog));
     }
   else
     {
       while (!XtIsSubclass(parent, applicationShellWidgetClass))
         parent = XtParent(parent);
     


        /* Build a new one in our cached list */
        n = 0;
        XtSetArg (args[n], XmNtitle, "Helpdemo Help");          n++;
       if (helpVolume != NULL)
         {
           XtSetArg (args[n],DtNhelpVolume,helpVolume);     n++; 
         }
        XtSetArg (args[n], DtNlocationId,locationId);        n++;
        pCurrentNode->helpDialog =  
                   DtCreateHelpDialog(parent, "helpWidget", args, n);


        XtAddCallback(pCurrentNode->helpDialog, DtNhyperLinkCallback,
                       ProcessLinkCB, NULL);
             
        XtAddCallback(pCurrentNode->helpDialog, DtNcloseCallback,
                      CloseHelpCB, (XtPointer) pCurrentNode->helpDialog);

        XtManageChild(pCurrentNode->helpDialog);    
        XtMapWidget(XtParent(pCurrentNode->helpDialog));
     }
}