Changeset 369
- Timestamp:
- 07/31/06 02:28:24 (4 years ago)
- Location:
- icfp2006/trunk
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
icfp2006/trunk/Makefile
r366 r369 1 CPPFLAGS = -Wall -O0 -g 1 CCOPT = -O0 -g 2 CCOPT_FAST = -fast -mcpu=7450 -mdynamic-no-pic 3 DEBUG = 1 4 CPPFLAGS = -Wall $(CCOPT) -DDEBUG=$(DEBUG) 2 5 3 all: um 6 7 all: opt 8 9 shark: CCOPT = $(CCOPT_FAST) 10 shark: um 11 12 opt: DEBUG = 0 13 opt: shark 4 14 5 15 um: um.o … … 8 18 %.o: %.cpp 9 19 $(CXX) $(CPPFLAGS) -o $@ -c $< 20 21 clean: 22 rm -f um *.o -
icfp2006/trunk/um.cpp
r368 r369 2 2 #include <cstdlib> 3 3 #include <stdint.h> 4 #include <sys/ioctl.h> 4 5 #include <vector> 5 6 using namespace std; 7 6 8 7 9 typedef uint32_t platter_t; … … 33 35 34 36 37 void check_input(); 38 35 39 void next_inst(); 36 40 void read_program(const char *fname); … … 60 64 61 65 read_program(argv[1]); 66 #if DEBUG 67 int done = 0; 68 #endif 69 62 70 while (1) { 71 #if DEBUG 72 if (done % 1000000 == 0) { 73 fprintf(stderr, "MOps: %5d\n", done / 1000000); 74 } 75 ++done; 76 #endif 63 77 next_inst(); 64 78 } … … 105 119 switch (OP) { 106 120 case OP_INPUT: { 107 int c = fgetc(Infile); 108 CREG = static_cast<platter_t>(c == EOF ? -1 : c); 109 break; 121 #if DEBUG 122 check_input(); 123 #endif 124 int c = fgetc(Infile); 125 CREG = static_cast<platter_t>(c == EOF ? -1 : c); 126 break; 110 127 } 111 128 … … 176 193 } 177 194 } 195 196 void check_input() { 197 if (Infile == stdin) { 198 int cnt; 199 ioctl(/* stdin */ 0, FIONREAD, &cnt); 200 if (cnt == 0) { 201 fprintf(stderr, "> "); /* prompt the user */ 202 } 203 } 204 }
