Пример #1
0
void produce() 
	{
	Foo * foo = new Foo;
	int I=0;
	int * PI;
	int const * CPI;
	foo->func1(i_);
	foo->func1(ci_);
	foo->func1(ir_);
	foo->func1(icr_);
	foo->func1(I);
	foo->func2(i_);
	foo->func2(ir_);
	foo->func2(I);
	foo->func6(i_);
	foo->func6(ir_);
	foo->func6(I);
	foo->nonConstFunc();
	foo_.nonConstFunc(); //should fail member data (object) call non const functions 
	foo_.constFunc(); //OK because const won't modify self
	method1(i_);
	method1(I);
	modifyStatic(I);
	modifyMember();
	indirectModifyMember();
	recursiveCaller(1);
	PI=foo_.nonConstAccess(); //should fail returns pointer to member data that is non const qualified
	CPI=foo_.constAccess(); // OK because returns pointer to member data that is const qualified
	if (*PI==*CPI) I++;
	}
int main(int argc, char **argv) {
  int arr_sz =10;
  int i;
  if(argc >1 )
		arr_sz = atoi(argv[1]);
  
  printf("clock_gettime() gives us:\n");
  for (i = 0; i < arr_sz; i++) {
    struct timespec ts = method1();
    printf("%ld,", (long) ts.tv_nsec);
  }

  printf("\n");
  
  unsigned long long newtsc =0, old=0;
  printf("\nrdtsc() gives us:\n");
  for (i = 0; i < arr_sz; i++) {
    old = rdtsc();
    newtsc = rdtsc();
    printf("%0.2f,", (newtsc-old)/3.2);
  }
  printf("\n");

  return 0;
}
Пример #3
0
int main()
{
  unsigned int sum = 1;
  int  i = 2;
  int interval = 0;
  int num = 1;

  while(i <= n)
    {
      num += i;
      sum += num;

      interval++;
      if(interval == 4)
	{
	  interval = 0;
	  i += 2;
	}

    }
  
  std::cout << sum << std::endl;
  method1();

  return 0;
}
Пример #4
0
int main() {
    method1();
    method2();
    method3();
    method4();
    method5();

    // On some platforms std::locale::classic() works
    // faster than std::locale()
    boost::iequals(str1, str2, std::locale::classic());
}
Пример #5
0
void test_dispatcher()
{
    RefCountedPtr<SysContext> ctx(new SysContext);
    RefCountedPtr<iSysComponent> cpt( new StdLogger( StdLogger::LOGC_DEBUG) );
    ctx->addComponent( cpt );

    // create the interfaces
    RefCountedPtr<RpcInterface> intf( new RpcInterface( NTEXT("interface"), ctx ));
    RefCountedPtr<RpcInterface> intf1( new RpcInterface( NTEXT("interface"), ctx ));
    RefCountedPtr<RpcInterface> intf2( new RpcInterface( NTEXT("interface"), ctx ));
 
    // create the methods
    RefCountedPtr<Object1Method1> method( 
        new Object1Method1(NTEXT("method"), NTEXT("default")) );
    intf->addMethod( (RefCountedPtr<iRpcMethod>&)method );

    RefCountedPtr<Object1Method1> method1( 
        new Object1Method1(NTEXT("method"), NTEXT("apache")) );
    intf1->addMethod( (RefCountedPtr<iRpcMethod>&)method1 );

    RefCountedPtr<Object1Method1> method2( 
        new Object1Method1(NTEXT("method"), NTEXT("cslib")) );
    intf2->addMethod( (RefCountedPtr<iRpcMethod>&)method2 );

    RpcDispatcher disp( NTEXT("test-dispatcher"), ctx );
    disp.addInterface( intf );
    disp.addInterface( intf1, APACHE_TENANT );
    disp.addInterface( intf2, CSLIB_TENANT );

    DOMDocument* requestDoc = DomUtils::getDocument( NTEXT("rpc_dispatcher.xml") );
    if (requestDoc != NULL)
    {
        StreamFormatTarget targ(COUT);

        DOMDocument* responseDoc = DomUtils::createDocument( NTEXT("default") );
	if (responseDoc != NULL)
	{
	    disp.dispatch( requestDoc, responseDoc );
	    disp.dispatch( requestDoc, responseDoc, APACHE_TENANT );
	    disp.dispatch( requestDoc, responseDoc, CSLIB_TENANT );
	    disp.dispatch( requestDoc, responseDoc, INVALID_TENANT );
	  
	    DomUtils::print( responseDoc, NTEXT("UTF-8"), targ );

	    responseDoc->release();
	}

	requestDoc->release();
    }
}
void FakeClassForNode::activeFunction(int id)
{
  switch(id)
  {
    case 0:
      method1();
      break;
    case 1:
      method2(0);
      break;
    case 2:
      method3(0,0);
      break;
  }
}
Пример #7
0
int main(int argc, char **argv)
{
    QCoreApplication app(argc, argv);

    if (!QDBusConnection::sessionBus().isConnected()) {
        fprintf(stderr, "Cannot connect to the D-Bus session bus.\n"
                "To start it, run:\n"
                "\teval `dbus-launch --auto-syntax`\n");
        return 1;
    }

    method1();
    method2();
    method3();

    return 0;
}
// defining and selecting our external user client methods
IOReturn SamplePCIUserClientClassName::externalMethod(
    uint32_t selector, IOExternalMethodArguments* arguments,
    IOExternalMethodDispatch * dispatch, OSObject * target, void * reference )
{
    IOReturn	result;

    if (fDriver == NULL || isInactive()) {
        // Return an error if we don't have a provider. This could happen if the user process
        // called either method without calling IOServiceOpen first. Or, the user client could be
        // in the process of being terminated and is thus inactive.
        result = kIOReturnNotAttached;
    }
    else if (!fDriver->isOpen(this)) {
        // Return an error if we do not have the driver open. This could happen if the user process
        // did not call openUserClient before calling this function.
        result = kIOReturnNotOpen;
    }

    IOReturn err;
    IOLog("The Leopard and later way to route external methods\n");
    switch (selector)
    {
    case kSampleMethod1:
        err = method1( (UInt32 *) arguments->structureInput,
                       (UInt32 *)  arguments->structureOutput,
                       arguments->structureInputSize, (IOByteCount *) &arguments->structureOutputSize );
        break;

    case kSampleMethod2:
        err = method2( (SampleStructForMethod2 *) arguments->structureInput,
                       (SampleResultsForMethod2 *)  arguments->structureOutput,
                       arguments->structureInputSize, (IOByteCount *) &arguments->structureOutputSize );
        break;

    default:
        err = kIOReturnBadArgument;
        break;
    }

    IOLog("externalMethod(%d) 0x%x", selector, err);

    return (err);
}
Пример #9
0
int main(void){
	static int val1=1;
	int i=0;


	for(i=0;i<5;i++){
	 method0();
	 method1();
	}

	printf("main:val2=%d\n", val2);
	/*
	a=1 always
	b=1,2,3,4,5
	 */
	method2();
	//method3(); method3 is defined as static in method1.c
	return 1;
}
void eval(void) 
{ int tmp ;
  int tmp___0 ;

  {
  {
  while (1) {
    while_0_continue: /* CIL Label */ ;
    {
    tmp___0 = exists_runnable_thread();
    }
    if (tmp___0) {

    } else {
      goto while_0_break;
    }
    if ((int )comp_m1_st == 0) {
      {
	tmp = __VERIFIER_nondet_int(); 
      }
      if (tmp) {
        {
        comp_m1_st = 1;
        method1();
        }
      } else {

      }
    } else {

    }
  }
  while_0_break: /* CIL Label */ ;
  }

  return;
}
}
Пример #11
0
// --------------------------------------------------------------
void RLE::multiPassCompress( std::string& str )
{

    // the same compression algorithm is performed twice,
    // one time factoring from the outside in and the other
    // time factoring from the inside out. The two are compared
    // and the best result is returned.
    std::string cp;
    std::string method1( str );
    std::string method2;

    // the compare size is the number of characters to compare with the
    // rest of the string to find matching patterns
    // NOTE: A "ping-pong" pattern has been implemented to avoid
    // useless copying of string objects between each other
    for( size_t compareSize = 1; compareSize < str.size()/2; ++compareSize )
    {
        cp.clear();
        this->multPassCompress_pass( compareSize, method1, cp ); ++compareSize;
        method1.clear();
        this->multPassCompress_pass( compareSize, cp, method1 );
    }
    for( size_t compareSize = str.size()/2; compareSize > 0; --compareSize )
    {
        method2.clear();
        this->multPassCompress_pass( compareSize, str, method2 );
        if(!(--compareSize))
        {
            str = method2;
            break;
        }
        str.clear();
        this->multPassCompress_pass( compareSize, method2, str );
    }

    // compare length to determine which one was more successful
    if( method1.size() < str.size() ) str = method1;
}
Пример #12
0
int main(int argc, char *argv[])
{
    //QCoreApplication a(argc, argv);

    srand(time(NULL));

    long M=511; //number of channels
    long T=20; //convolution kernel size
    long N=5e9/(M*T); //number of timepoints

    double *Xin=(double *)malloc(sizeof(double)*M*N);
    double *Xout=(double *)malloc(sizeof(double)*M*N);
    double *Kern=(double *)malloc(sizeof(double)*T);

    printf("Note: Each operation consists of a multiply and an add.\n\n");

    printf("Preparing...\n");
    for (int ii=0; ii<M*N; ii++) {
        Xin[ii]=ii%183;
    }
    for (int t=0; t<T; t++) {
        Kern[t]=rand()*1.0/rand();
    }

    if (1) {
        printf("\nMethod 1 (simple loops)...\n");
        QTime timer; timer.start();
        method1(M,N,T,Xin,Xout,Kern);
        double elapsed=timer.elapsed()*1.0/1000;
        printf("%g,%g,%g\n",Xout[1],Xout[1000],Xout[100000]);
        double mops=M*N*T/elapsed/1e6;
        printf("Method 1: Elapsed time: %.5f sec\n",elapsed);
        printf("   *** %g million operations per second ***\n\n",mops);
    }

    if (1) {
        printf("\nMethod 2 (simple loops - method 2)...\n");
        QTime timer; timer.start();
        method2(M,N,T,Xin,Xout,Kern);
        double elapsed=timer.elapsed()*1.0/1000;
        printf("%g,%g,%g\n",Xout[1],Xout[1000],Xout[100000]);
        double mops=M*N*T/elapsed/1e6;
        printf("Method 2: Elapsed time: %.5f sec\n",elapsed);
        printf("   *** %g million operations per second ***\n\n",mops);
    }

    if (1) {
        printf("\nMethod 3 (cblas level 1)...\n");
        QTime timer; timer.start();
        method3(M,N,T,Xin,Xout,Kern);
        double elapsed=timer.elapsed()*1.0/1000;
        printf("%g,%g,%g\n",Xout[1],Xout[1000],Xout[100000]);
        double mops=M*N*T/elapsed/1e6;
        printf("Method 3: Elapsed time: %.5f sec\n",elapsed);
        printf("   *** %g million operations per second ***\n\n",mops);
    }

    if (1) {
        printf("\nMethod 4 (cblas level 2)...\n");
        QTime timer; timer.start();
        method4(M,N,T,Xin,Xout,Kern);
        double elapsed=timer.elapsed()*1.0/1000;
        printf("%g,%g,%g\n",Xout[1],Xout[1000],Xout[100000]);
        double mops=M*N*T/elapsed/1e6;
        printf("Method 4: Elapsed time: %.5f sec\n",elapsed);
        printf("   *** %g million operations per second ***\n\n",mops);
    }

    if (1) {
        printf("\nMethod 5 (cblas level 2, multiple threads)...\n");
        QTime timer; timer.start();
        method5(M,N,T,Xin,Xout,Kern);
        double elapsed=timer.elapsed()*1.0/1000;
        printf("%g,%g,%g\n",Xout[1],Xout[1000],Xout[100000]);
        double mops=M*N*T/elapsed/1e6;
        printf("Method 5: Elapsed time: %.5f sec\n",elapsed);
        printf("   *** %g million operations per second ***\n\n",mops);
    }

    free(Xin);
    free(Xout);
    free(Kern);


    return 0;
}
Пример #13
0
int main(int argc, char const *argv[]) {
  method1();	
  method2();
  return 0;
}
Пример #14
0
void SVT_ThreadMother::run()
{
    int counter=0;
    while(!mCore->mCoreExit)
    {
        counter++;
        SLEEP(200);
//        continue;
        SVT_NodePoolRef lazyDelete;
        mMutex.lock();
        SVT_NodePoolRef waitpool=mNodePoolWaited;
        mNodePoolWaited=NULL;
        mMutex.unlock();

        if(!waitpool.isNull() && mNodePool!=waitpool)
        {
//            wantStart=true;

            if(!mNodePool.isNull())
            {
                mNodePool->mPoolExit=true;
                mNodePool->stop();
            }
            waitpool->mPoolExit=true;
            waitpool->stop();
            mThreadPool.waitForDone();
            lazyDelete=mNodePool;
            mNodePool=waitpool;
            CORE_LOCK();
#if USE_NETBIOS_METHOD
            if(sMapFlags &MF_USE_NETBIOS_SCAN)
            {
                SVT_TopoMethodRef method1(new SVT_NetbiosMethod(mNodePool.asPointer()));
                mNodePool->addMethod(method1);
            }
#endif
            if(sMapFlags & MF_USE_ARP_SCAN)
            {
                SVT_TopoMethodRef method2(new SVT_NetscanMethod(mNodePool.asPointer()));
                mNodePool->addMethod(method2);
            }
#if USE_UPNP_METHOD
            if(sMapFlags & MF_USE_UPNP_SCAN)
            {
                SVT_TopoMethodRef method3(new SVT_UpnpMethod(mNodePool.asPointer()));
                mNodePool->addMethod(method3);
            }
#endif
#if USE_NETGEARSPECIFIC_METHOD
            if(sMapFlags & MF_USE_NETGEARSPECIFIC_SCAN)
            {
                SVT_TopoMethodRef method4(new SVT_NetgearSpecificMethod(mNodePool.asPointer()));
                mNodePool->addMethod(method4);
            }
#endif
#if USE_AFP_METHOD
            if(sMapFlags & MF_USE_AFP_SCAN)
            {
                SVT_TopoMethodRef method5(new SVT_AfpMethod(mNodePool.asPointer()));
                mNodePool->addMethod(method5);
            }
#endif
#ifdef USE_RDP
            if(sMapFlags & MF_USE_RDP_SCAN)
            {
                SVT_TopoMethodRef method6(new SVT_RdpMethod(mNodePool.asPointer()));
                mNodePool->addMethod(method6);
            }
#endif
#ifdef USE_PUTTY
            if(sMapFlags & MF_USE_PUTTY_SCAN)
            {
                SVT_TopoMethodRef method7(new SVT_PuttyMethod(mNodePool.asPointer()));
                mNodePool->addMethod(method7);
            }
#endif


            mNodePool->start();
            CORE_UNLOCK();
        }
        lazyDelete=NULL;

    }

    mMutex.lock();
    if(!mNodePool.isNull())
    {
        mNodePool->mPoolExit=true;
    }
    if(!mNodePoolWaited.isNull())
    {
        mNodePoolWaited->mPoolExit=true;
    }
    mMutex.unlock();
    mThreadPool.waitForDone();

}