diff -N -r -c giottoc/INSTALL_MINGW32.txt giottoc-mingw32/INSTALL_MINGW32.txt *** giottoc/INSTALL_MINGW32.txt Wed Dec 31 16:00:00 1969 --- giottoc-mingw32/INSTALL_MINGW32.txt Thu Nov 15 23:54:08 2001 *************** *** 0 **** --- 1,41 ---- + This is the INSTALL file for the Mingw32 Windows version of giottoc 0.1! + + Follow Steps 1 through 6 in the INSTALL file (Install Java, unpack + the distribution) + + 7. Download Mingw from + http://www.mingw.org/download.shtml + I downloaded MinGW-1.1.tar.gz + + 8. Install Mingw with + + mkdir d:/mingw32 + cd d:/mingw32 + tar -zxf /cygdrive/d/tmp/downloads/MinGW-1.1.tar.gz + PATH=/cygdrive/d/mingw32/bin:$PATH + export PATH + + 9. Download pthreads from + http://sources.redhat.com/pthreads-win32/ + or use cvs + cvs -d :pserver:anoncvs@sources.redhat.com:/cvs/pthreads-win32 login + {enter ``anoncvs'' for the password} + cvs -d :pserver:anoncvs@sources.redhat.com:/cvs/pthreads-win32 checkout pthreads + + 10. cd to the pthreads directory and build it + cd ~/src/pthreads + ./configure + make clean GC + + 11. Edit giottoc/makefile, uncomment the makefile variables for + Mingw32 and adjust accordingly + + 12. Run + make emachine + + 13. Add the pthreadsGC.dll to your path: + PATH=/cygdrive/c/users/cxh/src/pthreads:$PATH + + 14. Run the demo + ./e_machine.exe + diff -N -r -c giottoc/emachine/e_interface.c giottoc-mingw32/emachine/e_interface.c *** giottoc/emachine/e_interface.c Thu Oct 4 11:46:09 2001 --- giottoc-mingw32/emachine/e_interface.c Thu Nov 15 23:59:49 2001 *************** *** 100,110 **** --- 100,125 ---- os_semaphore_post(&(((timer_type *) args)->semaphore)); + #ifdef __MINGW32__ + #ifdef DDEBUG + fprintf(stderr, "timer_code(): nanosleep is not defined under MINGW32 sec:%u, nsec: %u \n", + ((timer_type *) args)->timer_sec, + ((timer_type *) args)->timer_nsec + ); + fflush(stderr); + #endif /*DEBUG*/ + /* Sleep() takes times in ms, so we multiply seconds by 1k and + * divide nanoseconds by 1k. + */ + Sleep(((timer_type *) args)->timer_sec * 1000.0 + + ((timer_type *) args)->timer_nsec / 1000.0); + #else /*__MINGW32__*/ if (nanosleep(&req, &rem)) { #ifdef DEBUG printf(" nanosleep error\n"); #endif } + #endif /*__MINGW32__*/ logical_time = (logical_time + 1) % logical_time_overflow; } diff -N -r -c giottoc/emachine/e_machine.c giottoc-mingw32/emachine/e_machine.c *** giottoc/emachine/e_machine.c Thu Oct 4 13:36:36 2001 --- giottoc-mingw32/emachine/e_machine.c Thu Nov 15 23:57:42 2001 *************** *** 42,48 **** int arg1, arg2, arg3; ! unsigned mask, end; unsigned i, j; --- 42,49 ---- int arg1, arg2, arg3; ! /* Under Mingw32, end is a keyword, so we use e_end */ ! unsigned mask, e_end; unsigned i, j; *************** *** 81,89 **** n_enabled_triggers--; ! end = 0; ! while (!end) { arg1 = program[pc].arg1; arg2 = program[pc].arg2; arg3 = program[pc].arg3; --- 82,90 ---- n_enabled_triggers--; ! e_end = 0; ! while (!e_end) { arg1 = program[pc].arg1; arg2 = program[pc].arg2; arg3 = program[pc].arg3; *************** *** 136,142 **** pc = arg1; break; case OPCODE_return: /* return */ ! end = 1; break; } /* switch */ } /* while */ --- 137,143 ---- pc = arg1; break; case OPCODE_return: /* return */ ! e_end = 1; break; } /* switch */ } /* while */ diff -N -r -c giottoc/examples/fcode/f_code.c giottoc-mingw32/examples/fcode/f_code.c *** giottoc/examples/fcode/f_code.c Thu Oct 4 13:22:35 2001 --- giottoc-mingw32/examples/fcode/f_code.c Thu Nov 15 23:52:02 2001 *************** *** 32,44 **** --- 32,88 ---- #include "f_code.h" + + #ifdef __MINGW32__ + /* ioctl is not defined under MINGW32, so we use PeekConsoleInput + For an example that uses ReadConsole, see + http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/conchar_2nw3.asp + */ + static HANDLE hstdin; + void printError(char * message) { + fprintf(stderr, "%s, GetLastError: %d", message, GetLastError()); + fflush(stderr); + } + + #endif + void c_connect_sensor_to_return_key(c_bool *sensor) { unsigned c=0; char s; + #ifdef __MINGW32__ + DWORD peekRecordsRead; + INPUT_RECORD peek; + + if (hstdin == 0) { + if ((hstdin = GetStdHandle(STD_INPUT_HANDLE)) == INVALID_HANDLE_VALUE) { + printError("f_code.c: getStdHandle failed"); + } + } + + if (PeekConsoleInput(hstdin, &peek, 1, &peekRecordsRead) == 0) { + printError("f_code.c: PeekConsoleInput failed"); + } + if (FlushConsoleInputBuffer(hstdin) == 0) { + printError("f_code.c: FlushConsoleInputBuffer failed"); + + } + + if (peekRecordsRead && (peek.EventType & KEY_EVENT)) { + /* fprintf(stderr, "f_code.c: c_connect_sensor_to_return_key(): peekRecordsRead: %d, GetLastError(): %d\n", peekRecordsRead, GetLastError()); + fflush(stderr); + */ + + *sensor = peekRecordsRead; + } else { + *sensor = 0; + } + + #else ioctl(0,FIONREAD,&c); if(c) read(0,&s,1); *sensor=c; + #endif } void c_connect_sensor_to_random_generator(c_int *sensor) { *************** *** 146,173 **** return (current_time == (initial_time + relative_time) % get_time_overflow()); } - - - - - - - - - - - - - - - - - - - - - - - - - --- 190,192 ---- diff -N -r -c giottoc/examples/fcode/f_code.h giottoc-mingw32/examples/fcode/f_code.h *** giottoc/examples/fcode/f_code.h Thu Oct 4 12:51:40 2001 --- giottoc-mingw32/examples/fcode/f_code.h Wed Nov 14 23:24:18 2001 *************** *** 35,41 **** --- 35,44 ---- #include #include + + #ifndef __MINGW32__ #include + #endif #include "f_table.h" #include "f_spec.h" diff -N -r -c giottoc/makefile giottoc-mingw32/makefile *** giottoc/makefile Sat Oct 6 11:52:37 2001 --- giottoc-mingw32/makefile Thu Nov 15 07:49:17 2001 *************** *** 44,53 **** EMACHINE := ./e_machine ########################################################################## # CLASSPATH ! CLASSPATH := $(CLASSPATH):../ ########################################################################## # JAVABINPATH --- 44,65 ---- EMACHINE := ./e_machine + # Makefile variables for Linux + CLASSPATHSEPARATOR =: + PTHREADSDIR := + PTHREADSINCLUDEDIRECTIVE := + PTHREADSLIBDIRECTIVE := -lpthread + + # Makefile variables for Mingw32 under Windows + PTHREADSDIR := /users/cxh/src/pthreads + PTHREADSINCLUDEDIRECTIVE := -I$(PTHREADSDIR) + PTHREADSLIBDIRECTIVE := -L$(PTHREADSDIR) -lpthreadGC -lwsock32 + CLASSPATHSEPARATOR := ; + ########################################################################## # CLASSPATH ! CLASSPATH := "$(CLASSPATH)$(CLASSPATHSEPARATOR).." ########################################################################## # JAVABINPATH *************** *** 63,70 **** ########################################################################## ! CFLAGS := -I$(EMACHINEPATH) -I$(FTABLEPATH) -I$(FCODEPATH) -I$(ECODEPATH) -DDEBUG ! LDFLAGS := -lpthread -lm ########################################################################## # Get all .c files and replace .c suffix by .o --- 75,83 ---- ########################################################################## ! CFLAGS := $(PTHREADSINCLUDEDIRECTIVE) -I$(EMACHINEPATH) -I$(FTABLEPATH) -I$(FCODEPATH) -I$(ECODEPATH) -DDEBUG ! LDFLAGS := $(PTHREADSLIBDIRECTIVE) -lm ! ########################################################################## # Get all .c files and replace .c suffix by .o *************** *** 152,158 **** $(JVM) -classpath $(CLASSPATH) giottoc.GiottoC $(EXAMPLE) %.o : %.c $(EMACHINEHEADERS) $(FTABLEHEADERS) $(FCODEHEADERS) $(ECODEHEADERS) ! $(CC) -c $(CFLAGS) $< -o $@ $(EMACHINE): $(EMACHINEBINARIES) $(FTABLEBINARIES) $(FCODEBINARIES) $(ECODEBINARIES) ! $(CC) $(LDFLAGS) $^ -o $@ --- 165,172 ---- $(JVM) -classpath $(CLASSPATH) giottoc.GiottoC $(EXAMPLE) %.o : %.c $(EMACHINEHEADERS) $(FTABLEHEADERS) $(FCODEHEADERS) $(ECODEHEADERS) ! $(CC) -g -c $(CFLAGS) $< -o $@ $(EMACHINE): $(EMACHINEBINARIES) $(FTABLEBINARIES) $(FCODEBINARIES) $(ECODEBINARIES) ! $(CC) $^ -o $@ $(LDFLAGS) !