예제 #1
0
int main(int argc, char** argv )
{
	printf("%25s\t%15s\t%15s\t%15s\n", "clock", "res (ns)", "secs", "nsecs");
	struct timeval tv;
	gettimeofday(&tv, NULL);
	printf("%25s\t%15s\t%15s\t", "gettimeofday","1,000", commaprint(tv.tv_sec));
	printf("%15s\n", commaprint(tv.tv_usec*1000));
	#if _POSIX_TIMERS > 0
	#ifdef CLOCK_REALTIME
	do_clock(CLOCK_REALTIME);
	#endif
	#ifdef CLOCK_REALTIME_COARSE
	do_clock(CLOCK_REALTIME_COARSE);
	#endif
	#ifdef CLOCK_REALTIME_HR
	do_clock(CLOCK_REALTIME_HR);
	#endif
	#ifdef CLOCK_MONOTONIC
	do_clock(CLOCK_MONOTONIC);
	#endif
	#ifdef CLOCK_MONOTONIC_RAW
	do_clock(CLOCK_MONOTONIC_RAW);
	#endif
	#ifdef CLOCK_MONOTONIC_COARSE
	do_clock(CLOCK_MONOTONIC_COARSE);
	#endif
	#endif
	return 0;
}
예제 #2
0
int
main(int ac, char **av)
{
	GR_EVENT	event;		/* current event */
	GR_BITMAP	bitmap1fg[7];	/* bitmaps for first cursor */
	GR_BITMAP	bitmap1bg[7];

	if (GrOpen() < 0) {
		fprintf(stderr, "cannot open graphics\n");
		exit(1);
	}
	
	/* create window*/
	w1 = GrNewWindowEx(
		GR_WM_PROPS_NOAUTOMOVE|GR_WM_PROPS_BORDER|GR_WM_PROPS_CAPTION|
		GR_WM_PROPS_CLOSEBOX, "nxclock", GR_ROOT_WINDOW_ID, 
		10, 10, CWIDTH, CHEIGHT, GrGetSysColor(GR_COLOR_WINDOW));
		
	GrSelectEvents(w1, GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_CLOSE_REQ);

	gc1 = GrNewGC();
	gc2 = GrNewGC();

	GrSetGCForeground(gc1, GrGetSysColor(GR_COLOR_WINDOW));
	GrSetGCBackground(gc1, GrGetSysColor(GR_COLOR_WINDOWTEXT));
	GrSetGCForeground(gc2, GrGetSysColor(GR_COLOR_WINDOWTEXT));
	GrSetGCBackground(gc2, GrGetSysColor(GR_COLOR_WINDOW));

	bitmap1bg[0] = MASK(_,_,X,X,X,_,_);
	bitmap1bg[1] = MASK(_,X,X,X,X,X,_);
	bitmap1bg[2] = MASK(X,X,X,X,X,X,X);
	bitmap1bg[3] = MASK(X,X,X,X,X,X,X);
	bitmap1bg[4] = MASK(X,X,X,X,X,X,X);
	bitmap1bg[5] = MASK(_,X,X,X,X,X,_);
	bitmap1bg[6] = MASK(_,_,X,X,X,_,_);

	bitmap1fg[0] = MASK(_,_,_,X,_,_,_);
	bitmap1fg[1] = MASK(_,X,_,X,_,X,_);
	bitmap1fg[2] = MASK(_,_,_,X,_,_,_);
	bitmap1fg[3] = MASK(X,_,_,X,X,_,X);
	bitmap1fg[4] = MASK(_,_,_,_,_,_,_);
	bitmap1fg[5] = MASK(_,X,_,_,_,X,_);
	bitmap1fg[6] = MASK(_,_,_,X,_,_,_);

	GrSetCursor(w1, 7, 7, 3, 3, WHITE, BLACK, bitmap1fg, bitmap1bg);
	GrMapWindow(w1);

	while (1) {
		GrGetNextEventTimeout(&event, 500L);

		switch (event.type) {
			case GR_EVENT_TYPE_EXPOSURE:
				do_exposure(&event.exposure);
				break;

			case GR_EVENT_TYPE_CLOSE_REQ:
				GrClose();
				exit(0);

			case GR_EVENT_TYPE_TIMEOUT:
				do_clock();
				break;
		}
	}
}
예제 #3
0
/*
 *	The function "mon()" is the dialog user interface, called
 *	from the simulation just after program start.
 */
void mon(void)
{
	register int eoj = 1;
	static char cmd[LENCMD];

	tcgetattr(0, &old_term);

	if (x_flag) {
		if (do_getfile(xfn) == 0)
			do_go();
	}
	while (eoj) {
		next:
		printf(">>> ");
		fflush(stdout);
		if (fgets(cmd, LENCMD, stdin) == NULL) {
			putchar('\n');
			goto next;
		}
		switch (*cmd) {
		case '\n':
			do_step();
			break;
		case 't':
			do_trace(cmd + 1);
			break;
		case 'g':
			do_go();
			break;
		case 'd':
			do_dump(cmd + 1);
			break;
		case 'l':
			do_list(cmd + 1);
			break;
		case 'm':
			do_modify(cmd +	1);
			break;
		case 'f':
			do_fill(cmd + 1);
			break;
		case 'v':
			do_move(cmd + 1);
			break;
		case 'x':
			do_reg(cmd + 1);
			break;
		case 'p':
			do_port(cmd + 1);
			break;
		case 'b':
			do_break(cmd + 1);
			break;
		case 'h':
			do_hist(cmd + 1);
			break;
		case 'z':
			do_count(cmd + 1);
			break;
		case 'c':
			do_clock();
			break;
		case 's':
			do_show();
			break;
		case '?':
			do_help();
			break;
		case 'r':
			do_getfile(cmd + 1);
			break;
		case '!':
			do_unix(cmd + 1);
			break;
		case 'q':
			eoj = 0;
			break;
		default:
			puts("what??");
			break;
		}
	}
}