This repository was archived by the owner on Oct 12, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 7 files changed +40
-34
lines changed
Expand file tree Collapse file tree 7 files changed +40
-34
lines changed Original file line number Diff line number Diff line change 1313 */
1414module gc.proxy ;
1515
16- import gc.impl.conservative.gc;
17- import gc.impl.manual.gc;
1816import gc.impl.proto.gc;
1917import gc.config;
2018import gc.gcinterface;
@@ -37,11 +35,27 @@ private
3735
3836extern (C )
3937{
38+ // do not import GC modules, they might add a dependency to this whole module
39+ void _d_register_conservative_gc ();
40+ void _d_register_manual_gc ();
41+
42+ // if you don't want to include the default GCs, replace during link by another implementation
43+ void * register_default_gcs ()
44+ {
45+ pragma (inline, false );
46+ // do not call, they register implicitly through pragma(crt_constructor)
47+ // avoid being optimized away
48+ auto reg1 = &_d_register_conservative_gc;
49+ auto reg2 = &_d_register_manual_gc;
50+ return reg1 < reg2 ? reg1 : reg2;
51+ }
52+
4053 void gc_init ()
4154 {
4255 instanceLock.lock();
4356 if (! isInstanceInit)
4457 {
58+ register_default_gcs();
4559 config.initialize();
4660 auto protoInstance = instance;
4761 auto newInstance = createGCInstance(config.gc);
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -10,12 +10,8 @@ $(ROOT)/%.done: $(ROOT)/%
1010 $(QUIET )$(TIMELIMIT )$(ROOT ) /$* $(RUN_ARGS )
1111 @touch $@
1212
13- $(ROOT ) /custom_gc : $(ROOT ) /register_custom_gc.o
1413$(ROOT ) /% : $(SRC ) /% .d
15- $(QUIET )$(DMD ) $(DFLAGS ) -of$@ $^
16-
17- $(ROOT ) /register_custom_gc.o : $(SRC ) /register_custom_gc.c
18- $(QUIET )$(CC ) -c $(CFLAGS ) -o $@ $^
14+ $(QUIET )$(DMD ) $(DFLAGS ) -of$@ $<
1915
2016clean :
2117 rm -rf $(ROOT )
Original file line number Diff line number Diff line change @@ -6,11 +6,16 @@ static import core.memory;
66
77extern (C ) __gshared string [] rt_options = [" gcopt=gc:malloc" ];
88
9- extern (C ) void register_mygc()
9+ extern (C ) pragma (crt_constructor) void register_mygc()
1010{
1111 registerGCFactory(" malloc" , &MallocGC.initialize);
1212}
1313
14+ extern (C ) void register_default_gcs()
15+ {
16+ // remove default GCs
17+ }
18+
1419/* * Simple GC that requires any pointers passed to it's API
1520 to point to start of the allocation.
1621 */
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ # built from the druntime top-level folder
2+ # to be overwritten by caller
3+ DMD =dmd
4+ MODEL =64
5+ DRUNTIMELIB =druntime64.lib
6+
7+ test : custom_gc
8+
9+ custom_gc :
10+ $(DMD ) -m$(MODEL ) -conf= -Isrc -defaultlib=$(DRUNTIMELIB ) test\i nit_fini\s rc\c ustom_gc.d
11+ custom_gc.exe
12+ del custom_gc.exe custom_gc.obj
13+
Original file line number Diff line number Diff line change @@ -105,7 +105,10 @@ test_hash:
105105test_stdcpp :
106106 $(MAKE ) -f test\s tdcpp\w in64.mak " DMD=$( DMD) " MODEL=$(MODEL ) " VCDIR=$( VCDIR) " DRUNTIMELIB=$(DRUNTIME ) " CC=$( CC) " test
107107
108- test_all : test_uuid test_aa test_hash test_stdcpp
108+ custom_gc :
109+ $(MAKE ) -f test\i nit_fini\w in64.mak " DMD=$( DMD) " MODEL=$(MODEL ) " VCDIR=$( VCDIR) " DRUNTIMELIB=$(DRUNTIME ) " CC=$( CC) " test
110+
111+ test_all : test_uuid test_aa test_hash test_stdcpp custom_gc
109112
110113# ################## zip/install/clean ##########################
111114
You can’t perform that action at this time.
0 commit comments