int main() { int arm = 2; float foot = 1000.0; char lookers = 2; do_stuff(3, 12.0, 4); do_stuff(arm, foot, lookers); return 0; }
int bar (int p, int q) { if (q > 0) do_stuff (q); else do_stuff (-q); if (q % 2) do_stuff2 (2 * q); else do_stuff2 (2 * (q + 1)); return foo (4, p); }
void *thread_fn(void *dummy) { while (1){ do_stuff(); } return(NULL); }
void main() { long int period = 1; char main_stack[16384]; char stack1[16384]; timer.it_value.tv_sec=0; timer.it_value.tv_usec=period; timer.it_interval.tv_sec=0; timer.it_interval.tv_usec=period; //setitimer(ITIMER_PROF,&timer,NULL); printf("timer is %ld\n", period); signal(SIGVTALRM,hello); setitimer(ITIMER_VIRTUAL,&timer,NULL); while (keep_going) do_stuff (); getcontext(&ctxt_t1); ctxt_t1.uc_stack.ss_sp = stack1; ctxt_t1.uc_stack.ss_size = sizeof(stack1); ctxt_t1.uc_link = &ctxt_main; makecontext(&ctxt_t1, func1, 0); printf("In main: entering\n"); swapcontext(&ctxt_main, &ctxt_t1); printf("main: back in main\n"); swapcontext(&ctxt_main, &ctxt_t1); printf("main:exiting main\n"); return; }
void *Thread(void *arg) { int retval, num_tests = 1; int EventSet1=PAPI_NULL; int mask1, papi_event; int num_events1; long long **values; long long elapsed_us, elapsed_cyc; char event_name[PAPI_MAX_STR_LEN]; /* add PAPI_TOT_CYC and one of the events in PAPI_FP_INS, PAPI_FP_OPS or PAPI_TOT_INS, depends on the availability of the event on the platform */ EventSet1 = add_two_nonderived_events(&num_events1, &papi_event, hw_info, &mask1); expected[EventSet1] = *(int *)arg / mythreshold; myid[EventSet1] = PAPI_thread_id(); values = allocate_test_space(num_tests, num_events1); elapsed_us = PAPI_get_real_usec(); elapsed_cyc = PAPI_get_real_cyc(); if ((retval = PAPI_overflow(EventSet1, papi_event, mythreshold, 0, handler)) != PAPI_OK) test_fail(__FILE__, __LINE__, "PAPI_overflow", retval); /* start_timer(1); */ if ((retval = PAPI_start(EventSet1)) != PAPI_OK) test_fail(__FILE__, __LINE__, "PAPI_start", retval); do_stuff(); if ((retval = PAPI_stop(EventSet1, values[0])) != PAPI_OK) test_fail(__FILE__, __LINE__, "PAPI_stop", retval); elapsed_us = PAPI_get_real_usec() - elapsed_us; elapsed_cyc = PAPI_get_real_cyc() - elapsed_cyc; if ((retval = PAPI_overflow(EventSet1, papi_event, 0, 0, NULL)) != PAPI_OK) test_fail(__FILE__, __LINE__, "PAPI_overflow", retval); remove_test_events(&EventSet1, mask1); if ((retval = PAPI_event_code_to_name(papi_event, event_name)) != PAPI_OK) test_fail(__FILE__, __LINE__, "PAPI_event_code_to_name", retval); if (!TESTS_QUIET) { printf("Thread 0x%x %s : \t%lld\n", (int) pthread_self(), event_name, (values[0])[0]); printf("Thread 0x%x PAPI_TOT_CYC: \t%lld\n", (int) pthread_self(), (values[0])[1]); printf("Thread 0x%x Real usec : \t%lld\n", (int) pthread_self(), elapsed_us); printf("Thread 0x%x Real cycles : \t%lld\n", (int) pthread_self(), elapsed_cyc); } free_test_space(values, num_tests); pthread_exit(NULL); return (NULL); }
int top2 (int q) { do_stuff (200); do_other_stuff (); return bah (16, q); }
int main(void) { size_t n; scanf("%zu", &n); int64_t **values = malloc(n * sizeof(int64_t*)); if (!values) { free_and_exit(values, 1); } for (size_t i = 0; i != n; ++i) { int64_t x, y; scanf("%"SCNi64" %"SCNi64, &x, &y); values[i] = malloc(2 * sizeof(int64_t)); if (!values[i]) { for (size_t j = 0; j != i; ++j) { free(values[i]); } free_and_exit(values, 2); } values[i][0] = x; values[i][1] = y; } do_stuff(values, n); for (size_t i = 0; i != n; ++i) { free(values[i]); } free(values); return 0; }
int main(){ canusb_devices::lawicel_canusb adapter; can::bus bus; logging_services::logger log; log.set_prefix("Frame scan", 10); log.set_file_output("find_frames_results.txt"); log.enable_timestamping(); log.enable_prefix(); log.enable_data_destination(logging_services::Data_Destination_Type::Terminal); log.enable_data_destination(logging_services::Data_Destination_Type::File); log.disable_data_destination(logging_services::Data_Destination_Type::Network); if(adapter.auto_setup()){ log.log("Successfully set up adapter."); if(setup_bus(&bus)){ log.log("Successfully set up bus."); while(do_stuff(&bus, &log)){ }/*while*/ }/*if*/ else{ log.log("Failed to set up bus."); }/*else*/ }/*if*/ else{ log.log("Failed to setup adapter."); }/*else*/ }/*main*/
//gcc router.c -o router graph.c socket_open_read_write.c -w message_encode_decode.c -w //./router port_number int main(int argc, char *argv[]){ /*Initializing globals*/ memset(message_history_table,0,TABLE_SIZE); ROUTER_ID=atoi(argv[1]); message_count=0; //Setting up socket int port_number=ROUTER_BASE_PORT+ROUTER_ID; int my_socket=set_up_socket(port_number); char *msg_string; char c; msg *received_message; //listening now listen_again: initialize_graph(); msg_string=read_from_socket(my_socket); received_message=decode_message(msg_string); // free(msg_string); do_stuff(received_message); // printf("Press y to continue listening(you may have to press twice for assurance).n to kill the socket and exit.\n"); // c=getchar(); // c=getchar(); //if(c=='y') goto listen_again; close(my_socket); return 0; }
int main(int argc, char **argv) { d_init_custom("AutoKorg", WINDOW_WIDTH, WINDOW_HEIGHT, 0, "robot", NULL); //Calling an initiating function. Said function creates a window //with resolution 800x600, that's now full-screen and with the title AutoKorg. DARNIT_FONT *kgfont = d_font_load("KGRayofSunshine.ttf", 60, 256, 256); //We create a font handle. DARNIT_TEXT_SURFACE *papper = d_text_surface_new(kgfont, 100 , 800, 10, 0); //Here we create a handle to a text surface, using the font previously handled. /*pthread_t threads[1]; hello = pthread_create(&threads[0], NULL, musikka, (void *) NULL);*/ d_cursor_show(1); //Call a funciton which shows the cursor in the window. initiate_buttons(); initiate_serial_port(); for(;;) { //Program loop. d_render_begin(); //Call to start rendering. d_render_blend_enable(); //Enable blend, a call to a function apparently needed. if(state < DISCO){ d_render_tint(255,255,255,255); } else { d_render_tint(rand() & 0xF0, rand() & 0xF0, rand() & 0xF0, 255); } //Another call to a needed function. Don't question the libdarnit. //d_text_surface_string_append(papper, svar); do_stuff(papper); //Call to a function which does stuff. draw_interface(); //Draws us some graphics. d_render_end(); //Call to a function which you do at the stop of rendering. d_loop(); //Call to a function that is to be called inbetween frames. d_text_surface_reset(papper); //Lastly we clear the textsurface. } return 0; //End of show. }
int main() { for (int i = 0; i < 4; ++i) { do_stuff(); } printf("world!\n"); return 0; }
void *function(void *arg) { unsigned long i; for(i = 0; i < nr_events; i++) { do_stuff(); } return NULL; }
int main(int argc, char *argv[]) { setvbuf(stdout, (char *)NULL, _IONBF, 0); signal(SIGHUP, sighup); int devices = -1; int c; int optidx; struct option options[] = { { "devs", required_argument, 0, 0 } }; for(;;) { c = getopt_long(argc, argv, "", options, &optidx); if (c == -1) break; if (c == 0 && !strcmp(options[optidx].name, "devs")) { devices = atoi(optarg); } else { if (c) fprintf(stderr,"Unknow option -%c\n", c); else fprintf(stderr, "Unknow option %s\n", options[optidx].name); print_usage(argv[0]); return 1; } } char *device; while((device = argv[optind++])) { int ret; ret = fork(); if (ret == 0) return do_stuff(device); else if (ret < 0) perror("fork"); } int status; while(TRUE) wait(&status); return 0; }
//=========================================================================== // Function name: Switch2_Process // // Description: This function handles the detection of SW2 // // Passed : no variables passed // Locals: no variables declared // Returned: no values returned // Globals: none // // Author: Mattia Muller // Date: Sept 2013 // Compiler: Built with IAR Embedded Workbench Version: V4.10A/W32 (5.40.1) //=========================================================================== void Switch2_Process(void){ if (!sw2_position){ sw2_position = RELEASED; okay_to_look_at_switch2 = NOT_OKAY; PJOUT &=~LED3; current_step++; do_stuff(); } }
//=========================================================================== // Function name: Switch1_Process // // Description: This function handles the detection of SW1 // // Passed : no variables passed // Locals: no variables declared // Returned: no values returned // Globals: none // // Author: Mattia Muller // Date: Sept 2013 // Compiler: Built with IAR Embedded Workbench Version: V4.10A/W32 (5.40.1) //=========================================================================== void Switch1_Process(void){ if (!sw1_position){ sw1_position = RELEASED; okay_to_look_at_switch1 = NOT_OKAY; PJOUT &=~LED3; current_step = SET_0; do_stuff(); } }
void par_test(){ clock_t start, end; printf("par test\n"); start = clock(); #pragma omp parallel for schedule(dynamic) for (int i = 0; i < 10000; i++){ do_stuff(); } end = clock(); printf("done in %.4fs\n", ((float)(end-start))/CLOCKS_PER_SEC); }
int main(int argc, char *argv[]) { if (argc < 2) { printf("usage:\n%s -b for blocking\n%s -n for non-blocking\n",argv[0],argv[0]); exit(1); } if (strcmp(argv[1], "-b") == 0) { setup = BLOCKING; } else if (strcmp(argv[1], "-n") == 0) { setup = NON_BLOCKING; } do_stuff(); exit(0); }
int main() { pthread_t thread; int id, arg1, arg2; arg1 = 1; id = pthread_create(&thread, NULL, do_stuff, (void *)&arg1); arg2 = 2; do_stuff((void *)&arg2); return 0; }
int bah (int p, int q) { int i, j; while (q < -20) q += get_stuff (-q); for (i = 0; i < 36; i++) for (j = 0; j < 36; j++) do_stuff (get_stuff (q * i + 2)); bar (p, q); }
int main(int argc, char *argv[]) { MYDATA *my_out; MYDATA *my_err; int n; while ((n = getopt(argc, argv, "nt")) != -1) { switch (n) { case 'n': opt_n = TRUE; break; case 't': opt_t = TRUE; break; default: usage(); /* NOTREACHED */ } } argv += (optind - 1); argc -= (optind - 1); if (argc > 3) usage(); my_out = initialize((argc > 1) ? argv[1] : "vt100", stdout); my_err = initialize((argc > 2) ? argv[2] : "ansi", stderr); do_stuff(my_out); do_stuff(my_err); cleanup(my_out); cleanup(my_err); ExitProgram(EXIT_SUCCESS); }
int redirect_ask(string str) { object ob; string name, tmp1, tmp2; ob = this_player(); name=(string)ob->query("id"); if (!str) return 0; if (sscanf(str,"%s about %s",tmp1, tmp2) == 2) { if (tmp1 == name && tmp2 =="回家") return do_stuff(ob); else return 0; } else return 0; return 0; }
int main (void) { /* Establish a handler for SIGALRM signals. */ signal (SIGALRM, catch_alarm); /* Set an alarm to go off in a little while. */ alarm (2); /* Check the flag once in a while to see when to quit. */ while (keep_going) do_stuff (); return EXIT_SUCCESS; }
namespace array_resize { constexpr int do_stuff(int k1, int k2) { int arr[1234] = { 1, 2, 3, 4 }; arr[k1] = 5; // expected-note {{past-the-end}} expected-note {{cannot refer to element 1235}} expected-note {{cannot refer to element -1}} return arr[k2]; } static_assert(do_stuff(1, 2) == 3, ""); static_assert(do_stuff(0, 0) == 5, ""); static_assert(do_stuff(1233, 1233) == 5, ""); static_assert(do_stuff(1233, 0) == 1, ""); static_assert(do_stuff(1234, 0) == 1, ""); // expected-error {{constant expression}} expected-note {{in call}} static_assert(do_stuff(1235, 0) == 1, ""); // expected-error {{constant expression}} expected-note {{in call}} static_assert(do_stuff(-1, 0) == 1, ""); // expected-error {{constant expression}} expected-note {{in call}} }
int foo(void) /* use ANSI prototypes on every compiler that supports 'em */ { int local1, local2; /* local variable declarations are always followed by a blank line */ do_stuff(); if (bar(local1)) { /* long comments here *//* this lines up with -----------+ */ char *local3; /* autos declared close to use | */ /* | */ do_more_stuff(); /* (everything else indented) | */ local2 = strlen(local3);/* | */ } /* this <------------------------+ */ else local2 = fubar(); /* using tab >= 6, else's line up */ return local2; } /* no question where functions end! */
int main(int argc, char **argv) { int ret; int fd; struct input_event ev; config_init(argc, argv); while (true) { fd = open(config.input_device, O_RDONLY); if (fd == -1) err(EXIT_FAILURE, "%s", config.input_device); while (true) { ret = read(fd, &ev, sizeof ev); switch (ret) { case sizeof ev: do_stuff(&ev); break; case -1: /* Error occured while reading, warn and restart. */ warn("%s", config.input_device); case 0: /* EOF reached, this should not happen. Restart. */ goto cleanup; default: /* * If we did not do a full read, we can't use the contents of the * input_event structure. Just close everything and restart. */ warnx("%s: invalid read of size %d", config.input_device, ret); goto cleanup; } } cleanup: close(fd); } config_cleanup(); return EXIT_SUCCESS; }
int main(int argc, char** argv) { socklen_t acptaddr_len; // -0x48(rbp) int listener; // -0x44(rbp) int sock; // -0x40(rbp) int pid; // -0x3c(rbp) char* errmsg; // -0x38(rbp) struct sockaddr bindaddr; // 0x30(rbp) struct sockaddr acptaddr; // 0x20(rbp) signal(SIGALARM, &sigalarm_handler); puts("[+] Creating Socket"); listener = socket(2, 1, 0); if(!listener) { error("socket error"); } puts("[+] Binding"); bzero(bindaddr, 0x10); ((short*)&bindaddr)[0] = 2; ((short*)&bindaddr)[1] = htons(0x2eec); // 12012, port to listen on ((int*)&bindaddr)[1] = htons(0); if(!bind(listener, &bindaddr, 0x10)) { error("bind error"); } puts("[+] Listening"); if(!listen(listener, 5)) { error("listen error"); } do { puts("[+] accept loop"); acceptaddr_len = 0x10; if(!(sock = accept(listener, &acptaddr, &acptaddr_len))) { errmsg = malloc(0x1e); sprintf(errmsg, "accept errror %d", __errno_location()); error(errmsg); } printf("[+] socket fd: %d.\n", sock); pid = fork(); if(pid) { close(listener); do_stuff(sock); close(sock); exit(0); } close(sock); } while(1); }
int main(int argc, const char * argv[]) { /* Name our little program */ strncpy(program_name, argv[0], short_strlen); /* Prepare ilu functions "database" */ init_strings(); /* initialize DevIL in order to get defined behavior of the app */ ilInit(); iluInit(); /* Prepare command line parsing */ Params * parameters = create_params(); /* Do the parsing */ parse_arguments(argc, argv, parameters); /* Finally do what we wanted */ do_stuff(parameters); /* Clean after the party */ destroy_params(parameters); return 0; }
void do_fft(float *buffer) { fill_fft_buffer_in(buffer); fftw_execute(plan); get_fft_buffer_out(buffer); calc_subbands_energy(buffer); hist_end = (hist_end + 1) % HIST_SIZE; if (hist_size == HIST_SIZE) { do_stuff(); memcpy(Ei[hist_start], Es, BAND_SAMPLES * sizeof(float)); hist_start = (hist_start + 1) % HIST_SIZE; } else { memcpy(Ei[hist_start], Es, BAND_SAMPLES * sizeof(float)); hist_size++; } }
int main(int argc, char *argv[]) { int arg; extern char *optarg; char *target; while(( arg = getopt(argc, argv, "t:")) != -1 ){ switch(arg){ case 't': target = optarg; break; default: usage(); } } printf("Arguments count: %d\n",argc); if(target != NULL) { do_stuff(target); } return 0; }
int f2() { int i, j, ret; int * res; res = malloc(size * sizeof(*res)); ret = do_stuff(); if (ret < 0) { ret = f1(res); if (ret < 0) { log(); } return -EINVAL; } ret = do_final_stuff(); if (ret < 0) { return -EINVAL; } return res; }