summaryrefslogtreecommitdiffstats
path: root/libphobos
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2021-12-20 19:25:32 +0100
committerIain Buclaw <ibuclaw@gdcproject.org>2021-12-20 19:29:43 +0100
commitb3f58f87d78b958e35e4a44f5fdb4b7721cb2837 (patch)
treecb6530272537c7d845faab6a1ce0042f3096f618 /libphobos
parentFix static array size in gcc.dg/vect/vect-simd-20.c (diff)
downloadgcc-b3f58f87d78b958e35e4a44f5fdb4b7721cb2837.tar.gz
gcc-b3f58f87d78b958e35e4a44f5fdb4b7721cb2837.tar.bz2
gcc-b3f58f87d78b958e35e4a44f5fdb4b7721cb2837.tar.xz
d: Merge upstream dmd ad8412530, druntime fd9a4544, phobos 495e835c2.
D front-end changes: - Import dmd v2.098.1 - Remove calling of _d_delstruct from code generator. Druntime changes: - Import druntime v2.098.1 Phobos changes: - Import phobos v2.098.1 gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd ad8412530. * expr.cc (ExprVisitor::visit (DeleteExp *)): Remove code generation of _d_delstruct. * runtime.def (DELSTRUCT): Remove. libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream druntime fd9a4544. * src/MERGE: Merge upstream phobos 495e835c2.
Diffstat (limited to 'libphobos')
-rw-r--r--libphobos/libdruntime/MERGE2
-rw-r--r--libphobos/libdruntime/core/builtins.d48
-rw-r--r--libphobos/libdruntime/core/lifetime.d20
-rw-r--r--libphobos/libdruntime/core/sys/linux/sched.d3
-rw-r--r--libphobos/libdruntime/object.d30
-rw-r--r--libphobos/src/MERGE2
-rw-r--r--libphobos/src/std/format/write.d23
-rw-r--r--libphobos/src/std/range/interfaces.d9
-rw-r--r--libphobos/src/std/typecons.d2
9 files changed, 112 insertions, 27 deletions
diff --git a/libphobos/libdruntime/MERGE b/libphobos/libdruntime/MERGE
index b3da9063ce3..70f7ff596a8 100644
--- a/libphobos/libdruntime/MERGE
+++ b/libphobos/libdruntime/MERGE
@@ -1,4 +1,4 @@
16364e010bc87f3621028c8ac648133535c126fb3 1fd9a45448244fb9dd4326520ad8526c540895eb0
2 2
3The first line of this file holds the git revision number of the last 3The first line of this file holds the git revision number of the last
4merge done from the dlang/druntime repository. 4merge done from the dlang/druntime repository.
diff --git a/libphobos/libdruntime/core/builtins.d b/libphobos/libdruntime/core/builtins.d
index f2ca5038c59..1ed80f7d94a 100644
--- a/libphobos/libdruntime/core/builtins.d
+++ b/libphobos/libdruntime/core/builtins.d
@@ -1,11 +1,45 @@
1/********************************************** 1/**********************************************
2 * This module implements common builtins for the D frontend. 2To provide access to features that would be otherwise counterproductive or
3 * 3difficult to implement, compilers provide an interface consisting of a set
4 * Copyright: Copyright © 2019, The D Language Foundation 4of builtins (also called intrinsics) which can be called like normal functions.
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 5
6 * Authors: Walter Bright 6This module exposes builtins both common to all D compilers
7 * Source: $(DRUNTIMESRC core/builtins.d) 7(those provided by the frontend) and specific to the host compiler i.e. those
8 */ 8specific to either LLVM or GCC (`ldc.intrinsics` and `gcc.builtins` are publicly imported, respectively).
9Host-specific intrinsics cannot be reliably listed here, however listings can be found
10at the documentation for the relevant backends, i.e.
11$(LINK2 https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html, GCC) and
12$(LINK2 https://llvm.org/docs/LangRef.html, LLVM). It should be noted that not all
13builtins listed are necessarily supported by the host compiler, please file a bug
14if this is the case for your workload.
15
16Use of this module reduces the amount of conditional compilation needed
17to use a given builtin. For example, to write a target independent function
18that uses prefetching we can write the following:
19---
20float usePrefetch(float[] x)
21{
22 // There is only one import statement required rather than two (versioned) imports
23 import core.builtins;
24 version (GNU)
25 __builtin_prefetch(x.ptr);
26 version (LDC)
27 /+
28 For the curious: 0, 3, 1 mean `x` will only be read-from (0), it will be used
29 very often (3), and it should be fetched to the data-cache (1).
30 +/
31 llvm_prefetch(x.ptr, 0, 3, 1);
32 const doMath = blahBlahBlah;
33 return doMath;
34}
35---
36
37
38Copyright: Copyright © 2021, The D Language Foundation
39License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
40Authors: Walter Bright
41Source: $(DRUNTIMESRC core/builtins.d)
42*/
9 43
10module core.builtins; 44module core.builtins;
11 45
diff --git a/libphobos/libdruntime/core/lifetime.d b/libphobos/libdruntime/core/lifetime.d
index 8fb61a547d5..9a99f2da02a 100644
--- a/libphobos/libdruntime/core/lifetime.d
+++ b/libphobos/libdruntime/core/lifetime.d
@@ -1545,9 +1545,8 @@ template forward(args...)
1545{ 1545{
1546 import core.internal.traits : AliasSeq; 1546 import core.internal.traits : AliasSeq;
1547 1547
1548 static if (args.length) 1548 template fwd(alias arg)
1549 { 1549 {
1550 alias arg = args[0];
1551 // by ref || lazy || const/immutable 1550 // by ref || lazy || const/immutable
1552 static if (__traits(isRef, arg) || 1551 static if (__traits(isRef, arg) ||
1553 __traits(isOut, arg) || 1552 __traits(isOut, arg) ||
@@ -1556,15 +1555,16 @@ template forward(args...)
1556 alias fwd = arg; 1555 alias fwd = arg;
1557 // (r)value 1556 // (r)value
1558 else 1557 else
1559 @property auto fwd(){ return move(arg); } 1558 @property auto fwd(){ pragma(inline, true); return move(arg); }
1560
1561 static if (args.length == 1)
1562 alias forward = fwd;
1563 else
1564 alias forward = AliasSeq!(fwd, forward!(args[1..$]));
1565 } 1559 }
1560
1561 alias Result = AliasSeq!();
1562 static foreach (arg; args)
1563 Result = AliasSeq!(Result, fwd!arg);
1564 static if (Result.length == 1)
1565 alias forward = Result[0];
1566 else 1566 else
1567 alias forward = AliasSeq!(); 1567 alias forward = Result;
1568} 1568}
1569 1569
1570/// 1570///
@@ -2316,7 +2316,7 @@ template _d_delstructImpl(T)
2316@system pure nothrow unittest 2316@system pure nothrow unittest
2317{ 2317{
2318 int dtors = 0; 2318 int dtors = 0;
2319 struct S { ~this() { ++dtors; } } 2319 struct S { ~this() nothrow { ++dtors; } }
2320 2320
2321 S *s = new S(); 2321 S *s = new S();
2322 _d_delstructImpl!(typeof(s))._d_delstruct(s); 2322 _d_delstructImpl!(typeof(s))._d_delstruct(s);
diff --git a/libphobos/libdruntime/core/sys/linux/sched.d b/libphobos/libdruntime/core/sys/linux/sched.d
index dc815a0fc3c..e828b7447d1 100644
--- a/libphobos/libdruntime/core/sys/linux/sched.d
+++ b/libphobos/libdruntime/core/sys/linux/sched.d
@@ -153,6 +153,9 @@ version (CRuntime_Glibc)
153 int sched_getcpu(); 153 int sched_getcpu();
154} 154}
155 155
156/* Reassociate the calling thread with namespace referred to by fd */
157int setns(int fd, int nstype);
158
156enum CLONE_FILES = 0x400; 159enum CLONE_FILES = 0x400;
157enum CLONE_FS = 0x200; 160enum CLONE_FS = 0x200;
158enum CLONE_NEWCGROUP = 0x2000000; 161enum CLONE_NEWCGROUP = 0x2000000;
diff --git a/libphobos/libdruntime/object.d b/libphobos/libdruntime/object.d
index 29b5d58de5b..c989caa64bf 100644
--- a/libphobos/libdruntime/object.d
+++ b/libphobos/libdruntime/object.d
@@ -4667,17 +4667,33 @@ public import core.internal.switch_: __switch_error;
4667public @trusted @nogc nothrow pure extern (C) void _d_delThrowable(scope Throwable); 4667public @trusted @nogc nothrow pure extern (C) void _d_delThrowable(scope Throwable);
4668 4668
4669// Compare class and interface objects for ordering. 4669// Compare class and interface objects for ordering.
4670private int __cmp(Obj)(Obj lhs, Obj rhs) 4670int __cmp(C1, C2)(C1 lhs, C2 rhs)
4671if (is(Obj : Object)) 4671if ((is(C1 : const(Object)) || (is(C1 == interface) && (__traits(getLinkage, C1) == "D"))) &&
4672 (is(C2 : const(Object)) || (is(C2 == interface) && (__traits(getLinkage, C2) == "D"))))
4672{ 4673{
4673 if (lhs is rhs) 4674 static if (is(C1 == typeof(null)) && is(C2 == typeof(null)))
4675 {
4674 return 0; 4676 return 0;
4675 // Regard null references as always being "less than" 4677 }
4676 if (!lhs) 4678 else static if (is(C1 == typeof(null)))
4679 {
4680 // Regard null references as always being "less than"
4677 return -1; 4681 return -1;
4678 if (!rhs) 4682 }
4683 else static if (is(C2 == typeof(null)))
4684 {
4679 return 1; 4685 return 1;
4680 return lhs.opCmp(rhs); 4686 }
4687 else
4688 {
4689 if (lhs is rhs)
4690 return 0;
4691 if (lhs is null)
4692 return -1;
4693 if (rhs is null)
4694 return 1;
4695 return lhs.opCmp(rhs);
4696 }
4681} 4697}
4682 4698
4683// objects 4699// objects
diff --git a/libphobos/src/MERGE b/libphobos/src/MERGE
index c9d166b03a7..b517749b542 100644
--- a/libphobos/src/MERGE
+++ b/libphobos/src/MERGE
@@ -1,4 +1,4 @@
1575b67a9b4f78415f96ca77ad50b2de4c667cc74 1495e835c2da47606142ff24c85de707e3b955a9a
2 2
3The first line of this file holds the git revision number of the last 3The first line of this file holds the git revision number of the last
4merge done from the dlang/phobos repository. 4merge done from the dlang/phobos repository.
diff --git a/libphobos/src/std/format/write.d b/libphobos/src/std/format/write.d
index c7587688fc0..e67d95ccc23 100644
--- a/libphobos/src/std/format/write.d
+++ b/libphobos/src/std/format/write.d
@@ -1287,3 +1287,26 @@ void formatValue(Writer, T, Char)(auto ref Writer w, auto ref T val, scope const
1287 1287
1288 assertThrown!FormatException(formattedWrite(w, "%(%0*d%)", new int[1])); 1288 assertThrown!FormatException(formattedWrite(w, "%(%0*d%)", new int[1]));
1289} 1289}
1290
1291// https://issues.dlang.org/show_bug.cgi?id=22609
1292@safe pure unittest
1293{
1294 static enum State: ubyte { INACTIVE }
1295 static struct S {
1296 State state = State.INACTIVE;
1297 int generation = 1;
1298 alias state this;
1299 // DMDBUG: https://issues.dlang.org/show_bug.cgi?id=16657
1300 auto opEquals(S other) const { return state == other.state && generation == other.generation; }
1301 auto opEquals(State other) const { return state == other; }
1302 }
1303
1304 import std.array : appender;
1305 import std.format.spec : singleSpec;
1306
1307 auto writer = appender!string();
1308 const spec = singleSpec("%s");
1309 S a;
1310 writer.formatValue(a, spec);
1311 assert(writer.data == "0");
1312}
diff --git a/libphobos/src/std/range/interfaces.d b/libphobos/src/std/range/interfaces.d
index 475f35b51da..6d55d4149c7 100644
--- a/libphobos/src/std/range/interfaces.d
+++ b/libphobos/src/std/range/interfaces.d
@@ -201,6 +201,9 @@ interface RandomAccessFinite(E) : BidirectionalRange!(E) {
201 201
202/**Interface for an infinite random access range of type `E`.*/ 202/**Interface for an infinite random access range of type `E`.*/
203interface RandomAccessInfinite(E) : ForwardRange!E { 203interface RandomAccessInfinite(E) : ForwardRange!E {
204 ///
205 enum bool empty = false;
206
204 /**Calls $(REF moveAt, std, range, primitives) on the wrapped range, if 207 /**Calls $(REF moveAt, std, range, primitives) on the wrapped range, if
205 * possible. Otherwise, throws an $(LREF UnsupportedRangeMethod) exception. 208 * possible. Otherwise, throws an $(LREF UnsupportedRangeMethod) exception.
206 */ 209 */
@@ -213,6 +216,12 @@ interface RandomAccessInfinite(E) : ForwardRange!E {
213 E opIndex(size_t); 216 E opIndex(size_t);
214} 217}
215 218
219// https://issues.dlang.org/show_bug.cgi?id=22608
220@safe unittest
221{
222 static assert(isRandomAccessRange!(RandomAccessInfinite!int));
223}
224
216/**Adds assignable elements to InputRange.*/ 225/**Adds assignable elements to InputRange.*/
217interface InputAssignable(E) : InputRange!E { 226interface InputAssignable(E) : InputRange!E {
218 /// 227 ///
diff --git a/libphobos/src/std/typecons.d b/libphobos/src/std/typecons.d
index 6dee863521d..cde2b9da055 100644
--- a/libphobos/src/std/typecons.d
+++ b/libphobos/src/std/typecons.d
@@ -6971,7 +6971,7 @@ mixin template Proxy(alias a)
6971 static if (is(typeof(a.opCmp(b)))) 6971 static if (is(typeof(a.opCmp(b))))
6972 return a.opCmp(b); 6972 return a.opCmp(b);
6973 else static if (is(typeof(b.opCmp(a)))) 6973 else static if (is(typeof(b.opCmp(a))))
6974 return -b.opCmp(b); 6974 return -b.opCmp(a);
6975 else 6975 else
6976 return a < b ? -1 : a > b ? +1 : 0; 6976 return a < b ? -1 : a > b ? +1 : 0;
6977 } 6977 }