📄 readme.win32
字号:
The collector has at various times been compiled under Windows 95 & later, NT,and XP, with the original Microsoft SDK, with Visual C++ 2.0, 4.0, and 6, withthe GNU win32 tools, with Borland 4.5, with Watcom C, and recentlywith the Digital Mars compiler. It is likely that some of these have beenbroken in the meantime. Patches are appreciated.For historical reasons,the collector test program "gctest" is linked as a GUI application,but does not open any windows. Its output normally appears in the file"gctest.exe.log". It may be started from the file manager. The hour glasscursor may appear as long as it's running. If it is started from thecommand line, it will usually run in the background. Wait a fewminutes (a few seconds on a modern machine) before you check the output.You should see either a failure indication or a "Collector appears towork" message.The cord test program has not been ported (but should porteasily). A toy editor (cord/de.exe) based on cords (heavyweightstrings represented as trees) has been ported and is included.It runs fine under either win32 or win32S. It serves as an exampleof a true Windows application, except that it was written by anonexpert Windows programmer. (There are some peculiaritiesin the way files are displayed. The <cr> is displayed explicitlyfor standard DOS text files. As in the UNIX version, controlcharacters are displayed explicitly, but in this case as red text.This may be suboptimal for some tastes and/or sets of defaultwindow colors.)In general -DREDIRECT_MALLOC is unlikely to work unless theapplication is completely statically linked.The collector normally allocates memory from the OS with VirtualAlloc.This appears to cause problems under Windows NT and Windows 2000 (butnot Windows 95/98) if the memory is later passed to CreateDIBitmap.To work around this problem, build the collector with -DUSE_GLOBAL_ALLOC.This is currently incompatible with -DUSE_MUNMAP. (Thanks to JonathanClark for tracking this down. There's some chance this may be fixedin 6.1alpha4, since we now separate heap sections with an unused page.)[Threads and incremental collection are discussed near the end, below.]Microsoft Tools---------------For Microsoft development tools, rename NT_MAKEFILE asMAKEFILE. (Make sure that the CPU environment variable is definedto be i386.) In order to use the gc_cpp.h C++ interface, allclient code should include gc_cpp.h.For historical reasons,the collector test program "gctest" is linked as a GUI application,but does not open any windows. Its output appears in the file"gc.log". It may be started from the file manager. The hour glasscursor may appear as long as it's running. If it is started from thecommand line, it will usually run in the background. Wait a fewminutes (a few seconds on a modern machine) before you check the output.You should see either a failure indication or a "Collector appears towork" message.If you would prefer a VC++.NET project file, ask boehm@acm.org. One hasbeen contributed, but it seems to contain some absolute paths etc., soit can presumably only be a starting point, and is not in the standarddistribution. It is unclear (to me, Hans Boehm) whether it is feasible tochange that.Clients may need to define GC_NOT_DLL before including gc.h, if thecollector was built as a static library (as it normally is in theabsence of thread support).GNU Tools---------The collector should be buildable under Cygwin with either the old standardMakefile, or possibly with the "configure --diable-shared;make" machinery.(For the latter use --enable-threads=posix for thread support.) The major issuehere seems to be that dynamic library support is not currently enabled forCygwin. (This is probably fixable without a great deal of difficulty byreusing the standard WIN32 code. But it requires some tweaking.) As a resultof this, "configure; make; make check" currently does not completely succeed,though the static library appears to be OK when used only from the mainprograms, and correspondingly the Makefile.direct self tests succeed.Mingw32 builds are not regularly tested, and may or may not work.The following paragraph is probably obsolete:For GNU-win32, use the regular makefile, possibly after uncommentingthe line "include Makefile.DLLs". The latter should be necessary onlyif you want to package the collector as a DLL.[Is the following sentence obsolete? -HB] The GNU-win32 port isbelieved to work only for b18, not b19, probably due to linker changesin b19. This is probably fixable with a different definition ofDATASTART and DATAEND in gcconfig.h.Borland Tools-------------[Rarely tested.]For Borland tools, use BCC_MAKEFILE. Note thatBorland's compiler defaults to 1 byte alignment in structures (-a1),whereas Visual C++ appears to default to 8 byte alignment (/Zp8).The garbage collector in its default configuration EXPECTS ATLEAST 4 BYTE ALIGNMENT. Thus the BORLAND DEFAULT MUSTBE OVERRIDDEN. (In my opinion, it should usually be anyway.I expect that -a1 introduces major performance penalties on a486 or Pentium.) Note that this changes structure layouts. (As a lastresort, gcconfig.h can be changed to allow 1 byte alignment. Butthis has significant negative performance implications.)The Makefile is set up to assume Borland 4.5. If you have anotherversion, change the line near the top. By default, it does notrequire the assembler. If you do have the assembler, I recommendremoving the -DUSE_GENERIC.Watcom compiler---------------Ivan V. Demakov's README for the Watcom port:The collector has been compiled with Watcom C 10.6 and 11.0.It runs under win32, win32s, and even under msdos with dos4gwdos-extender. It should also run under OS/2, though this isn'ttested. Under win32 the collector can be built either as dllor as static library.Note that all compilations were done under Windows 95 or NT.For unknown reason compiling under Windows 3.11 for NT (oneattempt has been made) leads to broken executables.Incremental collection is not supported.cord is not ported.Before compiling you may need to edit WCC_MAKEFILE to set targetplatform, library type (dynamic or static), calling conventions, andoptimization options.To compile the collector and testing programs use the command: wmake -f WCC_MAKEFILEAll programs using gc should be compiled with 4-byte alignment.For further explanations on this see comments about Borland.If the gc is compiled as dll, the macro ``GC_DLL'' should be defined beforeincluding "gc.h" (for example, with -DGC_DLL compiler option). It'simportant, otherwise resulting programs will not run.Ivan Demakov (email: ivan@tgrad.nsk.su)Incremental Collection----------------------There is some support for incremental collection. By default, thecollector chooses between explicit page protection, anf GetWriteWatch-basedwrite tracking automatically, depending on the platform.The former is slow and interacts poorly with a debugger.Pages are protected. Protection faults are caught by a handlerinstalled at the bottom of the handlerstack. Whenever possible, I recommend adding a call toGC_enable_incremental at the last possible moment, after mostdebugging is complete. No systemcalls are wrapped by the collector itself. It may be necessaryto wrap ReadFile calls that use a buffer in the heap, so that thecall does not encounter a protection fault while it's running.(As usual, none of this is an issue unless GC_enable_incrementalis called.)Note that incremental collection is disabled with -DSMALL_CONFIG.Threads-------This version of the collector by default handles threads similarlyto other platforms. James Clark's code which tracks threads attachedto the collector DLL still exists, but requires that both- the collector is built in a DLL with GC_DLL defined, and- GC_use_DllMain() is called before GC initialization, which in turn must happen before creating additional threads.We generally recommend avoiding this if possible, since it seems tobe less than 100% reliable.Use NT_THREADS_MAKEFILE (a.k.a gc.mak) instead of NT_MAKEFILEto build a version that supports both kinds of thread tracking.To build the garbage collectortest with VC++ from the command line, usenmake /F ".\gc.mak" CFG="gctest - Win32 Release"This requires that the subdirectory gctest\Release exist.The test program and DLL will reside in the Release directory.This version currently supports incremental collection only if it isenabled before any additional threads are created.Since 6.3alpha2, threads are also better supported in static library buildswith Microsoft tools (use NT_STATIC_THREADS_MAKEFILE) and with the GNUtools. In all cases,the collector must be built with GC_WIN32_THREADSdefined, even if the Cygwin pthreads interface is used.(NT_STATIC_THREADS_MAKEFILE does this implicitly. Under Cygwin,./configure --enable-threads=posix defines GC_WIN32_THREADS.)For the normal, non-dll-based thread tracking to work properly,threads should be created with GC_CreateThread or GC_beginthreadex,and exit normally or call GC_endthreadex or GC_ExitThread. (ForCygwin, use standard pthread calls instead.) As in the pthreadcase, including gc.h will redefine CreateThread, _beginthreadex,_endthreadex, and ExitThread to call the GC_ versions instead.Note that, as usual, GC_CreateThread tends to introduce resource leaksthat are avoided by GC_beginthreadex. There is currently no equivalent of_beginthread, and it should not be used.GC_INIT should be called from the main executable before other GC calls.We strongly advise against using the TerminateThread() win32 API call,especially with the garbage collector. Any use is likely to provoke acrash in the GC, since it makes it impossible for the collector tocorrectly track threads.To build the collector for Mingw32 Pthreads, use Makefile.direct andexplicitly set GC_WIN32_PTHREADS. Use -DPTW32_STATIC_LIB for the staticthreads library. Note that the DEBUG_WIN32_PTHREADS support inwin32_threads.c is currently broken and looking for someone to debug it.(This information and the port came from Romano Paolo Tenca).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -