コード例 #1
0
ファイル: main.cpp プロジェクト: CCJY/coliru
int main() {
A a;
B b;

doStuff(a);
doStuff(b);
}
コード例 #2
0
ファイル: exceptions.cpp プロジェクト: kunallanjewar/csc240
int main() {
  std::cout << "doStuff(2,3):" << std::endl;
  doStuff(2,3); 
  std::cout << std::endl << "doStuff(2,0):" << std::endl;
  doStuff(2,0); 
  std::cout << std::endl << "doStuff(26,13):" << std::endl;
  doStuff(13,2); 
  return 0;
}
コード例 #3
0
ファイル: hellodali.cpp プロジェクト: AlexLuya/HPCC-Platform
int main(int argc, char* argv[])
{
    
    enableMemLeakChecking(true);

    InitModuleObjects();
    EnableSEHtoExceptionMapping();

    if (argc<2) {
        usage(argv[0]);
        return -1;
    }
    SocketEndpoint dalieps(argv[1],DALI_SERVER_PORT);       // endpoint of dali server
    Owned<IGroup> group = createIGroup(1,&dalieps); 

    try {
        initClientProcess(group, DCR_Other);            // I will add a DCR_Orbit at some point
        try {
            doStuff();
        }
        catch (IException *e) {
            pexception(argv[0],e);
            e->Release();
        }
        closedownClientProcess();
    }
    catch (IException *e) {
        pexception(argv[0],e);
        e->Release();
    }
    releaseAtoms();
    return 0;
}
コード例 #4
0
ファイル: ex1.cpp プロジェクト: ChenmingXu/20133notes
int main()
   {
   doStuff();
   std::cout << g_i;
   
   return 0;
   }
コード例 #5
0
/**
 * Initialize the whole plugins. Gets the monitoredContact, closes the mechanincal
 * @param world_
 * @param space_
 * @param contactJointGroup_
 */
void webots_physics_init(dWorldID world_, dSpaceID space_, dJointGroupID contactJointGroup_) {
#ifdef PHYSICS_DEBUG_OUT
	time_t rawtime;
	struct tm * timeinfo;

	time ( &rawtime );
	timeinfo = localtime ( &rawtime );

	DEBUG_OUT("Start Initialization at "<<asctime (timeinfo))
#endif

		s_data= new amarsi::PhysicsPluginData();
	s_data->world=world_;
	s_data->space=space_;
	s_data->contactJointGroup=contactJointGroup_;

	s_data->setMotionRestrictor(dWebotsGetBodyFromDEF("AMARSI"));

	doStuff("LEFT_FORE",amarsi::LEFT_FORE);
	doStuff("RIGHT_FORE",amarsi::RIGHT_FORE);
	doStuff("LEFT_HIND",amarsi::LEFT_HIND);
	doStuff("RIGHT_HIND",amarsi::RIGHT_HIND);
	s_data->addResettableBody(dWebotsGetBodyFromDEF("AMARSI"));
	s_data->addResettableBody(dWebotsGetBodyFromDEF("MOTORS_GROUP"));
	s_data->addResettableBody(dWebotsGetBodyFromDEF("FR4_BODY_PARTS"));

	s_data->saveState();

	s_data->addDeniedContactBody(getBodyFromDEF("MOTORS_GROUP"));

	s_data->addFloorElement("GROUND");
	s_data->addFloorElement("RAMP");
	s_data->addFloorElement("PODIUM");
	s_data->addFloorElement("SLOPE");
	s_data->addFloorElement("HEIGHTMAP");

	s_data->setMainBody("MOTORS_GROUP");

	initAllAmarsiMessages();
	Message::set_emitter_receiver(EmitterReceiverPhysics::create());
	Message::receive_enable(2);

	DEBUG_OUT("Finish Initialization.")
		//  toe_erp=0.04;
		//  toe_crf=0.001;
		}
コード例 #6
0
ファイル: arbCacheLinear.c プロジェクト: icefoxen/arbitrary
int main(int argc, char** argv) {
   if(argc < 2) {
      usage();
   } else {
      int i = atoi(argv[1]);
      long l = powl((long) 10, i);
      doStuff(l);
   }
   return 0; 
}
コード例 #7
0
// redraw the window
void display(void)
{
    doStuff();
    OSG::PerfMonitor::the()->updateFrame();     // Have to update the stats each "frame"
    
    mgr->redraw();

    // all done, swap
    glutSwapBuffers();
}
コード例 #8
0
ファイル: nano.c プロジェクト: Cybuster/Contest-Archive
int main(void){
	int a, b, c, d;

	scanf("%d %d %d %d", &a, &b, &c, &d);

	doStuff(a,b,c,d,31);

	printf("%d\n", best);

	return 0;
}
コード例 #9
0
ファイル: basic10.c プロジェクト: cherry-wb/TaintTracking
int main() {
    srand(time(NULL));
    int x = rand();
    
    if (x % 2) {
        x = 1;
    }
    
    doStuff(x);

    return 0;
}
コード例 #10
0
ファイル: demo_test6.c プロジェクト: andrnag/mcsema
void doWork(char **f, int l) {
    int a = 0;
    char* b = malloc(l);
    for( ; a < l; a++ ) {
        char *c = f[a];
        if( checkFn(c) == 0 ) {
            doStuff(c, c);
        }
    }
    b[1] = 2;

    return;
}
コード例 #11
0
ファイル: cs_new_dispatch.c プロジェクト: BlakeJarvis/csound
void workerThread (State *s) {
  taskID work;
  watchList *tasksToNotify, next;
  bool canQueue;

  do {

    task = getWork(dispatch);

    /* Do stuff */
    atomicWrite(status[work] = INPROGRESS);
    doStuff(work);
    atomicWrite(status[work] = DONE);    /* NOTE : Race condition */


    tasksToNotify = getWatches(work);

    while (tasksToNotify != NULL) {
      next = tasksToNotify->tail;

      canQueue = TRUE;
      foreach (dep in dep[tasksToNotify->id]) {  /* OPT : Watch ordering */
        if (atomicRead(status[dep]) != DONE) {
          /* NOTE : Race condition */
          if (moveWatch(watch[dep],tasksToNotify)) {
            canQueue = FALSE;
            break;
          } else {
            /* Have hit the race condition, try the next option */
            assert(atomicRead(status[dep]) == DONE);
          }
        }
      }

      if (canQueue) {                    /* OPT : Save one work item */
        addWork(*dispatch,tasksToNotify->id);
        deleteWatch(tasksToNotify);
      }

      tasksToNotify = next;
    }

  } while (1);  /* NOTE : some kind of control for thread exit needed */

  return;
}
コード例 #12
0
ファイル: nano.c プロジェクト: Cybuster/Contest-Archive
int doStuff(int a, int b, int c, int d, int n){
	best = max(best, a <= d && c <= b ? min(b,d) - max(a,c) + 1 : 0);

	if (n > 1){
		if (a == b && a == len(n-1) + 1) return;
		if (c == d && c == len(n-1) + 1) return;

		if (a <= len(n-1) && b > len(n-1)){
			if (len(n-1) - a + 1 > b - len(n-1) - 1){
				b = len(n-1);
			} else {
				a = 1;
				b = (b-1) - len(n-1);
			}
		} else {
			a = a <= len(n-1) ? a : (a-1) - len(n-1);
			a = max(1,a);
			b = b <= len(n-1) ? b : (b-1) - len(n-1);
			b = max(1,b);
		}

		if (c <= len(n-1) && d > len(n-1)){
			if (len(n-1) - c + 1 > d - len(n-1) - 1){
				d = len(n-1);
			} else {
				c = 1;
				d = (d-1) - len(n-1);
			}
		} else {
			c = c <= len(n-1) ? c : (c-1) - len(n-1);
			c = max(1,c);
			d = d <= len(n-1) ? d : (d-1) - len(n-1);
			d = max(1,d);
		}

		doStuff(a,b,c,d,n-1);
	}
}
コード例 #13
0
ファイル: main.cpp プロジェクト: CCJY/coliru
 void a() throw(int)
 {if(!doStuff()) throw 1;}
コード例 #14
0
ファイル: main.cpp プロジェクト: CCJY/coliru
 int a() noexcept
 {return doStuff();}
コード例 #15
0
int main (int argc, char **argv)
{
    key_t key = 1993;
    int shmid, i;
    pid_t pid;
    char *shm;
    double *values;
 
    //Get shared memory segment
    if ((shmid = shmget(key, 1000, IPC_CREAT | 0666)) < 0)
    {
        fprintf(stderr, "Failed to get memory!\n");
        exit(EXIT_FAILURE);
    }

    //Attach shared memory segment
    if ((values = shmat(shmid, NULL, 0)) == (double *) -1) 
    {
        fprintf(stderr, "Failed to attach memory!\n");
        exit(EXIT_FAILURE);
    }
    
    //Clear the shared memory
    for (i = 0; i < 2; i++) values[i] = 0;

    //If file doesnt open
    if (!(fp = fopen(argv[1], "r")))
    {
        fprintf(stderr, "Failed to open file %s\n", argv[1]);
        exit(EXIT_FAILURE);
    }

    //Create 10 children
    for (i = 0; i < 10; i++)
    {
      if ((pid = fork()) == -1)
      {
          fprintf(stderr, "Failed to fork!\n");
          exit(EXIT_FAILURE);
      }
      else if (pid == 0)
          return (doStuff (i,values));
    }

    //Wait till all children finishes
    while (1)
    {
        //Wait for the 'flag' to be set
        if(values[10] == 1)
        {
            double sum = 0;
            //Sum up the "sums" calculated from each of the 10 processes 
            for (i = 0; i < 10; i++)    
                sum += values[i];
            double average = sum/10;
            printf("Average of the file \"%s\" is \"%f\"\n", argv[1], average);
            fclose(fp);
            exit(EXIT_SUCCESS);
        }
    }
}
コード例 #16
0
ファイル: main.cpp プロジェクト: Allulz/AAIAA
void siika_main()
{
	doStuff();

}
コード例 #17
0
// Web server script
// Initiates a server
// Arguments: ./webserver hostname  port directory
// Defaults:              localhost 4000 .
int main(int argc, char* argv[])
{
  fd_set readFds;
  fd_set errFds;
  fd_set watchFds;
  FD_ZERO(&readFds);
  FD_ZERO(&errFds);
  FD_ZERO(&watchFds);

  for (int i = 0; i < 1024; i++){
    timeout[i] = 0;
  }
  struct sockaddr_in serverAddress;
  bzero((char*) &serverAddress, sizeof(serverAddress));
  serverAddress.sin_family = AF_INET;
  serverAddress.sin_addr.s_addr = inet_addr("127.0.0.1");
  serverAddress.sin_port = htons(4000);
  directory = ".";
  if(4 == argc) {
    // store this IP address in sa:
    inet_pton(AF_INET, argv[1], &(serverAddress.sin_addr));
    serverAddress.sin_port = htons(atoi(argv[2]));
    directory = std::string(argv[3]);
  }

  // Create a webserver on hostname:port
  // that serves files from directory
  int listenFd = socket(AF_INET, SOCK_STREAM, 0);
  int maxFd = listenFd;
  if(listenFd < 0)
  {
    std::cerr << "Cannot open socket" << std::endl;
    return -1;
  }
  FD_SET(listenFd, &watchFds);

  int yes = 1;
  if (setsockopt(listenFd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1){
    perror("setsockopt");
    return 1;
  }

  int res = bind(listenFd, (struct sockaddr*)&serverAddress, sizeof(serverAddress));
  if(res < 0) {
    std::cerr << "Cannot bind" << std::endl;
    return -1;    
  }
  if(listen(listenFd, 10) < 0) {
    std::cerr << "Cannot listen" << std::endl;
    return -1;
  }

  struct timeval tv;
  while (true) {
    int nReadyFds = 0;
    readFds = watchFds;
    errFds = watchFds;
    tv.tv_sec = 3;
    tv.tv_usec = 0;
      
      time_t curr;
      time(&curr);
      for (int i = 0; i <= maxFd; i++){
          if (i != listenFd && timeout[i] != 0 && timeout[i] <= curr){
              timeout[i] = 0;
              close(i);
              FD_CLR(i, &watchFds);
          }
      }
    if ((nReadyFds = select(maxFd + 1, &readFds, NULL, &errFds, &tv)) == -1)
    {
      perror ("Cannot select");
      return -1;
    }
    if (nReadyFds != 0){
      for (int fd = 0; fd <= maxFd; fd++){
        if (FD_ISSET(fd, &readFds)){//get one for reading
          if(fd == listenFd) {
            struct sockaddr_in client_addr;
            socklen_t client_addr_size = sizeof(client_addr);
            int clientFd = accept(fd, (struct sockaddr*)&client_addr, &client_addr_size);
            time_t current;
            time(&current);
            timeout[clientFd] = current + 30;
            if (clientFd == -1){
              perror("Cannot accept");
              return -1;
            }
            char ipstr[INET_ADDRSTRLEN] = {'\0'};
            inet_ntop(client_addr.sin_family, &client_addr.sin_addr, ipstr, sizeof(ipstr));
            time(&current);
            
            timeout[clientFd] = current + 30;

            if (maxFd < clientFd){
              maxFd = clientFd;
            }
            FD_SET (clientFd, &watchFds);
          }
          else { //normal socket
              time_t now;
              time(&now);
            timeout[fd] = now + 30;
            doStuff(fd);
            FD_CLR(fd, &watchFds);
          }
        }
      }
    }
    time_t cur;
    time(&cur);
    for (int i = 0; i < maxFd; i++){
      if (i != listenFd && timeout[i] <= cur){
        close(i);
        FD_CLR(i, &watchFds);
      }
    }
  }
  return 0;
}