Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit 4992bfa

Browse files
authored
Merge pull request #2044 from MartinNowak/merge_stable
Merge remote-tracking branch 'upstream/stable' into merge_stable merged-on-behalf-of: Sebastian Wilzbach <sebi.wilzbach@gmail.com>
2 parents c5b2777 + 7111dca commit 4992bfa

File tree

5 files changed

+41
-11
lines changed

5 files changed

+41
-11
lines changed

posix.mak

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ UT_MODULES:=$(patsubst src/%.d,$(ROOT)/unittest/%,$(SRCS))
229229
HAS_ADDITIONAL_TESTS:=$(shell test -d test && echo 1)
230230
ifeq ($(HAS_ADDITIONAL_TESTS),1)
231231
ADDITIONAL_TESTS:=test/init_fini test/exceptions test/coverage test/profile test/cycles test/allocations test/typeinfo \
232-
test/thread test/unittest
232+
test/thread test/unittest test/imports
233233
ADDITIONAL_TESTS+=$(if $(SHARED),test/shared,)
234234
endif
235235

@@ -239,7 +239,7 @@ unittest : $(UT_MODULES) $(addsuffix /.run,$(ADDITIONAL_TESTS))
239239
@echo done
240240
else
241241
unittest : unittest-debug unittest-release
242-
unittest-%:
242+
unittest-%: target
243243
$(MAKE) -f $(MAKEFILE) unittest OS=$(OS) MODEL=$(MODEL) DMD=$(DMD) BUILD=$*
244244
endif
245245

src/core/runtime.d

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -650,13 +650,18 @@ extern (C) UnitTestResult runModuleUnitTests()
650650
}
651651
}
652652
}
653-
import rt.config : rt_configOption;
653+
654+
import core.internal.traits : externDFunc;
655+
alias rt_configCallBack = string delegate(string) @nogc nothrow;
656+
alias fn_configOption = string function(string opt, scope rt_configCallBack dg, bool reverse) @nogc nothrow;
657+
alias rt_configOption = externDFunc!("rt.config.rt_configOption", fn_configOption);
658+
654659
if (results.passed != results.executed)
655660
{
656661
// by default, we always print a summary if there are failures.
657662
results.summarize = true;
658663
}
659-
else switch (rt_configOption("testmode"))
664+
else switch (rt_configOption("testmode", null, false))
660665
{
661666
case "":
662667
// By default, run main. Switch to only doing unit tests in 2.080
@@ -674,7 +679,7 @@ extern (C) UnitTestResult runModuleUnitTests()
674679
results.summarize = !results.runMain;
675680
break;
676681
default:
677-
throw new Error("Unknown --DRT-testmode option: " ~ rt_configOption("testmode"));
682+
throw new Error("Unknown --DRT-testmode option: " ~ rt_configOption("testmode", null, false));
678683
}
679684

680685
return results;

src/core/thread.d

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,6 @@ else version( Posix )
304304
{
305305
version (Shared)
306306
{
307-
import rt.sections;
308307
Thread obj = cast(Thread)(cast(void**)arg)[0];
309308
auto loadedLibraries = (cast(void**)arg)[1];
310309
.free(arg);
@@ -317,7 +316,11 @@ else version( Posix )
317316

318317
// loadedLibraries need to be inherited from parent thread
319318
// before initilizing GC for TLS (rt_tlsgc_init)
320-
version (Shared) inheritLoadedLibraries(loadedLibraries);
319+
version (Shared)
320+
{
321+
externDFunc!("rt.sections_elf_shared.inheritLoadedLibraries",
322+
void function(void*) @nogc nothrow)(loadedLibraries);
323+
}
321324

322325
assert( obj.m_curr is &obj.m_main );
323326
obj.m_main.bstack = getStackBottom();
@@ -404,7 +407,11 @@ else version( Posix )
404407
append( t );
405408
}
406409
rt_moduleTlsDtor();
407-
version (Shared) cleanupLoadedLibraries();
410+
version (Shared)
411+
{
412+
externDFunc!("rt.sections_elf_shared.cleanupLoadedLibraries",
413+
void function() @nogc nothrow)();
414+
}
408415
}
409416
catch( Throwable t )
410417
{
@@ -712,15 +719,17 @@ class Thread
712719

713720
version (Shared)
714721
{
715-
import rt.sections;
716-
auto libs = pinLoadedLibraries();
722+
auto libs = externDFunc!("rt.sections_elf_shared.pinLoadedLibraries",
723+
void* function() @nogc nothrow)();
724+
717725
auto ps = cast(void**).malloc(2 * size_t.sizeof);
718726
if (ps is null) onOutOfMemoryError();
719727
ps[0] = cast(void*)this;
720728
ps[1] = cast(void*)libs;
721729
if( pthread_create( &m_addr, &attr, &thread_entryPoint, ps ) != 0 )
722730
{
723-
unpinLoadedLibraries(libs);
731+
externDFunc!("rt.sections_elf_shared.unpinLoadedLibraries",
732+
void function(void*) @nogc nothrow)(libs);
724733
.free(ps);
725734
onThreadError( "Error creating thread" );
726735
}

test/imports/Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
include ../common.mak
2+
3+
TESTS:=bug18193
4+
5+
.PHONY: all clean
6+
all: $(addprefix $(ROOT)/,$(addsuffix .done,$(TESTS)))
7+
8+
$(ROOT)/%.done:
9+
@echo Testing $*
10+
@mkdir -p $(basename $@)
11+
$(QUIET)$(DMD) -version=Shared -o- -deps=$@ -Isrc -I../../import src/$*
12+
13+
clean:
14+
rm -rf $(GENERATED)

test/imports/src/bug18193.d

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import core.runtime;
2+
import core.thread;

0 commit comments

Comments
 (0)