Shouldn't all those IORefs (e.g., for the list of windows) be MVars in the GHC version?
We did that for the X11 version - I guess the Win32 version has fallen behind. What really needs done though is to introduce a single semaphore to control all access to all parts of the HGL data structures - atomically accessing each part of the data structures doesn't necessarily protect all the system invariants.
For a start, what about NoInline pragmas for global IORefs?
Yes, that should be done. (Hmmm, maybe we should push harder on a portable language extension for defining global, mutable, monomorphic IORefs.)
Unless there are any other suggestions, I could give the green card --safe-code a try. But why doesn't the green card input use %safecode to eliminate that potential error source?-)
Because I wrote the Win32 bindings for Hugs where %safecode and %code mean the same thing. Really, GreenCard should be changed so that %code is safe by default and you have to write %unsafecode to get the faster version. (That's the way it is in the ffi.)
And how would cross-ffi garbage-collection issues affect window parameters at startup?
Not sure what you mean - I can't think of any new issues in GC which aren't present in Hugs.
Anyway, is there a useable win32 green card input package hanging around somewhere (the link to glasgow is dead it seems; CVS has moved the gc-sources aside and has never been very modular - is there a way for me to take the win32/gc-src/ directory from CVS and make it, without having to prepare the various other parts of fptools that fptools-Makefiles tend to depend on so merrily?-(.
I'm attaching a crudely hacked up version of hugs.mk which generates the necessary .hs files. To invoke it: cd hslibs/win32 rm *.hs *stub* make -f hugs.mk GC="green-card --target=ghc" GCDIR=../../green-card GC_INCLUDES="--include-dir ../../green-card/lib/ghc" gen_hss -k It will fail when building Win32Dialogue.hs hence the use of -k. I looked at this just long enough to persuade myself that there was no easy fix (apart from deleting gc-src/Win32Dialogue.gc) but that the error was harmless (Win32.hs doesn't import Win32Dialogue). I could have changed the file further to set the target and greencard directories more quietly - but maybe you want to change the target (ffi?) or use a different greencard so it seemed easier to specify them on the command line. I have not tried compiling the generated files - my windows machine isn't used to being used for development and needs a bit of sweet-talking before it's willing to contemplate the idea. You'll need a different Makefile to compile the generated files - the compilation stuff that's there at the moment is for use with Hugs/GreenCard not GHC/FFI or GHC/GreenCard. -- Alastair Reid alastair@reid-consulting-uk.ltd.uk http://www.reid-consulting-uk.ltd.uk/alastair/ ################################################################ # Makefile for Win32 library # # This Makefile only works with GNUMake. If you feel like supplying # us with a more portable Makefile, we'll be happy to distribute it # as well. ################################################################ # This goes first to make it the default default : all # All generated C files #include errors.h to get consistent error messages $(DLLS) : errors.h GUILIBS = kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib comctl32.lib winmm.lib advapi32.lib # Describe how your system is configured here ROOT = $(HOME) HUGSDIR = $(ROOT)/hugs GCDIR = $(ROOT)/fptools/green-card RUNHUGS = $(ROOT)/hugs/runhugs CPP = gcc -P -E -x c -traditional # GC = $(ROOT)/green-card.exe --target Hugs GC = $(RUNHUGS) -F"$(CPP)" -h1m $(GCDIR)/src/GreenCard.lhs --target Hugs GC_INCLUDES = --include-dir $(GCDIR)/lib/hugs GCPP_FLAGS = -DTARGET_HUGS # Where to find GreenCard.h - in the Hugs source code INCLUDES = -i $(HUGSDIR)/src ################################################################ # Explicit dependencies ################################################################ Win32Window.dll: WndProc.c ################################################################ # Standard rules from here on ################################################################ RAW_GCS = $(wildcard gc-src/*.gc) GCS = $(notdir $(RAW_GCS)) DLLS = $(addsuffix .dll, $(basename $(GCS))) GEN_HSS = $(addsuffix .hs, $(basename $(GCS))) GEN_CFILES = $(addsuffix .c, $(basename $(GCS))) gen_hss: $(GCS) $(GEN_HSS) all: gen_hss $(DLLS) .SUFFIXES : .SUFFIXES : .pgc .gc .hs .dll .c %.gc : gc-src/%.gc $(CPP) $(GCPP_FLAGS) $< | perl -pe 's#\\n#\n#g' >$*.gc %.hs %.c : %.gc $(CPP) $(GCPP_FLAGS) $< | perl -pe 's#\\n#\n#g' >$*.gc $(GC) $(GC_INCLUDES) -i . $*.gc %.dll : %.c cl /nologo /LD /MD $(INCLUDES) $(GUILIBS) $(GCPP_FLAGS) -DSTRICT -o $@ $*.c %.obj : %.c cl /nologo $(INCLUDES) $(GCPP_FLAGS) -DSTRICT -o $@ $*.c # Cleanliness is next to dependencies clean : rm -f *.obj *.exp *.lib rm -f *.hi rm -f $(GEN_CFILES) $(GEN_HSS) $(DLLS) # Dependencies $(GCS) : $(PGCS) depends.mk :: perl mkGCDep *.gc >depends.mk include depends.mk ################################################################ # End of Makefile ################################################################