extern (C) void gc_removeRoot( void* p );
extern (C) void gc_removeRange( void* p );
+
+ extern (C) void* gc_getHandle();
+ extern (C) void gc_setHandle( void* p );
+ extern (C) void gc_endHandle();
}
{
gc_removeRange( p );
}
+
+ /**
+ * Get handle to the collector.
+ * The only thing that can be done with this handle is pass it to
+ * setHandle(). getHandle/setHandle/endHandle work together so that
+ * if there are multiple instances of the gc running, only one instance
+ * can be set to run.
+ * The most common case of this is under Windows where a D application
+ * calls functions in a DLL that is implemented in D.
+ */
+
+ static void* getHandle()
+ {
+ return gc_getHandle();
+ }
+
+ /**
+ * Set handle to the collector.
+ * The handle p is an opaque handle, acquired by a call to
+ * getHandle().
+ */
+
+ static void setHandle(void* p)
+ {
+ gc_setHandle(p);
+ }
+
+ /**
+ * Call when done using the collector specified by the
+ * call to setHandle().
+ */
+
+ static void endHandle()
+ {
+ gc_endHandle();
+ }
}
CFLAGS=-O $(ADD_CFLAGS)\r
#CFLAGS=-g $(ADD_CFLAGS)\r
\r
-DFLAGS=-release -O -inline -w -nofloat -version=Posix $(ADD_DFLAGS)\r
-#DFLAGS=-g -w -nofloat -version=Posix $(ADD_DFLAGS)\r
+DFLAGS=-release -O -inline -w -nofloat $(ADD_DFLAGS)\r
+#DFLAGS=-g -w -nofloat $(ADD_DFLAGS)\r
\r
-TFLAGS=-O -inline -w -nofloat -version=Posix $(ADD_DFLAGS)\r
-#TFLAGS=-g -w -nofloat -version=Posix $(ADD_DFLAGS)\r
+TFLAGS=-O -inline -w -nofloat $(ADD_DFLAGS)\r
+#TFLAGS=-g -w -nofloat $(ADD_DFLAGS)\r
\r
-DOCFLAGS=-version=DDoc -version=Posix\r
+DOCFLAGS=-version=DDoc\r
\r
CC=gcc\r
LC=$(AR) -qsv\r
*
*/
extern (C) void rt_scanStaticData( scanFn scan )
+{
+ scan(rt_staticDataBottom(), rt_staticDataTop());
+}
+
+/**
+ *
+ */
+extern (C) void* rt_staticDataBottom()
+{
+ version( Windows )
+ {
+ return &_xi_a;
+ }
+ else version( linux )
+ {
+ return &__data_start;
+ }
+ else
+ {
+ static assert( false, "Operating system not supported." );
+ }
+}
+
+/**
+ *
+ */
+extern (C) void* rt_staticDataTop()
{
version( Windows )
{
- scan( &_xi_a, &_end );
+ return &_end;
}
else version( linux )
{
- scan( &__data_start, &_end );
+ return &_end;
}
else
{
static assert( false, "Operating system not supported." );
}
}
+
+
CFLAGS=-O $(ADD_CFLAGS)
#CFLAGS=-g $(ADD_CFLAGS)
-DFLAGS=-release -O -inline -w -nofloat -version=Posix $(ADD_DFLAGS)
-#DFLAGS=-g -w -nofloat -version=Posix $(ADD_DFLAGS)
+DFLAGS=-release -O -inline -w -nofloat $(ADD_DFLAGS)
+#DFLAGS=-g -w -nofloat $(ADD_DFLAGS)
-TFLAGS=-O -inline -w -nofloat -version=Posix $(ADD_DFLAGS)
-#TFLAGS=-g -w -nofloat -version=Posix $(ADD_DFLAGS)
+TFLAGS=-O -inline -w -nofloat $(ADD_DFLAGS)
+#TFLAGS=-g -w -nofloat $(ADD_DFLAGS)
-DOCFLAGS=-version=DDoc -version=Posix
+DOCFLAGS=-version=DDoc
CC=gcc
LC=$(AR) -qsv
{
_gc.removeRange( p );
}
+
+extern (C) void* gc_getHandle()
+{
+ return cast(void*)_gc;
+}
+
+extern (C) void gc_setHandle(void* p)
+{
+ void* oldp = gc_getHandle();
+ gc_t g = cast(gc_t)p;
+ if (g.gcversion != gcx.GCVERSION)
+ throw new Error("incompatible gc versions");
+
+ // Add our static data to the new gc
+ GC.scanStaticData(g);
+
+ _gc = g;
+}
+
+extern (C) void gc_endHandle()
+{
+ GC.unscanStaticData(_gc);
+}
extern (C) void* rt_stackBottom();
extern (C) void* rt_stackTop();
+ extern (C) void* rt_staticDataBottom();
+ extern (C) void* rt_staticDataTop();
extern (C) void rt_finalize( void* p, bool det = true );
}
+ static void scanStaticData(gc_t g)
+ {
+ //debug(PRINTF) printf("+GC.scanStaticData()\n");
+ auto pbot = rt_staticDataBottom();
+ auto ptop = rt_staticDataTop();
+ g.addRange(pbot, ptop - pbot);
+ //debug(PRINTF) printf("-GC.scanStaticData()\n");
+ }
+
+ static void unscanStaticData(gc_t g)
+ {
+ auto pbot = rt_staticDataBottom();
+ g.removeRange(pbot);
+ }
+
/**
* add p to list of roots
*/
CFLAGS=-O $(ADD_CFLAGS)
#CFLAGS=-g $(ADD_CFLAGS)
-DFLAGS=-release -O -inline -w -nofloat -version=Posix $(ADD_DFLAGS)
-#DFLAGS=-g -w -nofloat -version=Posix $(ADD_DFLAGS)
+DFLAGS=-release -O -inline -w -nofloat $(ADD_DFLAGS)
+#DFLAGS=-g -w -nofloat $(ADD_DFLAGS)
-TFLAGS=-O -inline -w -nofloat -version=Posix $(ADD_DFLAGS)
-#TFLAGS=-g -w -nofloat -version=Posix $(ADD_DFLAGS)
+TFLAGS=-O -inline -w -nofloat $(ADD_DFLAGS)
+#TFLAGS=-g -w -nofloat $(ADD_DFLAGS)
-DOCFLAGS=-version=DDoc -version=Posix
+DOCFLAGS=-version=DDoc
CC=gcc
LC=$(AR) -qsv
{
}
+
+extern (C) void* gc_getHandle()
+{
+ return null;
+}
+
+extern (C) void gc_setHandle(void* p)
+{
+}
+
+extern (C) void gc_endHandle()
+{
+}
+
### warnings disabled because gcx has issues ###
-DFLAGS=-release -O -inline -version=Posix $(ADD_DFLAGS)
-#DFLAGS=-g -version=Posix $(ADD_DFLAGS)
+DFLAGS=-release -O -inline $(ADD_DFLAGS)
+#DFLAGS=-g $(ADD_DFLAGS)
-TFLAGS=-O -inline -version=Posix $(ADD_DFLAGS)
-#TFLAGS=-g -version=Posix $(ADD_DFLAGS)
+TFLAGS=-O -inline $(ADD_DFLAGS)
+#TFLAGS=-g $(ADD_DFLAGS)
-DOCFLAGS=-version=DDoc -version=Posix
+DOCFLAGS=-version=DDoc
CC=gcc
LC=$(AR) -qsv