void PrintTryFinallyStatement(const CodeSource &src, const TryFinallyStatementNode *node, Printer pr, int tabDepth) { pr("try "); PrintBlock(src, node->tryBlock(), pr, tabDepth + 1); PrintTabDepth(tabDepth, pr); pr("finally "); PrintBlock(src, node->finallyBlock(), pr, tabDepth + 1); }
void PrintTryCatchStatement(const CodeSource &src, const TryCatchStatementNode *node, Printer pr, int tabDepth) { pr("try "); PrintBlock(src, node->tryBlock(), pr, tabDepth + 1); PrintTabDepth(tabDepth, pr); pr("catch ("); PrintToken(src, node->catchName(), pr); pr(") "); PrintBlock(src, node->catchBlock(), pr, tabDepth + 1); }
void BlockMapIO_Printf(const BlockMap *me) { printf("\nBlockMap"); printf("\n pixelCount: width=%d, height=%d\n", me->pixelCount.width, me->pixelCount.height); printf("\n blockCount: width=%d, height=%d\n", me->blockCount.width, me->blockCount.height); printf("\n cornerCount: width=%d, height=%d\n", me->cornerCount.width, me->cornerCount.height); printf("\n allBlocks: x=%d, y=%d, width=%d, height=%d\n", me->allBlocks.x, me->allBlocks.y, me->allBlocks.width, me->allBlocks.height); printf("\n allCorners: x=%d, y=%d, width=%d, height=%d\n", me->allCorners.x, me->allCorners.y, me->allCorners.width, me->allCorners.height); printf("\n corners.allX (%dx):", me->corners.allX.size); array_printf(me->corners.allX.size, me->corners.allX.data); printf("\n corners.allY (%dx):", me->corners.allY.size); array_printf(me->corners.allY.size, me->corners.allY.data); printf("\n blockAreas.corners.allX (%dx):", me->blockAreas.corners.allX.size); array_printf(me->blockAreas.corners.allX.size, me->blockAreas.corners.allX.data); printf("\n blockAreas.corners.allY (%dx):", me->blockAreas.corners.allY.size); array_printf(me->blockAreas.corners.allY.size, me->blockAreas.corners.allY.data); printf("\n blockCenters.allX (%dx):", me->blockCenters.allX.size); array_printf(me->blockCenters.allX.size, me->blockCenters.allX.data); printf("\n blockCenters.allY (%dx):", me->blockCenters.allY.size); array_printf(me->blockCenters.allY.size, me->blockCenters.allY.data); printf("\n cornerAreas.corners.allX (%dx):", me->cornerAreas.corners.allX.size); array_printf(me->cornerAreas.corners.allX.size, me->cornerAreas.corners.allX.data); printf("\n cornerAreas.corners.allY (%dx):", me->cornerAreas.corners.allY.size); PrintBlock(me->cornerAreas.corners.allY); }
void Screen::PrintNormal(WINDOW * const window) const { const int dir=player->Dir(); const ushort k_start=( UP!=dir ) ? (( DOWN==dir ) ? player->Z()-1 : player->Z()) : player->Z()+1; const short k_step=( UP!=dir ) ? (-1) : 1; (void)wmove(window, 1, 1); const ushort start_x=( player->X()/SHRED_WIDTH )*SHRED_WIDTH + ( SHRED_WIDTH-SCREEN_SIZE )/2; const ushort start_y=( player->Y()/SHRED_WIDTH )*SHRED_WIDTH + ( SHRED_WIDTH-SCREEN_SIZE )/2; const int block_side=( dir==UP ) ? DOWN : UP; ushort i, j; for ( j=start_y; j<SCREEN_SIZE+start_y; ++j, waddstr(window, "\n_") ) for ( i=start_x; i<SCREEN_SIZE+start_x; ++i ) { ushort k; for (k=k_start; INVISIBLE==w->Transparent(i, j, k); k+=k_step); if ( (w->Enlightened(i, j, k, block_side) && player->Visible(i, j, k)) || player->GetCreativeMode() ) { PrintBlock(i, j, k, window); waddch(window, CharNumber(i, j, k)); } else { wstandend(window); waddch(window, OBSCURE_BLOCK); waddch(window, ' '); } } wstandend(window); box(window, 0, 0); if ( UP==dir || DOWN==dir ) { mvwaddstr(window, 0, 1, ( UP==dir ) ? "Up view" : "Ground view"); Arrows(window, (player->X()-start_x)*2+1, player->Y()-start_y+1); } else { mvwaddstr(window, 0, 1, "Down view"); if ( player->GetCreativeMode() ) { Arrows(window, (player->X()-start_x)*2+1, player->Y()-start_y+1); } } wnoutrefresh(window); }
void Screen::PrintFront(WINDOW * const window) const { const int dir=player->Dir(); if ( UP==dir || DOWN==dir ) { wstandend(window); werase(window); box(window, 0, 0); mvwaddstr(window, 0, 1, "No view"); wnoutrefresh(window); return; } short x_step, z_step, x_end, z_end, * x, * z, i, j, k; const ushort pX=player->X(); const ushort pY=player->Y(); const ushort pZ=player->Z(); const ushort begin_x = ( pX/SHRED_WIDTH )*SHRED_WIDTH + ( SHRED_WIDTH-SCREEN_SIZE )/2; const ushort begin_y = ( pY/SHRED_WIDTH )*SHRED_WIDTH + ( SHRED_WIDTH-SCREEN_SIZE )/2; ushort x_start, z_start, k_start; ushort arrow_Y, arrow_X; switch ( dir ) { case NORTH: x=&i; x_step=1; x_start=begin_x; x_end=x_start+SCREEN_SIZE; z=&j; z_step=-1; z_start=pY-1; z_end=pY-SHRED_WIDTH-1; arrow_X=(pX-begin_x)*2+1; break; case SOUTH: x=&i; x_step=-1; x_start=SCREEN_SIZE-1+begin_x; x_end=begin_x-1; z=&j; z_step=1; z_start=pY+1; z_end=pY+SHRED_WIDTH+1; arrow_X=(SCREEN_SIZE-pX+begin_x)*2-1; break; case WEST: x=&j; x_step=-1; x_start=SCREEN_SIZE-1+begin_y; x_end=begin_y-1; z=&i; z_step=-1; z_start=pX-1; z_end=pX-SHRED_WIDTH-1; arrow_X=(SCREEN_SIZE-pY+begin_y)*2-1; break; case EAST: x=&j; x_step=1; x_start=begin_y; x_end=SCREEN_SIZE+begin_y; z=&i; z_step=1; z_start=pX+1; z_end=pX+SHRED_WIDTH+1; arrow_X=(pY-begin_y)*2+1; break; default: fprintf(stderr, "Screen::PrintFront(WINDOW *): \ unlisted dir: %d\n", (int)dir); return; } if ( pZ+SCREEN_SIZE/2>=HEIGHT ) { k_start=HEIGHT-2; arrow_Y=HEIGHT-pZ; } else if ( pZ-SCREEN_SIZE/2<0 ) { k_start=SCREEN_SIZE-1; arrow_Y=SCREEN_SIZE-pZ; } else { k_start=pZ+SCREEN_SIZE/2; arrow_Y=SCREEN_SIZE/2+1; } const int block_side=w->Anti(dir); (void)wmove(window, 1, 1); for (k=k_start; k_start-k<SCREEN_SIZE; --k, waddstr(window, "\n_")) { for (*x=x_start; *x!=x_end; *x+=x_step) { for (*z=z_start; *z!=z_end; *z+=z_step) if ( w->Transparent(i, j, k) != INVISIBLE ) { if ( (w->Enlightened(i, j, k, block_side) && player-> Visible(i, j, k)) || player-> GetCreativeMode() ) { PrintBlock(i, j, k, window); waddch(window, CharNumberFront(i, j)); } else { wstandend(window); waddch(window, OBSCURE_BLOCK); waddch(window, ' '); } break; } if ( *z==z_end ) { //far decorations *z-=z_step; if ( player->Visible(i, j, k ) ) { wcolor_set(window, Color(BLOCK, SKY), NULL); waddch(window, CharName(BLOCK, SKY)); } else { wstandend(window); waddch(window, OBSCURE_BLOCK); } waddch(window, ' '); } } } wstandend(window); box(window, 0, 0); switch ( dir ) { case NORTH: mvwaddstr(window, 0, 1, "North view"); break; case SOUTH: mvwaddstr(window, 0, 1, "South view"); break; case EAST: mvwaddstr(window, 0, 1, "East view"); break; case WEST: mvwaddstr(window, 0, 1, "West view"); break; } Arrows(window, arrow_X, arrow_Y); if ( shiftFocus ) { HorizontalArrows(window, arrow_Y-=shiftFocus, WHITE_BLUE); } wnoutrefresh(window); }
void PrintBytesLenght(FILE *f, const char *text, const BYTE *bytes, unsigned long length) { PrintBlock(f,text); PrintHex(f,text,bytes,length); fprintf(f,"LENGTH = %ld\n\n", length); }
void PrintBytes(FILE *f, const char *text, const PTEID_Bytes *bytes) { PrintBlock(f,text); PrintHex(f,text,bytes->data,bytes->length); fprintf(f,"LENGTH = %ld\n\n", bytes->length); }
/*---------------------------------------------------------------------------*/ PROCESS_THREAD(aestest, ev, data) { static int i, j; unsigned long start, end; static struct etimer periodic_timer; PROCESS_BEGIN(); printf("#Fixed AES-128 implementation test for %s.\n", TARGET_NAME); #ifndef AES_128_CONF printf("#Using Contiki software implementation.\n"); #else printf("#Using Hardware coprocessor.\n"); #endif printf("#Rounds in each sample: %d\n", NROUND); printf("#Sample size: %d\n", NSAMPLE); printf("#Rtimer clock ticks per second on this platform is : %lu\n", (unsigned long) RTIMER_SECOND); printf("#datablock address: %u\n", (unsigned int) datablock); etimer_set(&periodic_timer, (2 * CLOCK_SECOND)); //Initialise Data for (j = 0; j < NROUND; j++) memcpy(datablock[j], fixed_data, AES_BLOCK_LEN); for (i = 0; i < NSAMPLE; i++) { PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&periodic_timer)); etimer_reset(&periodic_timer); #ifdef VERBOSE_AESTEST printf("#Sample %d/%d\n", i + 1, NSAMPLE); PrintBlock("#Key\t: ", Aes128Key, "\n"); PrintBlock("#Plaintext\t: ", datablock[0], "\n"); #endif AES_128.set_key(Aes128Key); //Start timing. start = RTIMER_NOW(); #ifndef TIMING_FRAMEWORK_TEST for (j = 0; j < NROUND; j++) { AES_128.encrypt(datablock[j]); } #else for (j = 0; j < NROUND * 10; j++) { random_rand(); } #endif end = RTIMER_NOW(); //Print result. #ifdef VERBOSE_AESTEST PrintBlock("#Ciphertext\t: ", datablock[0], "\n"); printf("#Round\t: %d\n", NROUND); printf("#Start\t: %lu\n", start); printf("#End\t: %lu\n", end); printf("#Time Elapsed\t:\n"); #endif printf("%lu\n", end - start); finalise(); } printf("#%d tests done for %s.\n", NSAMPLE, TARGET_NAME); PROCESS_END(); }
APIRET PerfCtrTest(void) { APIRET rc; HEV hevSem; PBYTE pbRangeStart = 0; PBYTE pbData; ULONG ulRangeSize = 0; ULONG ulBID; PTBH pTBH; PDBH pDBH; /* create event semaphore */ rc = DosCreateEventSem(NULL, &hevSem, DC_SEM_SHARED, 0); if (rc) printf ("createsem rc = %u %08x ...\n", rc, rc); /* to close previous session */ rc = Dos32ConfigurePerf(0, 4, 0, 0, 0, 0); printf ("Dos32ConfigurePerf(TERMINATE) rc = %u.\n", rc); /* note: it is important to allocate the queue first and launch the collector threads afterwards */ /* initialize subsystem */ rc = Dos32ConfigurePerf(0x100, 0, hevSem, 0, 0, 0); printf ("Dos32ConfigurePerf(INITIALIZE, ALLOC QUEUE) rc = %u\n", rc); /* initialize subsystem */ rc = Dos32ConfigurePerf(0x020, 0, hevSem, 0, 0, 0); printf ("Dos32ConfigurePerf(INITIALIZE, START THDS) rc = %u\n", rc); /* Dieser alias erlaubt scannen EINER gruppe rc = Dos32AliasPerfCtrs(0x0f, 0, &pbRangeStart, &ulRangeSize); printf ("aliasperff init rc = %u %08x ...\n", rc, rc); printf ("pbRangeStart = %08xh, ulRangeSize = %u\n", pbRangeStart, ulRangeSize); */ #define TESTAP(a,b) rc=Dos32AliasPerfCtrs(a,b,&pbRangeStart,&ulRangeSize); \ printf ("ap(#%08x,#%08x) rc=%3u", a,b,rc); \ printf (" pbRangeStart = %08xh, ulRangeSize = %u\n", \ pbRangeStart, \ ulRangeSize); /* TESTAP(0,0); TESTAP(1,0); TESTAP(2,0); TESTAP(3,0); TESTAP(4,0); TESTAP(5,0); TESTAP(6,0); TESTAP(7,0); TESTAP(8,0); TESTAP(9,0); TESTAP(10,0); TESTAP(11,0); TESTAP(12,0); TESTAP(13,0); TESTAP(14,0); TESTAP(15,0); TESTAP(16,0); TESTAP(17,0); TESTAP(18,0); TESTAP(19,0); TESTAP(20,0); TESTAP(21,0); TESTAP(22,0); TESTAP(23,0); TESTAP(24,0); TESTAP(25,0); TESTAP(26,0); TESTAP(27,0); TESTAP(28,0); TESTAP(29,0); TESTAP(30,0); TESTAP(31,0); TESTAP(32,0); rc = Dos32ConfigurePerf(1, 1, ulBID, 0, 0, 0); printf ("configureperf (%08xh) start rc = %u %08x ...\n", ulBID, rc, rc); */ /* TESTAP(11,0); pTBH = (PTBH)pbRangeStart; TESTAP(19,0); pDBH = (PDBH)pbRangeStart; ulBID = pTBH->tbh_bidID.bid_usInstance | (pTBH->tbh_bidID.bid_usGroup << 16); */ ulRangeSize = 65536; pbRangeStart = malloc(ulRangeSize); printf ("pbRangeStart = %08xh\n",pbRangeStart); while( !kbhit() ) { ULONG ulSize; PBYTE pBlock; DosSleep(1000); //printf("* waiting for PerfView message\n "); //rc = DosWaitEventSem(hevSem, // 1000); rc = NO_ERROR; if (rc == NO_ERROR) { printf("* got PerfView message\n "); printf ("***QUEUE SNAPSHOT***\n"); TESTAP(32,ulRangeSize); /* try to calculate blocks from messages in queue */ for (pBlock = pbRangeStart, ulSize = *(PULONG)pbRangeStart; ulSize != 0; pBlock += ulSize, ulSize = *(PULONG)pBlock) { printf("\n**BLOCK %08xh, SIZE %u (%08xh)**\n", pBlock, ulSize, ulSize); /* ToolsDumpHex(pBlock, 0x14, pBlock); */ pDBH = pBlock; pTBH = pBlock + 0x14; /* skip size */ PrintBlock (pTBH, pDBH, FALSE); printf ("\n**ALIASING BLOCK %04x:%04x**\n", pTBH->tbh_bidID.bid_usGroup, pTBH->tbh_bidID.bid_usInstance); ulBID = pTBH->tbh_bidID.bid_usInstance | (pTBH->tbh_bidID.bid_usGroup << 16); TESTAP(0x11, ulBID); //pDBH = (PDBH)pbRangeStart; ToolsDumpHex(pbRangeStart, ulRangeSize, pbRangeStart); rc = Dos32ConfigurePerf(1, 1, ulBID, 0, 0, 0); printf ("configureperf (%08xh) start rc = %u %08x ...\n", ulBID, rc, rc); /* ToolsDumpHex(pbRangeStart, ulRangeSize, pbRangeStart); */ PrintBlock(pTBH, pDBH, TRUE); } /* PrintBlock(pTBH, pDBH); ToolsDumpHex( pbRangeStart, ulRangeSize, pbRangeStart); printf("\n"); */ ulRangeSize = 65536; } else printf ("* nothing yet\n"); } /* rc = DosRegisterPerfCtrs(&PerfViewDB, &PerfViewTB, RPC_FL_APP | RPC_FL_32BIT | RPC_FL_DEREG); printf ("deregisterperf rc = %u %08x ...\n", rc, rc); printf ("textblock: bid: %08xh group=%04xh inst=%04xh\n", PerfViewTB.tbh_bidID, PerfViewTB.tbh_bidID.bid_usGroup, PerfViewTB.tbh_bidID.bid_usInstance); */ rc = Dos32ConfigurePerf(0, 4, 0, 0, 0, 0); printf ("configureperf term rc = %u %08x ...\n", rc, rc); return rc; }
/*---------------------------------------------------------------------------*/ PROCESS_THREAD(aestest, ev, data) { static int i, j; unsigned long start, end; static struct etimer periodic_timer; PROCESS_BEGIN(); printf("#Random AES-128 implementation test for %s.\n", TARGET_NAME); printf("#Using OpenBSD optimised AES implementation.\n"); printf("#Rounds in each sample: %d\n", NROUND); printf("#Sample size: %d\n", NSAMPLE); printf("#Rtimer clock ticks per second on this platform is : %lu\n", (unsigned long) RTIMER_SECOND); printf("#plaintext addr: %ul\n", (unsigned int)plaintext); printf("#ciphertext addr: %ul\n", (unsigned int)ciphertext); etimer_set(&periodic_timer, (1 * CLOCK_SECOND)); //Initialise plaintext. for (j = 0; j < NROUND; j++) { memcpy(plaintext[j], fixed_data, AES_BLOCK_LEN); } //Begin test. for (i = 0; i < NSAMPLE; i++) { PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&periodic_timer)); etimer_reset(&periodic_timer); #ifdef VERBOSE_AESTEST printf("#Sample %d/%d\n", i + 1, NSAMPLE); PrintBlock("#Key\t:", Aes128Key, "\n"); PrintBlock("#Plaintext\t: ", plaintext[0], "\n"); #endif //Set key. rijndael_set_key_enc_only(&aes_ctx, Aes128Key, 8 * AES_KEY_LEN); rijndael_encrypt(&aes_ctx, dummyplaintext, dummyciphertext); //Timing AES. start = RTIMER_NOW(); #ifdef CALIBRATE_FRAMEWORK for (j = 0; j < NROUND * 10; j++){ random_rand(); } #else for (j = 0; j < NROUND; j++) { rijndael_encrypt(&aes_ctx, plaintext[j], ciphertext[j]); } #endif end = RTIMER_NOW(); #ifdef VERBOSE_AESTEST //Print result. PrintBlock("#Ciphertext\t: ", ciphertext[0], "\n"); printf("#Round\t: %d\n", NROUND); printf("#Start\t: %lu\n", start); printf("#End\t: %lu\n", end); printf("#Time Elapsed\t:\n"); #endif //Print execution time. printf("%lu\n", end - start); finalise(); } printf("#%d tests done for %s.\n", NSAMPLE, TARGET_NAME); PROCESS_END(); }