diff --git a/.circleci/run.sh b/.circleci/run.sh index eb063fa2cbb..c92c8aec4a7 100755 --- a/.circleci/run.sh +++ b/.circleci/run.sh @@ -2,7 +2,7 @@ set -uexo pipefail -HOST_DMD_VER=2.079.1 +HOST_DMD_VER=2.095.0 CURL_USER_AGENT="CirleCI $(curl --version | head -n 1)" DUB=${DUB:-dub} N=${N:-2} diff --git a/.cirrus.yml b/.cirrus.yml index 81232fd6b33..458c3f04e24 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -39,10 +39,10 @@ linux_task: << : *COMMON_STEPS_TEMPLATE # Mac -mac_task: - name: macOS 10.15 x64 +macos_task: + name: macOS 11.x x64 osx_instance: - image: catalina-xcode + image: big-sur-xcode timeout_in: 60m environment: OS_NAME: darwin diff --git a/std/container/array.d b/std/container/array.d index d74fb1a4b99..63dc86403ec 100644 --- a/std/container/array.d +++ b/std/container/array.d @@ -678,9 +678,9 @@ if (!is(immutable T == immutable bool)) * Complexity: $(BIGOH 1). */ - T[] data() @system + inout(T)[] data() inout @system { - return _data._payload; + return _data.refCountedStore.isInitialized ? _data._payload : []; } /** @@ -2720,9 +2720,19 @@ if (is(immutable T == immutable bool)) @system unittest { + Array!int arr = [1, 2, 4, 5]; int[] data = arr.data(); + const Array!int arr2 = [8, 9]; + assert(arr2.data() == [8, 9]); + data[0] = 0; assert(arr[0] == 0); + + arr.length = 0; + assert(arr.data == []); + + Array!int empty; + assert(empty.data == []); } diff --git a/std/datetime/timezone.d b/std/datetime/timezone.d index 5df42e728c3..052758097a9 100644 --- a/std/datetime/timezone.d +++ b/std/datetime/timezone.d @@ -332,6 +332,7 @@ public: version (Posix) { version (FreeBSD) enum utcZone = "Etc/UTC"; + else version (OpenBSD) enum utcZone = "UTC"; else version (NetBSD) enum utcZone = "UTC"; else version (DragonFlyBSD) enum utcZone = "UTC"; else version (linux) enum utcZone = "UTC"; diff --git a/std/math/algebraic.d b/std/math/algebraic.d index ae7cbf941b4..db70b7a5552 100644 --- a/std/math/algebraic.d +++ b/std/math/algebraic.d @@ -595,6 +595,12 @@ if (isFloatingPoint!T1 && isFloatingPoint!T2) return r; } +version (linux) version = GenericPosixVersion; +else version (FreeBSD) version = GenericPosixVersion; +else version (OpenBSD) version = GenericPosixVersion; +else version (Solaris) version = GenericPosixVersion; +else version (DragonFlyBSD) version = GenericPosixVersion; + private real polyImpl(real x, in real[] A) @trusted pure nothrow @nogc { version (D_InlineAsm_X86) @@ -631,7 +637,7 @@ private real polyImpl(real x, in real[] A) @trusted pure nothrow @nogc return_ST: ; } } - else version (linux) + else version (GenericPosixVersion) { asm pure nothrow @nogc // assembler by W. Bright { @@ -685,87 +691,6 @@ private real polyImpl(real x, in real[] A) @trusted pure nothrow @nogc return_ST: ; } } - else version (FreeBSD) - { - asm pure nothrow @nogc // assembler by W. Bright - { - // EDX = (A.length - 1) * real.sizeof - mov ECX,A[EBP] ; // ECX = A.length - dec ECX ; - lea EDX,[ECX*8] ; - lea EDX,[EDX][ECX*4] ; - add EDX,A+4[EBP] ; - fld real ptr [EDX] ; // ST0 = coeff[ECX] - jecxz return_ST ; - fld x[EBP] ; // ST0 = x - fxch ST(1) ; // ST1 = x, ST0 = r - align 4 ; - L2: fmul ST,ST(1) ; // r *= x - fld real ptr -12[EDX] ; - sub EDX,12 ; // deg-- - faddp ST(1),ST ; - dec ECX ; - jne L2 ; - fxch ST(1) ; // ST1 = r, ST0 = x - fstp ST(0) ; // dump x - align 4 ; - return_ST: ; - } - } - else version (Solaris) - { - asm pure nothrow @nogc // assembler by W. Bright - { - // EDX = (A.length - 1) * real.sizeof - mov ECX,A[EBP] ; // ECX = A.length - dec ECX ; - lea EDX,[ECX*8] ; - lea EDX,[EDX][ECX*4] ; - add EDX,A+4[EBP] ; - fld real ptr [EDX] ; // ST0 = coeff[ECX] - jecxz return_ST ; - fld x[EBP] ; // ST0 = x - fxch ST(1) ; // ST1 = x, ST0 = r - align 4 ; - L2: fmul ST,ST(1) ; // r *= x - fld real ptr -12[EDX] ; - sub EDX,12 ; // deg-- - faddp ST(1),ST ; - dec ECX ; - jne L2 ; - fxch ST(1) ; // ST1 = r, ST0 = x - fstp ST(0) ; // dump x - align 4 ; - return_ST: ; - } - } - else version (DragonFlyBSD) - { - asm pure nothrow @nogc // assembler by W. Bright - { - // EDX = (A.length - 1) * real.sizeof - mov ECX,A[EBP] ; // ECX = A.length - dec ECX ; - lea EDX,[ECX*8] ; - lea EDX,[EDX][ECX*4] ; - add EDX,A+4[EBP] ; - fld real ptr [EDX] ; // ST0 = coeff[ECX] - jecxz return_ST ; - fld x[EBP] ; // ST0 = x - fxch ST(1) ; // ST1 = x, ST0 = r - align 4 ; - L2: fmul ST,ST(1) ; // r *= x - fld real ptr -12[EDX] ; - sub EDX,12 ; // deg-- - faddp ST(1),ST ; - dec ECX ; - jne L2 ; - fxch ST(1) ; // ST1 = r, ST0 = x - fstp ST(0) ; // dump x - align 4 ; - return_ST: ; - } - } else { static assert(0); diff --git a/std/parallelism.d b/std/parallelism.d index e4bdb0ced5f..bd467d21c3f 100644 --- a/std/parallelism.d +++ b/std/parallelism.d @@ -2763,9 +2763,6 @@ public: } } - foreach (ref t; tasks[]) - emplaceRef(t, RTask()); - // Hack to take the address of a nested function w/o // making a closure. static auto scopedAddress(D)(scope D del) @system @@ -2778,12 +2775,19 @@ public: void useTask(ref RTask task) { import std.algorithm.comparison : min; + import core.lifetime : emplace; + + // Private constructor, so can't feed it's arguments directly + // to emplace + emplace(&task, RTask + ( + scopedAddress(&reduceOnRange), + range, + curPos, // lower bound. + cast() min(len, curPos + workUnitSize) // upper bound. + )); task.pool = this; - task._args[0] = scopedAddress(&reduceOnRange); - task._args[3] = min(len, curPos + workUnitSize); // upper bound. - task._args[1] = range; // range - task._args[2] = curPos; // lower bound. curPos += workUnitSize; } @@ -3535,6 +3539,21 @@ public: assert(taskPool.fold!("a + b", "a + b")(r, 0, 0, 42) == tuple(expected, expected)); } +// Issue 16705 +@system unittest +{ + struct MyIota + { + size_t front; + void popFront()(){front++;} + auto empty(){return front >= 25;} + auto opIndex(size_t i){return front+i;} + auto length(){return 25-front;} + } + + auto mySum = taskPool.reduce!"a + b"(MyIota()); +} + /** Returns a lazily initialized global instantiation of `TaskPool`. This function can safely be called concurrently from multiple non-worker diff --git a/std/system.d b/std/system.d index 7a115da5409..55fcfd773b7 100644 --- a/std/system.d +++ b/std/system.d @@ -36,6 +36,7 @@ immutable watchOS, /// watchOS freeBSD, /// FreeBSD netBSD, /// NetBSD + openBSD, /// OpenBSD dragonFlyBSD, /// DragonFlyBSD solaris, /// Solaris android, /// Android @@ -54,6 +55,7 @@ immutable else version (watchOS) OS os = OS.watchOS; else version (FreeBSD) OS os = OS.freeBSD; else version (NetBSD) OS os = OS.netBSD; + else version (OpenBSD) OS os = OS.openBSD; else version (DragonFlyBSD) OS os = OS.dragonFlyBSD; else version (Posix) OS os = OS.otherPosix; else OS os = OS.unknown;