diff --git a/j/b/scag.c b/j/b/scag.c index 15e5dc6df..5aef703c2 100644 --- a/j/b/scag.c +++ b/j/b/scag.c @@ -15,7 +15,7 @@ return u3m_bail(c3__fail); } else { - u3_noun acc = u3_blip; + u3_noun acc = u3_nul; c3_w i_w = a; if ( !i_w ) @@ -23,9 +23,9 @@ while ( i_w ) { if ( c3n == u3du(b) ) { - return u3_nul; + return u3kb_flop(acc); } - acc = u3i_cell( u3h(b), acc ); + acc = u3nc(u3k(u3h(b)), acc); b = u3t(b); i_w--; } diff --git a/j/tree.c b/j/tree.c index 6c0ff2b46..180d2ded9 100644 --- a/j/tree.c +++ b/j/tree.c @@ -26,7 +26,7 @@ static u3j_harm _mood__hoon_reel_a[] = {{".2", u3wb_reel, c3y}, {}}; static u3j_harm _mood__hoon_roll_a[] = {{".2", u3wb_roll, c3y}, {}}; static u3j_harm _mood__hoon_skim_a[] = {{".2", u3wb_skim, c3y}, {}}; static u3j_harm _mood__hoon_skip_a[] = {{".2", u3wb_skip, c3y}, {}}; -// static u3j_harm _mood__hoon_scag_a[] = {{".2", u3wb_scag, c3y}, {}}; +static u3j_harm _mood__hoon_scag_a[] = {{".2", u3wb_scag, c3y}, {}}; static u3j_harm _mood__hoon_slag_a[] = {{".2", u3wb_slag, c3y}, {}}; static u3j_harm _mood__hoon_snag_a[] = {{".2", u3wb_snag, c3y}, {}}; // static u3j_harm _mood__hoon_sort_a[] = {{".2", u3wb_sort, c3y}, {}}; @@ -395,7 +395,7 @@ static u3j_core _mood__hoon_d[] = { "roll", _mood__hoon_roll_a }, { "skim", _mood__hoon_skim_a }, { "skip", _mood__hoon_skip_a }, -// { "scag", _mood__hoon_scag_a }, // this jet is actually broken + { "scag", _mood__hoon_scag_a }, // this jet is actually broken { "slag", _mood__hoon_slag_a }, { "snag", _mood__hoon_snag_a }, // { "sort", _mood__hoon_sort_a }, diff --git a/n/t.c b/n/t.c index ff937334b..31eede32e 100644 --- a/n/t.c +++ b/n/t.c @@ -207,10 +207,14 @@ u3t_samp(void) { u3C.wag_w &= ~u3o_debug_cpu; + static int home = 0; + static int away = 0; + // Profile sampling, because it allocates on the home road, // only works on when we're not at home. // if ( &(u3H->rod_u) != u3R ) { + home++; c3_l mot_l; u3a_road* rod_u; @@ -250,6 +254,10 @@ u3t_samp(void) } u3R = rod_u; } + else { + away++; + // fprintf(stderr,"home: %06d away: %06d\r\n", home, away); + } u3C.wag_w |= u3o_debug_cpu; } @@ -349,7 +357,29 @@ u3t_boot(void) } #endif #elif defined(U3_OS_linux) - // TODO: support profiling on linux + { + struct itimerval itm_v; + struct sigaction sig_s; + sigset_t set; + + sig_s.sa_handler = _ct_sigaction; + sigemptyset(&(sig_s.sa_mask)); + sig_s.sa_flags = 0; + sigaction(SIGPROF, &sig_s, 0); + + sigemptyset(&set); + sigaddset(&set, SIGPROF); + if ( 0 != pthread_sigmask(SIG_UNBLOCK, &set, NULL) ) { + perror("pthread_sigmask"); + } + + itm_v.it_interval.tv_sec = 0; + itm_v.it_interval.tv_usec = 10000; + // itm_v.it_interval.tv_usec = 100000; + itm_v.it_value = itm_v.it_interval; + + setitimer(ITIMER_PROF, &itm_v, 0); + } #elif defined(U3_OS_bsd) // TODO: support profiling on bsd #else