static void output_base(void) { int i, j; start_int_table("sindex", base[0]); j = 10; for (i = 1; i < nstates; i++) { if (j >= 10) { output_newline(); j = 1; } else ++j; output_int(base[i]); } end_table(); start_int_table("rindex", base[nstates]); j = 10; for (i = nstates + 1; i < 2 * nstates; i++) { if (j >= 10) { output_newline(); j = 1; } else ++j; output_int(base[i]); } end_table(); start_int_table("gindex", base[2 * nstates]); j = 10; for (i = 2 * nstates + 1; i < nvectors - 1; i++) { if (j >= 10) { output_newline(); j = 1; } else ++j; output_int(base[i]); } end_table(); FREE(base); }
sl_def(t_main, void) { output_int(slr_get(a)[0], 1); output_char('\n', 1); output_int(slr_get(b)[0], 1); output_char('\n', 1); output_int(slr_get(c)[0], 1); output_char('\n', 1); }
sl_def(t_main, void) { int a[90000]; a[42] = 123; output_int(foo(a), 1); output_char('\n', 1); output_int(a[42], 1); output_char('\n', 1); }
sl_def(t_main, void) { int a = select(0, 1.41, 123); int b = select(1, 3.14, 456); output_int(a, 1); output_char('\n', 1); output_int(b, 1); output_char('\n', 1); }
sl_def(t_main, void) { int a = select(0, 123, 456); int b = select(1, 789, 666); output_int(a, 1); output_char('\n', 1); output_int(b, 1); output_char('\n', 1); }
int main(int argc, char **argv) { // Set up gpi pointer for direct register access setup_io(); // set the GPIO pins used for serial comm with shift registers to output setup_shiftreg(); output_int(0b1111111111111111); sleep(1); output_int(0b0); sleep(1); output_int(0b1001001001001000); sleep(1); output_int(0b0); sleep(1); output_int(0b0100100100100100); sleep(1); output_int(0b0); sleep(1); output_int(0b0010010010010010); sleep(1); output_int(0b0); return 0; } // main
// XIGNORE: *:D int main(int argc, const char **argv) { output_int(argc, 1); output_char('\n', 1); output_string(argv[0], 1); output_char('\n',1); return 0; }
static void output_check(void) { int i; int j; start_int_table("check", check[0]); j = 10; for (i = 1; i <= high; i++) { if (j >= 10) { output_newline(); j = 1; } else ++j; output_int(check[i]); } end_table(); FREE(check); }
sl_enddef // 2009-04-02: FIXME: we acknowledge that muTC-ptl // does not support this construct fully yet; but // we want slc's testsuite to properly succeed. So // we mark the test to ignore the output on muTC-ptl: // XIGNORE: ptl*:D sl_def(t_main, void) { int busy; sl_create(,,,,,,, foo, sl_sharg(int, a)); // FIXME: for ptl here we should find a way to // force a context switch, otherwise the problem // is not demonstrated. In the previous version // of this test, a call was done to the C library's // putc() function, but we can't do this in SL // because putc is a thread function and we cannot // nest creates. for (busy = 0; busy < 10000; ++busy) nop(); sl_seta(a, 42); sl_sync(); output_int(sl_geta(a), 1); output_char('\n', 1); }
static void goto_actions(void) { int i, j, k; state_count = NEW2(nstates, Value_t); k = default_goto(start_symbol + 1); start_int_table("dgoto", k); save_column(start_symbol + 1, k); j = 10; for (i = start_symbol + 2; i < nsyms; i++) { if (j >= 10) { output_newline(); j = 1; } else ++j; k = default_goto(i); output_int(k); save_column(i, k); } end_table(); FREE(state_count); }
static void output_table(void) { int i; int j; ++outline; fprintf(code_file, "#define YYTABLESIZE %d\n", high); start_int_table("table", table[0]); j = 10; for (i = 1; i <= high; i++) { if (j >= 10) { output_newline(); j = 1; } else ++j; output_int(table[i]); } end_table(); FREE(table); }
sl_def(synch_thread, void, sl_shparm(int, s)) { int temp; temp = sl_getp(s); output_int(temp, 1); sl_setp(s, temp + 1); }
sl_def(t_main, void) { int x = 42; x = foo(x); x = bar(x, x); output_int(x, 1); output_char('\n', 1); }
sl_def(foo, void, sl_shparm(int, token)) { int token = sl_getp(token); (void)bar(""); sl_index(i); output_int(i, 1); output_char('\n', 1); sl_setp(token, token); }
sl_enddef sl_def(t_main, void) { blah = 42; sl_proccall(foo); output_int(blah, 1); output_char('\n', 1); }
sl_enddef sl_def(iprint, int, sl_shparm(unsigned, count), sl_glparm(unsigned, refcount)) { sl_index(i); unsigned c = sl_getp(count); if (c >= sl_getp(refcount)) { sl_setp(count, c); sl_break ; } output_int(c, 1); output_char(' ', 1); output_int(indices[c], 1); output_char('\n', 1); sl_setp(count, c + 1); }
static void output_rule_data(void) { int i; int j; output_YYINT_typedef(output_file); start_int_table("lhs", symbol_value[start_symbol]); j = 10; for (i = 3; i < nrules; i++) { if (j >= 10) { output_newline(); j = 1; } else ++j; output_int(symbol_value[rlhs[i]]); } end_table(); start_int_table("len", 2); j = 10; for (i = 3; i < nrules; i++) { if (j >= 10) { output_newline(); j = 1; } else j++; output_int(rrhs[i + 1] - rrhs[i] - 1); } end_table(); }
void my_printf( char *fmt_buf, ... ) { va_list unnamed_p; /* point to named argument */ char *p, *sval; unsigned int value_i; /* unnamed_p point to first unnamed argument */ va_start( unnamed_p, fmt_buf ); for ( p=fmt_buf; *p; p++ ) { if ( *p != '%' ) { uart_putchar( UART0_BASE, *p ); continue; } switch ( *++p ) { case 'd': value_i = va_arg( unnamed_p, unsigned int ); output_int( value_i, 10 ); break; case 's': for (sval = va_arg(unnamed_p, char*); *sval; sval++) uart_putchar( UART0_BASE, *sval ); break; case 'x': value_i = va_arg( unnamed_p, unsigned int ); output_int( value_i, 16 ); break; default: uart_putchar( UART0_BASE, *p ); break; } } va_end( unnamed_p ); }
sl_def(t_main, void) { if (fibre_tag(0) != -1) { int x = 0; x += *(int*)fibre_data(0); x += *(int*)fibre_data(1); x += *(int*)fibre_data(2); x += *(int*)fibre_data(3); output_int(x, 1); output_char('\n', 1); } }
void sys_conf_init(void *init_parameters) { confword_t * words = (confword_t*) init_parameters; if (verbose_boot) { output_string("* reading configuration from 0x", 2); output_hex(words, 2); output_char(',', 2); } if (*words < 0x10000) { if (verbose_boot) output_string(" old style: only place info found.\n", 2); mgconf_layout_data = init_parameters; } else { if (verbose_boot) output_string(" new style:\n", 2); // new style microgrid, configuration blocks // are available, see MGSystem.cpp for values while (*words != 0) { unsigned tag = *words >> 16; unsigned size = *words & 0xffff; confword_t *data = words + 1; if (verbose_boot) { output_string(" at 0x", 2); output_hex(words, 2); output_string(", tag ", 2); output_uint(tag, 2); output_string(", ", 2); output_int(size, 2); output_string(" words: ", 2); } if (tag > (sizeof(parsers) / sizeof(parsers[0])) || !parsers[tag]) { if (verbose_boot) output_string("unknown tag\n", 2); } else parsers[tag](data); words += size + 1; } } }
static void output_accessing_symbols(void) { int i, j; int *translate; if (nstates != 0) { translate = TMALLOC(int, nstates); NO_SPACE(translate); for (i = 0; i < nstates; ++i) { int gsymb = accessing_symbol[i]; translate[i] = symbol_pval[gsymb]; } putl_code(output_file, "#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING)\n"); /* yystos[] may be unused, depending on compile-time defines */ start_int_table("stos", translate[0]); j = 10; for (i = 1; i < nstates; ++i) { if (j < 10) ++j; else { output_newline(); j = 1; } output_int(translate[i]); } end_table(); FREE(translate); putl_code(output_file, "#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */\n"); }
void interrupt handler(void){ int int_id; //determine if port is open if(DCB->flag != OPEN) outportb(PIC_CMD, 0x20); else{ //Read Interrupt ID int_id=inportb(COM1_INT_ID_REG); int_id &= 0x07; //calling appropiate second-level handler if(int_id == 2) output_int(); else if(int_id == 4) input_int(); //clear interrupt outportb(PIC_CMD,0x20); } }//end new_handler
static void output_yydefred (void) { int i, j; start_int_table ("defred", (defred[0] ? defred[0] - 2 : 0)); j = 10; for (i = 1; i < nstates; i++) { if (j < 10) ++j; else { output_newline (); j = 1; } output_int ((defred[i] ? defred[i] - 2 : 0)); } end_table (); }
static void output_accessing_symbols(void) { int i, j; int *translate; if (nstates != 0) { translate = TMALLOC(int, nstates); NO_SPACE(translate); for (i = 0; i < nstates; ++i) { int gsymb = accessing_symbol[i]; translate[i] = symbol_pval[gsymb]; } /* yystos[] may be unused, depending on compile-time defines */ start_int_table("stos", translate[0]); j = 10; for (i = 1; i < nstates; ++i) { if (j < 10) ++j; else { output_newline(); j = 1; } output_int(translate[i]); } end_table(); FREE(translate); }
sl_enddef // XIGNORE: mts*:D // SLT_RUN: -f TEST.d1 // SLT_RUN: -f TEST.d2 int main(int argc, char **argv) { int j; double x = .42; int n = 42; assert(fibre_tag(0) == 2 && fibre_rank(0) == 0); assert(fibre_tag(1) == 0 && fibre_rank(1) == 0); x = *(double*)fibre_data(0); n = *(long*)fibre_data(1); for(j = 0; j < MAX_TESTS; ++j) { values[j].desc = 0; values[j].f = values[j].d = x; values[j].i = values[j].l = values[j].ll = n; } sl_create(,,,,,,, do_test); sl_sync(); double_t xd = x; float_t xf = x; output_string("dot forty two, d: ", 1); output_float(xd, 1, 4); output_char('\n', 1); output_string("dot forty two, f: ", 1); output_float(xf, 1, 4); output_char('\n', 1); output_string("HUGE_VAL: ", 1); output_float(HUGE_VAL, 1, 4); output_char('\n', 1); output_string("HUGE_VALF: ", 1); output_float(HUGE_VALF, 1, 4); output_char('\n', 1); output_string("INFINITY: ", 1); output_float(INFINITY, 1, 4); output_char('\n', 1); output_string("NAN: ", 1); output_float(NAN, 1, 4); output_char('\n', 1); output_string("FP_ILOGB0 // ilogb(0): ", 1); output_int(FP_ILOGB0 == ilogb(0), 1); output_char('\n', 1); output_string("FP_ILOGBNAN // ilogb(NAN): ", 1); output_int(FP_ILOGBNAN == ilogb(NAN), 1); output_char('\n', 1); output_string("M_2: ", 1); output_float(M_E, 1, 4); output_char('\n', 1); output_string("M_LOG2E: ", 1); output_float(M_LOG2E, 1, 4); output_char('\n', 1); output_string("M_LOG10E: ", 1); output_float(M_LOG10E, 1, 4); output_char('\n', 1); output_string("M_LN2: ", 1); output_float(M_LN2, 1, 4); output_char('\n', 1); output_string("M_LN10: ", 1); output_float(M_LN10, 1, 4); output_char('\n', 1); output_string("M_PI: ", 1); output_float(M_PI, 1, 4); output_char('\n', 1); output_string("M_PI_2: ", 1); output_float(M_PI_2, 1, 4); output_char('\n', 1); output_string("M_PI_4: ", 1); output_float(M_PI_4, 1, 4); output_char('\n', 1); output_string("M_1_PI: ", 1); output_float(M_1_PI, 1, 4); output_char('\n', 1); output_string("M_2_PI: ", 1); output_float(M_2_PI, 1, 4); output_char('\n', 1); output_string("M_2_SQRTPI: ", 1); output_float(M_2_SQRTPI, 1, 4); output_char('\n', 1); output_string("M_SQRT2: ", 1); output_float(M_SQRT2, 1, 4); output_char('\n', 1); output_string("M_SQRT1_2: ", 1); output_float(M_SQRT1_2, 1, 4); output_char('\n', 1); for (j = 0; j < p; ++j) { const char *d = values[j].desc ? values[j].desc : "."; output_string(d, 1); output_char(' ', 1); output_float(values[j].d, 1, 4); output_char(' ', 1); output_float(values[j].f, 1, 4); output_char(' ', 1); output_int(values[j].i, 1); output_char(' ', 1); output_int(values[j].l, 1); output_char(' ', 1); output_int(values[j].ll, 1); output_char('\n', 1); } return 0; }
int get_result(size_t size,size_t points_size,point_t *points,int ***result) { size_t iter = 0,iter_,result_size; int hs_size = size,***hs_points = malloc(sizeof(int **)*(points_size+1)) ,***hs_result,errcode; FILE *pin,*pout; if(!hs_points)return 0; while(iter != points_size){ hs_points[iter] = malloc(sizeof(int *)*2); if(!hs_points[iter]){ free_iituplelist(hs_points); return 0; } hs_points[iter][0] = malloc(sizeof(int)); hs_points[iter][1] = malloc(sizeof(int)); if(!hs_points[iter][0] || !hs_points[iter][1]){ free(hs_points[iter][0]); free(hs_points[iter][1]); free(hs_points[iter]); hs_points[iter] = NULL; free_iituplelist(hs_points); return 0; } *hs_points[iter][0] = points[iter].x; *hs_points[iter][1] = points[iter].y; iter++; } hs_points[points_size] = NULL; errcode = popen2("runyadorigi ./nqueens.hs",&pout,&pin); if(errcode < 0){ free_iituplelist(hs_points); return 0; } output_int(pin,&hs_size); fputc('\n',pin); output_iituplelist(pin,hs_points); fputc('\n',pin); fclose(pin); hs_result = parse_intlistlist(pout); fclose(pout); if(!hs_result)return 0; result_size = parray_length((void **)hs_result); *result = malloc(sizeof(int *)*(result_size+1)); if(!*result){ free_intlistlist(hs_result); return 0; } iter = 0; while(iter != result_size){ (*result)[iter] = malloc(sizeof(int)*size); if(!(*result)[iter]){ while(iter--)free((*result)[iter]); free(*result); return 0; } iter_ = 0; while(iter_ != size){ (*result)[iter][iter_] = *hs_result[iter][iter_]; iter_++; } iter++; } (*result)[result_size] = NULL; return 1; }
FTextStream &FTextStream::operator<<( signed long i ) { return output_int( i, i < 0 ); }
FTextStream &FTextStream::operator<<( unsigned long i ) { return output_int( i, FALSE ); }
sl_def(t_main, void) { output_int(bar(), 1); output_char('\n', 1); }
void output_pixbuf (FILE *outfile, gboolean ext_symbols, const char *varname, GdkPixbuf *pixbuf) { const char *modifier; const guchar *p; const guchar *end; gboolean has_alpha; int column; modifier = "static "; if (ext_symbols) modifier = ""; g_fprintf (outfile, "%sconst guchar ", modifier); fputs (varname, outfile); fputs ("[] =\n", outfile); fputs ("{\n", outfile); p = gdk_pixbuf_get_pixels (pixbuf); end = p + gdk_pixbuf_get_rowstride (pixbuf) * gdk_pixbuf_get_height (pixbuf); has_alpha = gdk_pixbuf_get_has_alpha (pixbuf); /* Sync the order of writing with the order of reading in * gdk-pixbuf-data.c */ output_int (outfile, GDK_PIXBUF_INLINE_MAGIC_NUMBER, "File magic"); output_int (outfile, GDK_PIXBUF_INLINE_RAW, "Format of following stuff"); output_int (outfile, gdk_pixbuf_get_rowstride (pixbuf), "Rowstride"); output_int (outfile, gdk_pixbuf_get_width (pixbuf), "Width"); output_int (outfile, gdk_pixbuf_get_height (pixbuf), "Height"); output_bool (outfile, has_alpha, "Has an alpha channel"); output_int (outfile, gdk_pixbuf_get_colorspace (pixbuf), "Colorspace (0 == RGB, no other options implemented)"); output_int (outfile, gdk_pixbuf_get_n_channels (pixbuf), "Number of channels"); output_int (outfile, gdk_pixbuf_get_bits_per_sample (pixbuf), "Bits per sample"); fputs (" /* Image data */\n", outfile); /* Copy the data in the pixbuf */ column = 0; while (p != end) { guchar r, g, b, a; r = *p; ++p; g = *p; ++p; b = *p; ++p; if (has_alpha) { a = *p; ++p; } else a = 0; if (has_alpha) g_fprintf (outfile, " 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x", r, g, b, a); else g_fprintf (outfile, " 0x%.2x, 0x%.2x, 0x%.2x", r, g, b); if (p != end) fputs (",", outfile); else fputs ("\n", outfile); ++column; if (column > 2) { fputs ("\n", outfile); column = 0; } } fputs ("};\n\n", outfile); }