int main() { noop(); goto jump_to_me; // CHECK-NOTES: [[@LINE-1]]:3: warning: avoid using 'goto' for flow control // CHECK-NOTES: [[@LINE+3]]:1: note: label defined here noop(); jump_to_me:; jump_backwards:; noop(); goto jump_backwards; // CHECK-NOTES: [[@LINE-1]]:3: warning: avoid using 'goto' for flow control // CHECK-NOTES: [[@LINE-4]]:1: note: label defined here goto jump_in_line; ; jump_in_line:; // CHECK-NOTES: [[@LINE-3]]:3: warning: avoid using 'goto' for flow control // CHECK-NOTES: [[@LINE-2]]:1: note: label defined here // Test the GNU extension https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html some_label:; void *dynamic_label = &&some_label; // FIXME: `IndirectGotoStmt` is not detected. goto *dynamic_label; }
double time_find_all(const std::string& re, const std::string& text, bool icase) { try{ boost::xpressive::regex_constants::syntax_option_type flags = boost::xpressive::regex_constants::optimize; if(icase) flags = flags | boost::xpressive::regex_constants::icase; boost::xpressive::sregex e(boost::xpressive::sregex::compile(re, flags)); boost::xpressive::smatch what; boost::timer tim; int iter = 1; int counter, repeats; double result = 0; double run; do { tim.restart(); for(counter = 0; counter < iter; ++counter) { boost::xpressive::sregex_iterator begin( text.begin(), text.end(), e ), end; std::for_each( begin, end, noop() ); } result = tim.elapsed(); iter *= 2; }while(result < 0.5); iter /= 2; if(result >10) return result / iter; // repeat test and report least value for consistency: for(repeats = 0; repeats < REPEAT_COUNT; ++repeats) { tim.restart(); for(counter = 0; counter < iter; ++counter) { boost::xpressive::sregex_iterator begin( text.begin(), text.end(), e ), end; std::for_each( begin, end, noop() ); } run = tim.elapsed(); result = (std::min)(run, result); } return result / iter; } catch(const std::exception& e) { std::cout << "Exception: " << e.what() << std::endl; return -1; } }
double time_find_all(const std::string& re, const std::string& text, bool icase) { try{ std::regex e(re, (icase ? std::regex::ECMAScript | std::regex::icase : std::regex::ECMAScript)); std::smatch what; boost::timer tim; int iter = 1; int counter, repeats; double result = 0; double run; do { tim.restart(); for(counter = 0; counter < iter; ++counter) { std::sregex_iterator begin( text.begin(), text.end(), e ), end; std::for_each( begin, end, noop() ); //std::regex_grep(&dummy_grep_proc, text, e); } result = tim.elapsed(); iter *= 2; }while(result < 0.5); iter /= 2; if(result >10) return result / iter; // repeat test and report least value for consistency: for(repeats = 0; repeats < REPEAT_COUNT; ++repeats) { tim.restart(); for(counter = 0; counter < iter; ++counter) { std::sregex_iterator begin( text.begin(), text.end(), e ), end; std::for_each( begin, end, noop() ); //std::regex_grep(&dummy_grep_proc, text, e); } run = tim.elapsed(); result = (std::min)(run, result); } return result / iter; } catch(const std::exception& e) { std::cout << "Exception: " << e.what() << std::endl; return -1; } }
/** * @brief Sends a signal to a process. * * @param proc Process to send the signal. * @param sig Signal to be sent. */ PUBLIC void sndsig(struct process *proc, int sig) { /* * SIGCHLD and SIGCONT are somewhat special. The receiving * process is resumed even if these signals are being ignored, * otherwise caos might follow. */ if ((sig != SIGCHLD) && (sig != SIGCONT)) { if (IGNORING(proc, sig)) return; } /* Set signal flag. */ proc->received |= (1 << sig); /* Wake up process. */ if (proc->state == PROC_WAITING) { if (proc == *proc->chain) *proc->chain = proc->next; else { struct process *p; for (p = *proc->chain; p->next != proc; p = p->next) noop() ; p->next = proc->next; } sched(proc); } }
void scheduler() { // Init no longer has children. Needs to close. if (jrb_empty(init->children)) { SYSHalt(); } if(dll_empty(readyQ)) { noop_flag = 1; noop(); } else { PCB *process; Dllist node; Jval registers; noop_flag = 0; process = (PCB *) malloc(sizeof(PCB)); node = dll_first(readyQ); // Get next node in queue dll_delete_node(node); // Node in memory. Delete off readyQ // Get registers from node registers = dll_val(node); process = (PCB *)jval_v(registers); // Update current process currentProcess = process; User_Base = process->base; User_Limit = process->limit; run_user_code(process->registers); } }
int main (void) { pid_t pid; int status; printf ("Before vfork\n"); fflush (stdout); pid = vfork (); if (pid == 0) { /* This will clobber the return pc from vfork in the parent on machines where it is stored on the stack, if vfork wasn't implemented correctly, */ noop (); _exit (NR); } else if (pid < 0) error (1, errno, "vfork"); printf ("After vfork (parent)\n"); if (waitpid (0, &status, 0) != pid || !WIFEXITED (status) || WEXITSTATUS (status) != NR) exit (1); return 0; }
void VJoystickMainWindow::setJoystickInfo() { if(m_adapter->isConnected()) { m_ui->labelName->setText(m_adapter->getJoystickName()); m_ui->labelNumButtons->setText(QString("%1").arg(m_adapter->getJoystickNumButtons())); m_ui->labelNumAxes->setText(QString("%1").arg(m_adapter->getJoystickNumAxes())); m_ui->labelNumHats->setText(QString("%1").arg(m_adapter->getJoystickNumHats())); m_ui->labelNumBalls->setText(QString("%1").arg(m_adapter->getJoystickNumBalls())); QString noop("0"); m_ui->labelXAxis->setText(noop); m_ui->labelYAxis->setText(noop); m_ui->labelXRotate->setText(noop); m_ui->labelYRotate->setText(noop); m_ui->labelZAxis->setText(noop); m_ui->labelHat1->setText(noop); m_ui->labelHat2->setText(noop); m_ui->labelBall1X->setText(noop); m_ui->labelBall1Y->setText(noop); m_ui->labelBall2X->setText(noop); m_ui->labelBall2Y->setText(noop); m_ui->labelButton->setText(""); } }
void scheduler() { //readyq = new_dllist(); if(dll_empty(readyq)) { //printf("empty ready q\n"); current = NULL; noop(); } //takes the first PCB off the readyq and calls run_user_code() on its registers else { // pop off and delete from readyq printf("non-empty q\n"); current = (PCB *) jval_v(dll_val(dll_first(readyq))); printf("non-empty q\n"); dll_delete_node(dll_first(readyq)); printf("non-empty q\n"); run_user_code(current->registers); } }
int main () { int i; for (i = 0; i < 10; i++) /* count(11) */ noop (); /* count(10) */ return 0; /* count(1) */ }
double time_find_all(const std::string& re, const std::string& text) { boost::regex e(re, boost::regex_constants::ECMAScript | boost::regex_constants::optimize); boost::smatch what; boost::timer tim; int iter = 1; int counter, repeats; double result = 0; double run; do { tim.restart(); for(counter = 0; counter < iter; ++counter) { boost::sregex_iterator begin( text.begin(), text.end(), e ), end; std::for_each( begin, end, noop() ); //boost::regex_grep(&dummy_grep_proc, text, e); } result = tim.elapsed(); iter *= 2; }while(result < 0.5); iter /= 2; if(result >10) return result / iter; // repeat test and report least value for consistency: for(repeats = 0; repeats < REPEAT_COUNT; ++repeats) { tim.restart(); for(counter = 0; counter < iter; ++counter) { boost::sregex_iterator begin( text.begin(), text.end(), e ), end; std::for_each( begin, end, noop() ); //boost::regex_grep(&dummy_grep_proc, text, e); } run = tim.elapsed(); result = (std::min)(run, result); } return result / iter; }
void BackendSync::Client::noop() { uint64_t seq; if(this->status == Client::COPY && this->last_key.empty()) { seq = 0; } else { seq = this->last_seq; this->last_noop_seq = this->last_seq; } Binlog noop(seq, BinlogType::NOOP, BinlogCommand::NONE, ""); //log_debug("fd: %d, %s", link->fd(), noop.dumps().c_str()); link->send(noop.repr()); }
void perform_action(gamestate_t *gs, int action) { switch(action) { case 0: noop(gs); qbLog("Noop"); break; case 1: turn_left(gs); qbLog("turn left"); break; case 2: turn_right(gs); qbLog("turn right"); break; case 3: move_forward(gs); qbLog("move forward"); break; case 4: move_backward(gs); qbLog("move backward"); break; case 5: jump(gs); qbLog("jump"); break; case 6: shoot(gs); qbLog("shoot"); break; } }
void jump_out_backwards() { before_the_loop: noop(); for (int i = 0; i < 10; ++i) { for (int j = 0; j < 10; ++j) { if (i * j > 80) goto before_the_loop; // CHECK-NOTES: [[@LINE-1]]:9: warning: avoid using 'goto' for flow control // CHECK-NOTES: [[@LINE-8]]:1: note: label defined here } } }
static void buggy_func(void) { struct node * s1; while (global.head != 0 && global.tokens > 0) { if (global.head->type != 2) { printf( "BUG: 2 = %d!!!\n", global.head->type); printf( "OK: 2 = %d\n", global.head->type); abort(); } s1 = global.head; switch(s1->type) { default: printf("oops, shoudl not be there\n"); exit(1); break; case 2: global.head = s1->next; s1->type = 3; noop(s1); if (global.head == 0) noop(); break; } } }
void object::test<5>() { set_test_name("checks throw std::exception"); try { ensure_THROW( noop(), std::exception ); fail("throw doesn't work"); } catch (const failure& ex) { if (std::string(ex.what()).find("noop()") == std::string::npos ) { fail("throw doesn't contain proper message"); } } }
/** * @brief Sends a signal to a process. * * @param proc Process to send the signal. * @param sig Signal to be sent. */ PUBLIC void sndsig(struct process *proc, int sig) { /* Ignore this. */ if (IGNORING(proc, sig) && (sig != SIGCHLD)) return; /* Set signal flag. */ proc->received |= (1 << sig); /* * SIGCONT is somewhat special. The receiving process * is resumed even if SIGCONT is being ignored, * otherwise it could stop forever. */ if (sig == SIGCONT) { resume(proc); /* * The process is not catching SIGCONT and the * default action for this signal has just been * taken. */ if (!CATCHING(proc, sig)) { proc->received &= ~(1 << sig); return; } } /* Wake up process. */ if (proc->state == PROC_WAITING) { if (proc == *proc->chain) *proc->chain = proc->next; else { struct process *p; for (p = *proc->chain; p->next != proc; p = p->next) noop() ; p->next = proc->next; } sched(proc); } }
int main(int argc, char *argv[]) { int lines = 10; int columns = 20; char** m; struct map v1; MAP v2; v1.lines = lines; v1.columns = columns; v1.array = m; noop(&v1); memset(&v2, 0, sizeof(MAP)); memcpy(&v2, &v1, sizeof(MAP)); printf("OK"); return 0; }
void VJoystickMainWindow::clearJoystickInfo() { QString noop(" "); m_ui->labelName->setText(noop); m_ui->labelNumButtons->setText(noop); m_ui->labelNumAxes->setText(noop); m_ui->labelNumHats->setText(noop); m_ui->labelNumBalls->setText(noop); m_ui->labelXAxis->setText(noop); m_ui->labelYAxis->setText(noop); m_ui->labelXRotate->setText(noop); m_ui->labelYRotate->setText(noop); m_ui->labelZAxis->setText(noop); m_ui->labelHat1->setText(noop); m_ui->labelHat2->setText(noop); m_ui->labelBall1X->setText(noop); m_ui->labelBall1Y->setText(noop); m_ui->labelBall2X->setText(noop); m_ui->labelBall2Y->setText(noop); m_ui->labelButton->setText(noop); }
__device__ basic_concurrent_agent(Function f, const typename super_t::index_type& index, const typename super_t::param_type& param) : super_t(noop(), index, param) { f(*this); }
inline void setArrayOne(elem *array) { noop(array); setArray(array); noop(array); setArray(array); }
void delay(int cycles) { for(int i=0; i<cycles; ++i) { noop(); } }
void BackendSync::Client::out_of_sync(){ this->status = Client::OUT_OF_SYNC; Binlog noop(this->last_seq, BinlogType::CTRL, BinlogCommand::NONE, "OUT_OF_SYNC"); link->send(noop.repr()); }
void forward_jump_out_nested_loop() { int array[] = {1, 2, 3, 4, 5}; for (int i = 0; i < 10; ++i) { noop(); for (int j = 0; j < 10; ++j) { noop(); if (i + j > 10) goto early_exit1; } noop(); } for (int i = 0; i < 10; ++i) { noop(); while (true) { noop(); if (i > 5) goto early_exit1; } noop(); } for (auto value : array) { noop(); for (auto number : array) { noop(); if (number == 5) goto early_exit1; } } do { noop(); do { noop(); goto early_exit1; } while (true); } while (true); do { for (auto number : array) { noop(); if (number == 2) goto early_exit1; } } while (true); // Jumping further results in error, because the variable declaration would // be skipped. early_exit1:; int i = 0; while (true) { noop(); while (true) { noop(); if (i > 5) goto early_exit2; i++; } noop(); } while (true) { noop(); for (int j = 0; j < 10; ++j) { noop(); if (j > 5) goto early_exit2; } noop(); } while (true) { noop(); for (auto number : array) { if (number == 1) goto early_exit2; noop(); } } while (true) { noop(); do { noop(); goto early_exit2; } while (true); } early_exit2:; }
/* Loop <delay> times in a way that the compiler won't optimize away. */ static inline void delay(unsigned int count) { for(int ra=0;ra<count;ra++) noop(ra); }
void BackendSync::Client::noop(){ this->last_noop_seq = this->last_seq; Binlog noop(this->last_seq, BinlogType::NOOP, BinlogCommand::NONE, ""); //log_trace("fd: %d, %s", link->fd(), log.dumps().c_str()); link->send(noop.repr()); }
/** * @brief Default hardware interrupt handler. */ PRIVATE void default_hwint(void) { noop(); }
static void cilk_for_root(F body, void *data, count_t count, int grain) { // Cilkscreen should not report this call in a stack trace NOTIFY_ZC_INTRINSIC((char *)"cilkscreen_hide_call", 0); // Pedigree computation: // // If the last pedigree node on entry to the _Cilk_for has value X, // then at the start of each iteration of the loop body, the value of // the last pedigree node should be 0, the value of the second-to-last // node should equal the loop counter, and the value of the // third-to-last node should be X. On return from the _Cilk_for, the // value of the last pedigree should be incremented to X+2. The // pedigree within the loop is thus flattened, such that the depth of // recursion does not affect the results either inside or outside of // the loop. Note that the pedigree after the loop exists is the same // as if a single spawn and sync were executed within this function. // TBD: Since the shrink-wrap optimization was turned on in the compiler, // it is not possible to get the current stack frame without actually // forcing a call to bind-thread. This spurious spawn is a temporary // stopgap until the correct intrinsics are added to give us total control // over frame initialization. _Cilk_spawn noop(); // Fetch the current worker. From that we can get the current stack frame // which will be constant even if we're stolen __cilkrts_worker *w = __cilkrts_get_tls_worker(); __cilkrts_stack_frame *sf = w->current_stack_frame; // Decrement the rank by one to undo the pedigree change from the // _Cilk_spawn --w->pedigree.rank; // Save the current worker pedigree into loop_root_pedigree, which will be // the root node for our flattened pedigree. __cilkrts_pedigree loop_root_pedigree = w->pedigree; // Don't splice the loop_root node in yet. It will be done when we // call the loop body lambda function // w->pedigree.rank = 0; // w->pedigree.next = &loop_root_pedigree; /* Spawn is necessary at top-level to force runtime to start up. * Runtime must be started in order to call the grainsize() function. */ int gs = grainsize(grain, count); cilk_for_recursive((count_t) 0, count, body, data, gs, w, &loop_root_pedigree); // Need to refetch the worker after calling a spawning function. w = sf->worker; // Restore the pedigree in the worker. w->pedigree = loop_root_pedigree; // Bump the worker pedigree. ++w->pedigree.rank; // Implicit sync will increment the pedigree leaf rank again, for a total // of two increments. If the noop spawn above is removed, then we'll need // to re-enable the following code: // // If this is an optimized build, then the compiler will have optimized // // out the increment of the worker's pedigree in the implied sync. We // // need to add one to make the pedigree_loop test work correctly. // #if CILKRTS_OPTIMIZED // ++sf->worker->pedigree.rank; // #endif }
void for_each_type(type_list<Ts...>, F&& f) { noop((f(type<Ts>()), 0)...); }
int x() { return (noop(noop(noop(noop(noop(noop(noop(noop(noop(f)))))))))()); }
std::uint16_t VirtualCPU::executeInstructionAtAddress(std::uint16_t address) { debugger_.pc_ = address; //HACK FOR NOW switch (memoryController_.readAtAddress(address)) { case 0: return address + halt(); case 1: return address + set(memoryController_.readAtAddress(address + 1), memoryController_.readAtAddress(address + 2)); case 2: return address + push(memoryController_.readAtAddress(address + 1)); case 3: return address + pop(memoryController_.readAtAddress(address + 1)); case 4: return address + eq(memoryController_.readAtAddress(address + 1), memoryController_.readAtAddress(address + 2), memoryController_.readAtAddress(address + 3)); case 5: return address + gt(memoryController_.readAtAddress(address + 1), memoryController_.readAtAddress(address +2), memoryController_.readAtAddress(address + 3)); case 6: return jump(memoryController_.readAtAddress(address + 1), address); case 7: return jt(memoryController_.readAtAddress(address + 1), memoryController_.readAtAddress(address + 2), address); case 8: return jf(memoryController_.readAtAddress(address + 1), memoryController_.readAtAddress(address + 2), address); case 9: return address + add(memoryController_.readAtAddress(address + 1), memoryController_.readAtAddress(address + 2), memoryController_.readAtAddress(address + 3)); case 10: return address + mult(memoryController_.readAtAddress(address + 1), memoryController_.readAtAddress(address + 2), memoryController_.readAtAddress(address + 3)); case 11: return address + mod(memoryController_.readAtAddress(address + 1), memoryController_.readAtAddress(address + 2), memoryController_.readAtAddress(address + 3)); case 12: return address + and_i(memoryController_.readAtAddress(address + 1), memoryController_.readAtAddress(address + 2), memoryController_.readAtAddress(address + 3)); case 13: return address + or_i(memoryController_.readAtAddress(address + 1), memoryController_.readAtAddress(address + 2), memoryController_.readAtAddress(address + 3)); case 14: return address + not_i(memoryController_.readAtAddress(address + 1), memoryController_.readAtAddress(address + 2)); case 15: return address + rmem(memoryController_.readAtAddress(address + 1), memoryController_.readAtAddress(address + 2)); case 16: return address + wmem(memoryController_.readAtAddress(address + 1), memoryController_.readAtAddress(address + 2)); case 17: return call(memoryController_.readAtAddress(address + 1), address); case 18: return ret(); case 19: return address + out(memoryController_.readAtAddress(address + 1)); case 21: return address + noop(); case 20: return address + in(memoryController_.readAtAddress(address + 1)); default: std::cout << "CPU ERROR illegal op code: " << memoryController_.readAtAddress(address) << std::endl; return address + 1; } }