]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/tools/build/src/engine/boehm_gc/doc/README.darwin
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / tools / build / src / engine / boehm_gc / doc / README.darwin
CommitLineData
7c673cae
FG
1Darwin/MacOSX Support - December 16, 2003
2=========================================
3
4Important Usage Notes
5=====================
6
7GC_init() MUST be called before calling any other GC functions. This
8is necessary to properly register segments in dynamic libraries. This
9call is required even if you code does not use dynamic libraries as the
10dyld code handles registering all data segments.
11
12When your use of the garbage collector is confined to dylibs and you
13cannot call GC_init() before your libraries' static initializers have
14run and perhaps called GC_malloc(), create an initialization routine
15for each library to call GC_init():
16
17#include <gc/gc.h>
18extern "C" void my_library_init() { GC_init(); }
19
20Compile this code into a my_library_init.o, and link it into your
21dylib. When you link the dylib, pass the -init argument with
22_my_library_init (e.g. gcc -dynamiclib -o my_library.dylib a.o b.o c.o
23my_library_init.o -init _my_library_init). This causes
24my_library_init() to be called before any static initializers, and
25will initialize the garbage collector properly.
26
27Note: It doesn't hurt to call GC_init() more than once, so it's best,
28if you have an application or set of libraries that all use the
29garbage collector, to create an initialization routine for each of
30them that calls GC_init(). Better safe than sorry.
31
32The incremental collector is still a bit flaky on darwin. It seems to
33work reliably with workarounds for a few possible bugs in place however
34these workaround may not work correctly in all cases. There may also
35be additional problems that I have not found.
36
37Thread-local GC allocation will not work with threads that are not
38created using the GC-provided override of pthread_create(). Threads
39created without the GC-provided pthread_create() do not have the
40necessary data structures in the GC to store this data.
41
42
43Implementation Information
44==========================
45Darwin/MacOSX support is nearly complete. Thread support is reliable on
46Darwin 6.x (MacOSX 10.2) and there have been reports of success on older
47Darwin versions (MacOSX 10.1). Shared library support had also been
48added and the gc can be run from a shared library. There is currently only
49support for Darwin/PPC although adding x86 support should be trivial.
50
51Thread support is implemented in terms of mach thread_suspend and
52thread_resume calls. These provide a very clean interface to thread
53suspension. This implementation doesn't rely on pthread_kill so the
54code works on Darwin < 6.0 (MacOSX 10.1). All the code to stop and
55start the world is located in darwin_stop_world.c.
56
57Since not all uses of the GC enable clients to override pthread_create()
58before threads have been created, the code for stopping the world has
59been rewritten to look for threads using Mach kernel calls. Each
60thread identified in this way is suspended and resumed as above. In
61addition, since Mach kernel threads do not contain pointers to their
62stacks, a stack-walking function has been written to find the stack
63limits. Given an initial stack pointer (for the current thread, a
64pointer to a stack-allocated local variable will do; for a non-active
65thread, we grab the value of register 1 (on PowerPC)), it
66will walk the PPC Mach-O-ABI compliant stack chain until it reaches the
67top of the stack. This appears to work correctly for GCC-compiled C,
68C++, Objective-C, and Objective-C++ code, as well as for Java
69programs that use JNI. If you run code that does not follow the stack
70layout or stack pointer conventions laid out in the PPC Mach-O ABI,
71then this will likely crash the garbage collector.
72
73The original incremental collector support unfortunatelly no longer works
74on recent Darwin versions. It also relied on some undocumented kernel
75structures. Mach, however, does have a very clean interface to exception
76handing. The current implementation uses Mach's exception handling.
77
78Much thanks goes to Andrew Stone, Dietmar Planitzer, Andrew Begel,
79Jeff Sturm, and Jesse Rosenstock for all their work on the
80Darwin/OS X port.
81
82-Brian Alliet
83brian@brianweb.net
84
85gc_cpp.h usage
86==============
87
88Replacement of operator new and delete is apparently not supported with
89dynamic libraries. This means that applications using gc_cpp.h
90(including the built-in test) will probably not work correctly with
91the collector in a dynamic library, unless special care is taken.
92
93See
94http://article.gmane.org/gmane.comp.programming.garbage-collection.boehmgc/1421
95for some details.
96
97- Hans Boehm (based on information from Andrew Begel)
98
99
100Older Information (Most of this no longer applies to the current code)
101======================================================================
102
103While the GC should work on MacOS X Server, MacOS X and Darwin, I only tested
104it on MacOS X Server.
105I've added a PPC assembly version of GC_push_regs(), thus the setjmp() hack is
106no longer necessary. Incremental collection is supported via mprotect/signal.
107The current solution isn't really optimal because the signal handler must decode
108the faulting PPC machine instruction in order to find the correct heap address.
109Further, it must poke around in the register state which the kernel saved away
110in some obscure register state structure before it calls the signal handler -
111needless to say the layout of this structure is no where documented.
112Threads and dynamic libraries are not yet supported (adding dynamic library
113support via the low-level dyld API shouldn't be that hard).
114
115The original MacOS X port was brought to you by Andrew Stone.
116
117
118June, 1 2000
119
120Dietmar Planitzer
121dave.pl@ping.at
122
123Note from Andrew Begel:
124
125One more fix to enable gc.a to link successfully into a shared library for
126MacOS X. You have to add -fno-common to the CFLAGS in the Makefile. MacOSX
127disallows common symbols in anything that eventually finds its way into a
128shared library. (I don't completely understand why, but -fno-common seems to
129work and doesn't mess up the garbage collector's functionality).
130
131Feb 26, 2003
132
133Jeff Sturm and Jesse Rosenstock provided a patch that adds thread support.
134GC_MACOSX_THREADS should be defined in the build and in clients. Real
135dynamic library support is still missing, i.e. dynamic library data segments
136are still not scanned. Code that stores pointers to the garbage collected
137heap in statically allocated variables should not reside in a dynamic
138library. This still doesn't appear to be 100% reliable.
139
140Mar 10, 2003
141Brian Alliet contributed dynamic library support for MacOSX. It could also
142use more testing.