Exemplo n.º 1
0
// Substitute s into all members of the set
void LocationSet::substitute(Assign& a)
{
    Exp* lhs = a.getLeft();
    if (lhs == NULL) return;
    Exp* rhs = a.getRight();
    if (rhs == NULL) return;		// ? Will this ever happen?
    std::set<Exp*, lessExpStar>::iterator it;
    // Note: it's important not to change the pointer in the set of pointers to expressions, without removing and
    // inserting again. Otherwise, the set becomes out of order, and operations such as set comparison fail!
    // To avoid any funny behaviour when iterating the loop, we use the following two sets
    LocationSet removeSet;			// These will be removed after the loop
    LocationSet removeAndDelete;	// These will be removed then deleted
    LocationSet insertSet;			// These will be inserted after the loop
    bool change;
    for (it = lset.begin(); it != lset.end(); it++)
        {
            Exp* loc = *it;
            Exp* replace;
            if (loc->search(lhs, replace))
                {
                    if (rhs->isTerminal())
                        {
                            // This is no longer a location of interest (e.g. %pc)
                            removeSet.insert(loc);
                            continue;
                        }
                    loc = loc->clone()->searchReplaceAll(lhs, rhs, change);
                    if (change)
                        {
                            loc = loc->simplifyArith();
                            loc = loc->simplify();
                            // If the result is no longer a register or memory (e.g.
                            // r[28]-4), then delete this expression and insert any
                            // components it uses (in the example, just r[28])
                            if (!loc->isRegOf() && !loc->isMemOf())
                                {
                                    // Note: can't delete the expression yet, because the
                                    // act of insertion into the remove set requires silent
                                    // calls to the compare function
                                    removeAndDelete.insert(*it);
                                    loc->addUsedLocs(insertSet);
                                    continue;
                                }
                            // Else we just want to replace it
                            // Regardless of whether the top level expression pointer has
                            // changed, remove and insert it from the set of pointers
                            removeSet.insert(*it);		// Note: remove the unmodified ptr
                            insertSet.insert(loc);
                        }
                }
        }
    makeDiff(removeSet);	   // Remove the items to be removed
    makeDiff(removeAndDelete); // These are to be removed as well
    makeUnion(insertSet);	   // Insert the items to be added
    // Now delete the expressions that are no longer needed
    std::set<Exp*, lessExpStar>::iterator dd;
    for (dd = removeAndDelete.lset.begin(); dd != removeAndDelete.lset.end();
            dd++)
        delete *dd;				// Plug that memory leak
}
Exemplo n.º 2
0
/*__forceinline*/ int StateSystem::prepareTransitionCache(StateID prev, StateInternal& to )
{
  StateInternal& from = m_states[prev];

  int index = -1;

  for (int i = 0; i < MAX_DIFFS; i++){
    if ( to.others[i].state == prev && to.others[i].incarnation == from.incarnation) {
      index = i;
      break;
    }
  }

  if (index < 0){
    index = to.usedDiff;
    to.usedDiff = (to.usedDiff + 1) % MAX_DIFFS;

    to.others[index].state = prev;
    to.others[index].incarnation = from.incarnation;

    makeDiff(to.diffs[index], from, to);
  }

  return index;
}
Exemplo n.º 3
0
// Remove locations defined by any of the given set of statements
// Used for killing in liveness sets
void
LocationSet::removeIfDefines(const StatementSet &given)
{
	for (const auto &s : given) {
		LocationSet defs;
		s->getDefinitions(defs);
		makeDiff(defs);
	}
}
Exemplo n.º 4
0
int main(int argc, char *argv[])
{
  cv::VideoCapture cap(0);
  // 設定しても反映されていないかもだから注意
  cap.set(CV_CAP_PROP_FRAME_WIDTH, 240);
  cap.set(CV_CAP_PROP_FRAME_HEIGHT, 160);
  // カメラがオープンできたかの確認
  if (!cap.isOpened())
  {
    return -1;
  }

  cv::namedWindow("Capture", CV_WINDOW_AUTOSIZE | CV_WINDOW_FREERATIO);
  cv::namedWindow("Diff", CV_WINDOW_AUTOSIZE | CV_WINDOW_FREERATIO);

  ResultSet* result = new ResultSet();

  FILE * mylog;
  char logf[BSIZE];
  sprintf_s<BSIZE>(logf, DATA_DIR LOGFILE);
  fopen_s(&mylog, logf, "w");
  
  while (1) {
    preproc(cap, result);
    //映像が安定してから処理開始
    if (result->serial > START_FRAME)
    {
      makeDiff(result);
      result->nPix = countMat(result->diff);
      boundFace(result);
    }

    result->serial++;
    result->prev = result->gray.clone();
    //output log
    writelog(mylog, result);
    writeilog(result);
    showlog(result);

    if (result->serial > MAX_FRAME)
    {
      break;
    }
    Sleep(waitmil - WAITKEYMIL);
  }

  if (mylog != NULL)
  {
    fclose(mylog);
  }
  if (result != NULL)
  {
    delete result;
  }
  return 0;
}
Exemplo n.º 5
0
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

#ifndef _DEBUG_
    if(argc != 3){
        dump("引数が違います");
        return -1;
    }
#endif
    dump("開始");

    QString xpPath, sevenPath;
#ifndef _DEBUG_
    QString arg1(QString::fromUtf8(argv[1]));
    if( -1 != arg1.indexOf("xp")){
        xpPath = arg1;
        sevenPath = QString::fromUtf8(argv[2]);
    }
    else{
        xpPath = QString::fromUtf8(argv[2]);
        sevenPath = arg1;
    }
#else
    xpPath = f8("D:\\Programming\\Qt\\CoordinateDiff\\CoordinateDiff-build-desktop-Qt_4_8_1_for_Desktop_-_MinGW__Qt_SDK__Debug\\data\\xp");
    sevenPath = f8("D:\\Programming\\Qt\\CoordinateDiff\\CoordinateDiff-build-desktop-Qt_4_8_1_for_Desktop_-_MinGW__Qt_SDK__Debug\\data\\7");
#endif


    QDir xpFolder(xpPath);
    QFileInfoList xpFileList = xpFolder.entryInfoList(QDir::NoFilter, QDir::Name);

    QDir sevenFolder(sevenPath);
    QFileInfoList sevenFileList = sevenFolder.entryInfoList(QDir::NoFilter, QDir::Name);

    if(xpFileList.size() != sevenFileList.size()){
        dump("ファイル数が違います");
    }

    OString diffList;

    QFileInfoList xpOnlyList;
    // xpフォルダの各ファイルを、7フォルダ内のファイルから探して、
    // 差分を比較する。7フォルダ内に無かったら、そのファイルを記録しておく。
    foreach(QFileInfo xpFile, xpFileList){
        if(xpFile.fileName() == "." || xpFile.fileName() == "..")
            continue;

        bool xpOnly = true;
        foreach(QFileInfo sevenFile, sevenFileList){
            if(xpFile.fileName() == sevenFile.fileName()){

                // 差分を作成
                unsigned int bef = diffList.size();
                int ret = makeDiff( xpFile, sevenFile, diffList, ret);
                if(bef != diffList.size()){
                    dump("差分あり:" + xpFile.fileName());
                }


                // -1 xpファイルオープン失敗
                // -2 7ファイルオープン失敗
                // -3 xp・7ファイルに書かれている行数が違う
                if(ret != 1){
                    if(ret == -1){
                        dump("xpファイルオープン失敗:"+xpFile.fileName());
                    }
                    else if(ret == -2){
                        dump("7ファイルオープン失敗:"+sevenFile.fileName());
                    }
                    else if(ret == -3){
                        dump("xpファイルと7ファイルの行数が違う:"+xpFile.fileName() +", "+ sevenFile.fileName());
                    }
                }

                xpOnly = false;
                break;
            }
        }
        if(xpOnly)
            xpOnlyList.append(xpFile);
    }

    QFileInfoList sevenOnlyList;
    // 7フォルダ内にしかないファイルも探す
    foreach(QFileInfo sevenFile, sevenFileList){
        bool sevenOnly = true;
        foreach(QFileInfo xpFile, xpFileList){
            if(xpFile.fileName() == sevenFile.fileName()){
                sevenOnly = false;
                break;
            }
        }
        if(sevenOnly)
            sevenOnlyList.append(sevenFile);
    }
Exemplo n.º 6
0
Arquivo: ctf.c Projeto: ErikPshat/cxmb
int makeCxmbThemeFile( unsigned int cxmb_magic, const char * cxmb_theme_file )
{
	const char * folders_name[] = {
		"/data/cert",
		"/dic",
		"/font",
		"/kd",
		"/kd/resource",
		"/vsh/etc",
		"/vsh/module",
		"/vsh/resource"
	};
	int folders_count = 8;
	const char * support_exts[] = {
		".prx",
		".rco",
		".bmp",
		".pmf",
		".res",
		".pgf",
		".bwfon",
		".rsc",
		".dat",
		".img",
		".bin",
		".cet",
		".dic"
	};
	int exts_count = 13;
	int dfd, heap_id, fd, i, bytes, file_count = 0;
	unsigned int ptf_h[5];
	char path[128], file[128], preview[64];
	u8 * buf;
	// dectect if theme file in conf exist
	int ctf = sceIoOpen( cxmb_theme_file, PSP_O_RDONLY, 0644 );
	if ( ctf >= 0 )
	{
		log( "theme file exist!\n" );
		sceIoClose( ctf );
		return 0;
	}

	dfd = sceIoDopen( "ms0:/cxmb" );
	if ( dfd < 0 )
	{
		log( "no cxmb folder found!\n" );
		return 0;
	}
	sceIoDclose( dfd );

	sprintf( preview, "ms0:/cxmb%s", &cxmb_theme_file[14] );
	preview[strlen( preview ) - 3] = 'p';
	log( "preview: %s\n", preview );
	fd = sceIoOpen( preview, PSP_O_RDONLY, 0644 );
	if ( fd < 0 )
	{
		log( "no preview ptf file found!\n" );
		return 0;
	}
	sceIoLseek( fd, 0x100, PSP_SEEK_SET );
	sceIoRead( fd, ptf_h, 20 );

	// create CXMB_MKCTF_BUF_SIZE + 32kb heap
	heap_id = sceKernelCreateHeap( 2, CXMB_MKCTF_BUF_SIZE + 1024 * 32 , 1, "cxmb_tmp_heap");
	if ( heap_id < 0 )
	{
		log( "failed in create heap in making cxmb theme file!\n" );
		return -1;
	}

	CtfHeader * ch = ( CtfHeader * )sceKernelAllocHeapMemory( heap_id, sizeof( CtfHeader ) * 64 );
	memset( ch, 0, sizeof( CtfHeader ) * 64 );
	SceIoDirent * ent = ( SceIoDirent * )sceKernelAllocHeapMemory( heap_id, sizeof( SceIoDirent ) );
	memset( ent, 0, sizeof( SceIoDirent ) );

	sceIoMkdir( "ms0:/PSP/THEME", 0777 );
	ctf = sceIoOpen( cxmb_theme_file, PSP_O_RDWR | PSP_O_CREAT | PSP_O_TRUNC, 0777 );
	if ( ctf < 0 )
	{
		log( "failed in opening %s\n", cxmb_theme_file );
		sceKernelFreeHeapMemory( heap_id, ent );
		sceKernelFreeHeapMemory( heap_id, ch );
		sceKernelDeleteHeap( heap_id );
		return -1;
	}
	else
	{
		if ( ptf_h[2] == 0 )
			ptf_h[2] = sceIoLseek( fd, 0, PSP_SEEK_END );
		log( "ptf sections size %08x\n", ptf_h[2] );
		buf = sceKernelAllocHeapMemory( heap_id, ptf_h[2] );
		if ( buf )
		{
			sceIoLseek( fd, 0, PSP_SEEK_SET );
			sceIoRead( fd, buf, ptf_h[2] );
			sceIoWrite( ctf, buf, ptf_h[2] );
			sceIoClose( fd );
			sceKernelFreeHeapMemory( heap_id, buf );

			sceIoLseek( ctf, 0x10, PSP_SEEK_SET );
			sceIoWrite( ctf, &cxmb_magic, 4 );
			sceIoLseek( ctf, 0x1C, PSP_SEEK_SET );
			sceIoWrite( ctf, &ptf_h[2], 4 );

			memset( &ptf_h[2], 0, 12 );
			sceIoLseek( ctf, 0x100, PSP_SEEK_SET );
			sceIoWrite( ctf, ptf_h, 20 );
			sceIoLseek( ctf, 0, PSP_SEEK_END );

			for ( i = 0; i < folders_count; i ++ )
			{
				sprintf( path, "ms0:/cxmb%s", folders_name[i] );
				dfd = sceIoDopen( path );
				if ( dfd < 0 )
				{
					log( "folder %s not found!\n", path );
					continue;
				}
				log( "parsing %s\n", path );
				while ( sceIoDread( dfd, ent ) > 0 )
				{
					log( "found %s\n", ent->d_name );
					if ( ( ent->d_stat.st_attr & FIO_SO_IFDIR ) || ent->d_name[0] == '.' )
					{
						log( "ignore %s\n", ent->d_name );
						continue;
					}
					if ( endwithistrs( ent->d_name, support_exts, exts_count ) )
					{
						sprintf( file, "%s/%s", path, ent->d_name );
						sprintf( ch[file_count].name, "%s/%s", folders_name[i], ent->d_name );
						ch[file_count].start = sceIoLseek( ctf, 0, PSP_SEEK_CUR );
						ch[file_count].size = 0;
						if ( cmpistrs( ent->d_name, diff_files, diff_count ) )
						{
							char ori_file[128];
							sprintf( ori_file, "%s/%s", CXMB_SUPPORT_FOLDER, ent->d_name );
							ch[file_count].size = makeDiff( file, ori_file, heap_id, ctf );
						}
						else
						{
							log( "dealing with %s\n", ent->d_name );
							fd = sceIoOpen( file, PSP_O_RDONLY, 0644 );
							if ( fd < 0 )
							{
								log( "failed in opening %s\n", file );
								continue;
							}
							buf = ( u8 * )sceKernelAllocHeapMemory( heap_id, CXMB_MKCTF_BUF_SIZE );
							bytes = sceIoRead( fd, buf, CXMB_MKCTF_BUF_SIZE );
							while( bytes > 0 )
							{
								ch[file_count].size += sceIoWrite( ctf, buf, bytes );
								bytes = sceIoRead( fd, buf, CXMB_MKCTF_BUF_SIZE );
							}
							sceKernelFreeHeapMemory( heap_id, buf );
							sceIoClose( fd );
						}
						if ( ch[file_count].size > 0 && ch[file_count].size < CXMB_MAX_FILE_SIZE )
						{
							log( "start: %08x size: %08x\n", ch[file_count].start, ch[file_count].size );
							file_count ++;
						}
					}
					else
					{
						log( "ignore %s\n", ent->d_name );
					}
				}
				sceIoDclose( dfd );
			}
		}
		else
		{
			log( "failed in allocating %08x heap\n", ptf_h[2] );
		}
	}

	log( "file_count: %d\n", file_count );
	if ( file_count > 0 )
	{
		u8 sha1[20];
		sceKernelUtilsSha1Digest( ( u8 * )ch, sizeof( CtfHeader ) * file_count, sha1 );
		sceIoWrite( ctf, ch, sizeof( CtfHeader ) * file_count );
		sceIoLseek( ctf, 0x14, PSP_SEEK_SET );
		sceIoWrite( ctf, &sha1[0], 4 );
		sceIoWrite( ctf, &file_count, 4 );
		sceIoClose( ctf );
	}
	else
	{
		sceIoClose( ctf );
		sceIoRemove( cxmb_theme_file );
	}
	sceKernelFreeHeapMemory( heap_id, ent );
	sceKernelFreeHeapMemory( heap_id, ch );
	sceKernelDeleteHeap( heap_id );
	return 0;
}